Project

General

Profile

Statistics
| Branch: | Revision:

root / scout / libscout / src / introlab / misty / draw_misty_name.cpp @ 73f82b31

History | View | Annotate | Download (7.01 KB)

1
/**
2
 * Copyright (c) 2011 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 */
25

    
26
#include "draw_misty_name.h"
27

    
28
/**
29
 * In here we define the run function which specifies the behavior
30
 * that the scout will run.
31
 */
32
void draw_misty_name::turnRight() {
33
    Duration one_second(0.954);
34
    motors->set_sides(26, -26, MOTOR_ABSOLUTE);
35
    one_second.sleep();
36
}
37
void draw_misty_name::run()
38
{
39
  /**
40
   * This loop runs as long as ROS is ok. This is necessary to make
41
   * sure that our program terminates if something is wrong with ROS.
42
   * And if not continues to run.
43
   */
44
    Duration half_second(0.5);
45
    Duration one_second(1.0);
46
    Duration one_point_five(1.5);
47
    Duration three_second(3.0);
48
    Duration weird_sleep(1.1);
49
    while(ok()){
50
        one_second.sleep();
51

    
52
        // move to a good position
53
        turnRight();
54
        turnRight();
55
        motors->set_sides(100, 100, MOTOR_ABSOLUTE);
56
        half_second.sleep();
57
        turnRight();
58
        turnRight();
59
        turnRight();
60

    
61

    
62

    
63
        // first edge of M
64
        motors->set_sides(100,100, MOTOR_ABSOLUTE);
65
        three_second.sleep();
66

    
67
        // turn at top left
68
        motors->set_sides(30,-30, MOTOR_ABSOLUTE);
69
        one_second.sleep();
70
        one_second.sleep();
71

    
72
        // second edge of M
73
        motors->set_sides(100,100, MOTOR_ABSOLUTE);
74
        one_point_five.sleep();
75

    
76
        // turn at middle
77
        motors->set_sides(-30, 30, MOTOR_ABSOLUTE);
78
        one_second.sleep();
79
        one_second.sleep();
80

    
81
        // third edge of M
82
        motors->set_sides(100,100, MOTOR_ABSOLUTE);
83
        one_point_five.sleep();
84

    
85
        // turn at top right
86
        motors->set_sides(127,-127, MOTOR_ABSOLUTE);
87
        one_second.sleep();
88
        one_second.sleep();
89

    
90
        // last edge!!!
91
        motors->set_sides(100,100, MOTOR_ABSOLUTE);
92
        three_second.sleep();
93

    
94
        // starting to draw i!!! which should be farely simple!!!
95
        motors->set_sides(-100,100, MOTOR_ABSOLUTE);
96
        one_point_five.sleep();
97

    
98
        motors->set_sides(-20,100, MOTOR_ABSOLUTE);
99
        one_second.sleep();
100
        one_second.sleep();
101
        one_second.sleep();
102

    
103
        motors->set_sides(50, 50, MOTOR_ABSOLUTE);
104
        one_second.sleep();
105

    
106
        motors->set_sides(-50, -50, MOTOR_ABSOLUTE);
107
        one_second.sleep();
108

    
109

    
110
        motors->set_sides(-100, 20, MOTOR_ABSOLUTE);
111
        one_second.sleep();
112
        one_second.sleep();
113
        one_second.sleep();
114

    
115
        // start drawing s
116
        motors->set_sides(127,-127, MOTOR_ABSOLUTE);
117
        one_second.sleep();
118
        weird_sleep.sleep();
119

    
120

    
121

    
122
        motors->set_sides(-50,127, MOTOR_ABSOLUTE);
123
        one_second.sleep();
124
        one_second.sleep();
125

    
126
        motors->set_sides(127, -50, MOTOR_ABSOLUTE);
127
        one_second.sleep();
128
        one_second.sleep();
129

    
130
        // come back to s
131
        motors->set_sides(-127, 50, MOTOR_ABSOLUTE);
132
        one_second.sleep();
133
        one_second.sleep();
134

    
135
        motors->set_sides(50,-127, MOTOR_ABSOLUTE);
136
        one_second.sleep();
137
        one_second.sleep();
138

    
139
        // start drawing t
140
        motors->set_sides(100,-100, MOTOR_ABSOLUTE);
141
        one_second.sleep();
142

    
143
        motors->set_sides(-20,100, MOTOR_ABSOLUTE);
144
        one_second.sleep();
145
        one_second.sleep();
146
        one_second.sleep();
147

    
148
        motors->set_sides(50, 50, MOTOR_ABSOLUTE);
149
        one_second.sleep();
150

    
151
        // a + at the tip of t
152

    
153
        //left
154
        motors->set_sides(-50,50, MOTOR_ABSOLUTE);
155
        one_second.sleep();
156
        one_second.sleep();
157
        one_point_five.sleep();
158

    
159
        motors->set_sides(50,50, MOTOR_ABSOLUTE);
160
        one_second.sleep();
161

    
162
        motors->set_sides(-50,-50, MOTOR_ABSOLUTE);
163
        one_second.sleep();
164

    
165
        // top
166
        motors->set_sides(50,-50, MOTOR_ABSOLUTE);
167
        one_second.sleep();
168
        one_point_five.sleep();
169
        one_second.sleep();
170

    
171
        motors->set_sides(50,50, MOTOR_ABSOLUTE);
172
        one_second.sleep();
173

    
174
        motors->set_sides(-50,-50, MOTOR_ABSOLUTE);
175
        one_second.sleep();
176

    
177
        // right
178
        motors->set_sides(50,-50, MOTOR_ABSOLUTE);
179
        one_point_five.sleep();
180
        one_second.sleep();
181
        one_second.sleep();
182

    
183
        motors->set_sides(50,50, MOTOR_ABSOLUTE);
184
        one_second.sleep();
185

    
186
        motors->set_sides(-50,-50, MOTOR_ABSOLUTE);
187
        one_second.sleep();
188

    
189
        // down 
190
        motors->set_sides(-50,50, MOTOR_ABSOLUTE);
191
        one_second.sleep();
192
        one_point_five.sleep();
193
        one_second.sleep();
194

    
195
        motors->set_sides(-50, -50, MOTOR_ABSOLUTE);
196
        one_second.sleep();
197

    
198

    
199
        motors->set_sides(-100, 20, MOTOR_ABSOLUTE);
200
        one_second.sleep();
201
        one_second.sleep();
202

    
203
        // start drawing y
204
        motors->set_sides(-100, 100, MOTOR_ABSOLUTE);
205
        one_second.sleep();
206
        one_second.sleep();
207
        one_second.sleep();
208
        one_point_five.sleep();
209

    
210
        motors->set_sides(-30, 127, MOTOR_ABSOLUTE);
211
        one_second.sleep();
212

    
213
        motors->set_sides(50, 50, MOTOR_ABSOLUTE);
214
        one_second.sleep();
215

    
216
        motors->set_sides(-50,-50, MOTOR_ABSOLUTE);
217
        one_second.sleep();
218

    
219
        motors->set_sides(-127, 70, MOTOR_ABSOLUTE);
220
        one_point_five.sleep();
221
        one_point_five.sleep();
222

    
223
        motors->set_sides(-50,-50, MOTOR_ABSOLUTE);
224
        one_second.sleep();
225

    
226
        motors->set_sides(110, 110, MOTOR_ABSOLUTE);
227
        one_point_five.sleep();
228

    
229
        motors->set_sides(100,-40, MOTOR_ABSOLUTE);
230
        three_second.sleep();
231
        three_second.sleep();
232

    
233
        motors->set_sides(100,100, MOTOR_ABSOLUTE);
234
        one_second.sleep();
235
        one_second.sleep();
236

    
237
        ROS_INFO("hallo!");
238
        /* WRITE YOUR SCOUT BEHAVIOR HERE */
239

    
240
        /**
241
         * These two functions cause the world to update its
242
         * state (spinOnce) and causes us to wait for incoming
243
         * messages (loop_rate->sleep). These are necessary for
244
         * ROS to do its job. You can think of this as ROS voodoo magic.
245
         */
246

    
247
        spinOnce();
248
        loop_rate->sleep();
249
        motors->set_sides(0,0,MOTOR_ABSOLUTE);
250
        break;
251
      }
252
}