Project

General

Profile

Revision 73f82b31

ID73f82b31b433c09d1b299dfd02e6bd27505dfc62
Parent d0876993
Child 0fd64186

Added by Yuyang Guo over 9 years ago

highlevel software introlab0 setup

View differences:

scout/libscout/CMakeLists.txt
35 35
set(MAIN_FILES src/Sensors.cpp src/Behavior.cpp src/BehaviorList.cpp src/BehaviorProcess.cpp)
36 36
FILE(GLOB BEHAVIOR_FILES "${PROJECT_SOURCE_DIR}/src/behaviors/*.cpp")
37 37
FILE(GLOB TEST_BEHAVIOR_FILES "${PROJECT_SOURCE_DIR}/src/test_behaviors/*.cpp")
38
FILE(GLOB INTRO_LAB_FILES "${PROJECT_SOURCE_DIR}/src/introlab/*/*.cpp")
38 39
FILE(GLOB HELPER_FILES "${PROJECT_SOURCE_DIR}/src/helper_classes/*.cpp")
39 40
FILE(GLOB CONTROL_CLASSES "${PROJECT_SOURCE_DIR}/src/*Control.cpp")
40 41
set(WIRELESS_CONTROL_CLASSES src/WirelessSender.cpp src/WirelessReceiver.cpp)
41 42

  
42
rosbuild_add_executable(libscout ${MAIN_FILES} ${CONTROL_CLASSES} ${WIRELESS_CONTROL_CLASSES} ${HELPER_FILES} ${BEHAVIOR_FILES} ${TEST_BEHAVIOR_FILES})
43
rosbuild_add_executable(libscout ${MAIN_FILES} ${CONTROL_CLASSES} ${WIRELESS_CONTROL_CLASSES} ${HELPER_FILES} ${BEHAVIOR_FILES} ${TEST_BEHAVIOR_FILES} ${INTRO_LAB_FILES})
43 44
rosbuild_add_compile_flags(libscout -std=c++0x)
scout/libscout/generate_behavior_lists.py
52 52

  
53 53
# Extract all the header files for behaviors we want
54 54
for path, dirname, fnames in os.walk('src'):
55
    if path == 'src/behaviors' or path == 'src/test_behaviors':
55
    if path == 'src/behaviors' or path == 'src/test_behaviors' or path.startswith("src/introlab"):
56 56
        path_parts = path.split('/')
57
        modified_path = path.lstrip("src/")
57 58
        for f in fnames:
58 59
            if f.endswith('.h'):
59 60
                all_paths.append(path)
60 61
                all_fnames.append(f)
61
                all_lasts.append(path_parts[-1])
62
                all_lasts.append(modified_path)
62 63

  
63 64
# Sort these headers into a good order and add them to our lists of paths/names
64 65
all_fnames, all_paths, all_lasts = (list(t) for t in zip(*sorted(zip(all_fnames, all_paths, all_lasts), key=lambda x: x[0].lower())))
scout/libscout/src/introlab/draw_someone_name.cppfake
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_<someone>_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_<someone>_name::turnRight() {
33
    Duration one_second(0.954);
34
    motors->set_sides(26, -26, MOTOR_ABSOLUTE);
35
    one_second.sleep();
36
}
37
void draw_<someone>_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
        ROS_INFO("hallo!");
51
        /* WRITE YOUR SCOUT BEHAVIOR HERE */
52

  
53
        /**
54
         * These two functions cause the world to update its
55
         * state (spinOnce) and causes us to wait for incoming
56
         * messages (loop_rate->sleep). These are necessary for
57
         * ROS to do its job. You can think of this as ROS voodoo magic.
58
         */
59

  
60
        spinOnce();
61
        loop_rate->sleep();
62
        motors->set_sides(0,0,MOTOR_ABSOLUTE);
63
        break;
64
      }
65
}
scout/libscout/src/introlab/misty/draw_misty_name.cpp
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
}
scout/libscout/src/introlab/misty/draw_misty_name.h
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
#ifndef _DRAW_MISTY_NAME_H_
27
#define _DRAW_MISTY_NAME_H_
28

  
29
#include "../../Behavior.h"
30

  
31
/** 
32
 * The following class inherits the behavior class. This
33
 * means that all functions and variables defined
34
 * in the Behavior class also apply to this class.
35
 */
36
class draw_misty_name : Behavior
37
{
38
    public:
39
        /** 
40
         * The following line is the constructor of this class.
41
         * It first calls the Behavior class's constructor with some
42
         * parameters and then does nothing on its own.
43
         */
44
        draw_misty_name(std::string scoutname, Sensors* sensors)
45
            : Behavior(scoutname, "draw_misty_name", sensors) {};
46

  
47
        /** This is the function that when called actually executes
48
         * the behavior. */
49
        void run();
50
    private:
51
        void turnRight();
52
};
53

  
54
#endif

Also available in: Unified diff