Revision c384dc7e
ID | c384dc7e5c99254e07ef0d46bef2b9dfaf32e817 |
Updated the Behavior definition and extensions.
The Behavior.cpp/h class now works and can be extended by simply implementing its run() method. However, the subclass must also be extantiated and used in an external executable. An example of this can be seen in PriyaBehavior.cpp/h, and the executable, priya_behavior_process.cpp. In the future, we should move all behaviors into a behaviors/ folder, and autogenerate the executable to be compiled.
I also changed Behavior and the MotorControl class to accept a scoutname string as a parameter so that each behavior only controls a single scout. This means when you call the priya_behavior_process executable, you pass it one argument (the name of the scout in scoutsim), and all control classes will prefix their output ROS messages with that scoutname so that only the scout you intended gets the messages.
I removed behavior files which do not use this new abstract behavior class.
scout/libscout/CMakeLists.txt | ||
---|---|---|
29 | 29 |
#rosbuild_add_executable(example examples/example.cpp) |
30 | 30 |
#target_link_libraries(example ${PROJECT_NAME}) |
31 | 31 |
|
32 |
#rosbuild_add_executable(libscout_node src/behavior.cpp src/libscout.cpp src/libmotors.cpp src/libheadlights.cpp src/libbuttons.cpp) |
|
33 | 32 |
rosbuild_add_executable(alex_behavior src/alex_behavior.cpp src/libscout.h src/MotorControl.cpp src/HeadlightControl.cpp) |
33 |
rosbuild_add_executable(priya_behavior src/priya_behavior_process.cpp src/PriyaBehavior.cpp src/Behavior.cpp src/libscout.h src/MotorControl.cpp src/HeadlightControl.cpp) |
|
34 |
rosbuild_add_executable(drive_square src/drive_square.cpp src/libscout.h src/MotorControl.cpp src/HeadlightControl.cpp) |
scout/libscout/src/Behavior.cpp | ||
---|---|---|
31 | 31 |
* |
32 | 32 |
* @author Colony Project, CMU Robotics Club |
33 | 33 |
* @author Priyanka Deo |
34 |
* @author Alex Zirbel |
|
34 | 35 |
**/ |
35 | 36 |
|
36 | 37 |
#include "Behavior.h" |
37 | 38 |
|
38 |
Behavior::init(int argc, char** argv) |
|
39 |
{ |
|
40 |
ros::init(argc, argv, "libscout"); |
|
39 |
using namespace std; |
|
41 | 40 |
|
42 |
motors(node); |
|
41 |
Behavior::Behavior(string scoutname) |
|
42 |
{ |
|
43 |
motors = new MotorControl(node, scoutname); |
|
44 |
loop_rate = new ros::Rate(10); |
|
43 | 45 |
//buttons(node); |
44 | 46 |
//sonar(node); |
45 |
|
|
46 |
ros::Rate loop_rate(10); |
|
47 | 47 |
} |
48 | 48 |
|
49 |
Behavior::ok() |
|
49 |
bool Behavior::ok()
|
|
50 | 50 |
{ |
51 |
return ros::ok() |
|
51 |
return ros::ok();
|
|
52 | 52 |
} |
53 | 53 |
|
54 |
Behavior::spin() |
|
54 |
void Behavior::spin()
|
|
55 | 55 |
{ |
56 | 56 |
ros::spin(); |
57 | 57 |
return; |
58 | 58 |
} |
59 | 59 |
|
60 |
Behavior::spinOnce() |
|
60 |
void Behavior::spinOnce()
|
|
61 | 61 |
{ |
62 |
ros::SpinOnce();
|
|
62 |
ros::spinOnce();
|
|
63 | 63 |
return; |
64 | 64 |
} |
scout/libscout/src/Behavior.h | ||
---|---|---|
31 | 31 |
* |
32 | 32 |
* @author Colony Project, CMU Robotics Club |
33 | 33 |
* @author Priyanka Deo |
34 |
* @author Alex Zirbel |
|
34 | 35 |
**/ |
35 | 36 |
|
36 |
#ifdef _BEHAVIOR_H_ |
|
37 |
#ifndef _BEHAVIOR_H_
|
|
37 | 38 |
#define _BEHAVIOR_H_ |
38 | 39 |
|
39 |
#include "libscout.h" |
|
40 |
#include <ros/ros.h> |
|
41 |
#include <libscout/constants.h> |
|
42 |
|
|
43 |
#include "MotorControl.h" |
|
44 |
#include "HeadlightControl.h" |
|
45 |
#include "SonarControl.h" |
|
40 | 46 |
|
41 | 47 |
class Behavior |
42 | 48 |
{ |
43 | 49 |
public: |
44 |
ros::NodeHandle node; |
|
45 |
ros::Rate loop_rate; |
|
46 |
|
|
47 |
//Declare all used library controls |
|
48 |
MotorControl motors; |
|
49 |
//ButtonControl buttons; |
|
50 |
//SonarControl sonar; |
|
50 |
// Initializes ROS for behavior |
|
51 |
Behavior(std::string scoutname); |
|
51 | 52 |
|
52 |
//Initializes ROS for behavior
|
|
53 |
void init(int argc, char** argv);
|
|
53 |
// User implemented behavior
|
|
54 |
virtual void run() = 0;
|
|
54 | 55 |
|
55 |
//User implemented behavior |
|
56 |
virtual int main(int argc, char** argv) = 0; |
|
56 |
protected: |
|
57 |
ros::NodeHandle node; |
|
58 |
ros::Rate *loop_rate; |
|
57 | 59 |
|
58 |
//Wrappers for ROS functions
|
|
59 |
bool ok();
|
|
60 |
void spin();
|
|
61 |
void spinOnce();
|
|
60 |
// Declare all used library controls
|
|
61 |
MotorControl * motors;
|
|
62 |
//ButtonControl buttons;
|
|
63 |
//SonarControl sonar;
|
|
62 | 64 |
|
65 |
// Wrappers for ROS functions |
|
66 |
bool ok(); |
|
67 |
void spin(); |
|
68 |
void spinOnce(); |
|
63 | 69 |
}; |
64 | 70 |
|
65 | 71 |
#endif |
scout/libscout/src/MotorControl.cpp | ||
---|---|---|
37 | 37 |
|
38 | 38 |
#include "MotorControl.h" |
39 | 39 |
|
40 |
using namespace std; |
|
41 |
|
|
40 | 42 |
/** |
41 | 43 |
* @brief Initialize the motors module of libscout. |
42 | 44 |
* |
43 | 45 |
* Initialize the libscout node as a publisher of set_motors and a client of |
44 | 46 |
* query_motors. |
45 | 47 |
*/ |
46 |
MotorControl::MotorControl(const ros::NodeHandle& libscout_node) |
|
48 |
MotorControl::MotorControl(const ros::NodeHandle& libscout_node, |
|
49 |
string scoutname) |
|
47 | 50 |
: node(libscout_node) |
48 | 51 |
{ |
49 | 52 |
set_motors_pub = |
50 |
node.advertise<motors::set_motors>("scout1/set_motors", QUEUE_SIZE); |
|
53 |
node.advertise<motors::set_motors>(scoutname + "/set_motors", |
|
54 |
QUEUE_SIZE); |
|
51 | 55 |
query_motors_client = |
52 |
node.serviceClient<motors::query_motors>("query_motors");
|
|
56 |
node.serviceClient<motors::query_motors>(scoutname + "/query_motors");
|
|
53 | 57 |
} |
54 | 58 |
|
55 | 59 |
/** |
scout/libscout/src/MotorControl.h | ||
---|---|---|
76 | 76 |
{ |
77 | 77 |
public: |
78 | 78 |
/** Set up the motor node and prepare to communicate over ROS */ |
79 |
MotorControl(const ros::NodeHandle& libscout_node); |
|
79 |
MotorControl(const ros::NodeHandle& libscout_node, |
|
80 |
std::string scoutname); |
|
80 | 81 |
|
81 | 82 |
/** Uses which to specify what to change, and sets all to same speed */ |
82 | 83 |
void set(int which, float speed, char units=MOTOR_DEFAULT_UNIT); |
... | ... | |
112 | 113 |
ros::ServiceClient query_motors_client; |
113 | 114 |
|
114 | 115 |
ros::NodeHandle node; |
115 |
|
|
116 | 116 |
}; |
117 | 117 |
|
118 | 118 |
#endif |
scout/libscout/src/PriyaBehavior.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 |
/** |
|
27 |
* @file PriyaBehavior.cpp |
|
28 |
* @brief A simple robot behavior, smart-runaround style, that uses |
|
29 |
* the behavior class |
|
30 |
* |
|
31 |
* @author Colony Project, CMU Robotics Club |
|
32 |
* @author Alex Zirbel |
|
33 |
* @author Priyanka Deo |
|
34 |
*/ |
|
35 |
|
|
36 |
#include "PriyaBehavior.h" |
|
37 |
|
|
38 |
void PriyaBehavior::run() |
|
39 |
{ |
|
40 |
while(ok()) |
|
41 |
{ |
|
42 |
motors->set_sides(20, 80, MOTOR_ABSOLUTE); |
|
43 |
|
|
44 |
spinOnce(); |
|
45 |
loop_rate->sleep(); |
|
46 |
} |
|
47 |
} |
scout/libscout/src/PriyaBehavior.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 |
/** |
|
27 |
* @file PriyaBehavior.h |
|
28 |
* @brief A simple behavior which drives the scout in a circle. |
|
29 |
* |
|
30 |
* @author Colony Project, CMU Robotics Club |
|
31 |
* @author Priyanka Deo |
|
32 |
* @author Alex Zirbel |
|
33 |
**/ |
|
34 |
|
|
35 |
#ifndef _PRIYA_BEHAVIOR_H_ |
|
36 |
#define _PRIYA_BEHAVIOR_H_ |
|
37 |
|
|
38 |
#include "Behavior.h" |
|
39 |
|
|
40 |
/** |
|
41 |
* @brief PriyaBehavior A simple robot behavior. |
|
42 |
* |
|
43 |
* Inherits Behavior class which contains all basic behavior |
|
44 |
* functionality. |
|
45 |
*/ |
|
46 |
class PriyaBehavior : Behavior |
|
47 |
{ |
|
48 |
public: |
|
49 |
|
|
50 |
PriyaBehavior(std::string scoutname) : Behavior(scoutname) {} |
|
51 |
/** |
|
52 |
* @brief Runs the behavior. |
|
53 |
*/ |
|
54 |
void run(); |
|
55 |
}; |
|
56 |
|
|
57 |
#endif |
scout/libscout/src/alex_behavior.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 |
/** |
|
27 |
* @file alex_behavior.cpp |
|
28 |
* @brief A simple robot behavior, smart-runaround style. |
|
29 |
* |
|
30 |
* @author Colony Project, CMU Robotics Club |
|
31 |
* @author Alex Zirbel |
|
32 |
*/ |
|
33 |
|
|
34 |
#include "libscout.h" |
|
35 |
|
|
36 |
/** |
|
37 |
* @brief Main. The main function for the behavior. |
|
38 |
* |
|
39 |
* This is the main function for libscout. It calls init() which initializes |
|
40 |
* the clients and publishers/subscribers for the other parts of the library. |
|
41 |
*/ |
|
42 |
int main(int argc, char **argv) |
|
43 |
{ |
|
44 |
ros::init(argc, argv, "libscout"); |
|
45 |
|
|
46 |
ros::NodeHandle node; |
|
47 |
|
|
48 |
MotorControl motors(node); |
|
49 |
//ButtonControl buttons(node); |
|
50 |
|
|
51 |
ros::Rate loop_rate(10); |
|
52 |
|
|
53 |
while(ros::ok()) |
|
54 |
{ |
|
55 |
motors.set_sides(20, 80, MOTOR_ABSOLUTE); |
|
56 |
|
|
57 |
ros::spinOnce(); |
|
58 |
loop_rate.sleep(); |
|
59 |
} |
|
60 |
|
|
61 |
return 0; |
|
62 |
} |
scout/libscout/src/behavior.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 |
|
|
27 |
/** |
|
28 |
* @file behavior.cpp |
|
29 |
* @brief Contains behavior |
|
30 |
* |
|
31 |
* @author Colony Project, CMU Robotics Club |
|
32 |
* @author Ben Wasserman |
|
33 |
**/ |
|
34 |
|
|
35 |
#include "libscout.h" |
|
36 |
|
|
37 |
/*! |
|
38 |
* \brief Main. The main function for the behavior. |
|
39 |
* |
|
40 |
* This is the main function for libscout. It calls init() which initializes |
|
41 |
* the clients and publishers/subscribers for the other parts of the library. |
|
42 |
* |
|
43 |
* \param argc The number of command line arguments (should be 1) |
|
44 |
* \param argv The array of command line arguments |
|
45 |
**/ |
|
46 |
int main(int argc, char **argv){ |
|
47 |
/* Todo: Replace this tester code */ |
|
48 |
/* Creates a simple publisher/subscriber node to test simulator |
|
49 |
* for motors interface |
|
50 |
*/ |
|
51 |
|
|
52 |
/* Initialize ROS */ |
|
53 |
ros::init(argc, argv, "libscout"); |
|
54 |
/* Initialize Scout library */ |
|
55 |
init(LIB_ALL, argc, argv); |
|
56 |
|
|
57 |
/* Some nodehandle to something. I'd tell you what except its called n_ |
|
58 |
* so it wouldnt reflect in the rest of the code. |
|
59 |
*/ |
|
60 |
ros::NodeHandle n_; |
|
61 |
|
|
62 |
ros::Publisher motors_set = n_.advertise<motors::set_motors>("Stuff", 1000); |
|
63 |
|
|
64 |
ros::Rate loop_rate(10); |
|
65 |
|
|
66 |
while(ros::ok()){ |
|
67 |
motors::set_motors msg; |
|
68 |
|
|
69 |
/* Set message fields */ |
|
70 |
msg.fl_speed = 125; |
|
71 |
msg.bl_speed = 125; |
|
72 |
msg.fr_speed = 125; |
|
73 |
msg.br_speed = 125; |
|
74 |
msg.units = MOTOR_ABSOLUTE; |
|
75 |
|
|
76 |
/* publish */ |
|
77 |
motors_set.publish(msg); |
|
78 |
|
|
79 |
ros::spinOnce(); |
|
80 |
|
|
81 |
loop_rate.sleep(); |
|
82 |
} |
|
83 |
|
|
84 |
return 0; |
|
85 |
} |
scout/libscout/src/libscout.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 |
/** |
|
27 |
* @file libscout.cpp |
|
28 |
* @brief Contains top level scout library functions |
|
29 |
* |
|
30 |
* Contains functions and definitions for the use of |
|
31 |
* libscout |
|
32 |
* |
|
33 |
* @author Colony Project, CMU Robotics Club |
|
34 |
* @author Ben Wasserman |
|
35 |
*/ |
|
36 |
|
|
37 |
#include "libscout.h" |
|
38 |
|
|
39 |
/** @todo Decide how to call user behaviors |
|
40 |
* |
|
41 |
* I'm thinking that there be a function call in main that calls the "main" |
|
42 |
fn in the user behavior. However, their "main" function will not be called |
|
43 |
main. However, this has to be able to point to different functions by |
|
44 |
changing as little code in this file as possible. Also, the user behaviors |
|
45 |
should live in a different directory (possibly a different package). |
|
46 |
However, this other package should not be executed as a separate node, |
|
47 |
because that is the job of the libscout node/package to handle all the ROS |
|
48 |
stuff, and keep it under the lid. The user only has to call normal c |
|
49 |
functions. I also want to reduce the need to recompile this package when the |
|
50 |
user behavior, or any other package that works below the surface. |
|
51 |
*/ |
|
52 |
|
|
53 |
/** |
|
54 |
* @brief Initializes modules in the libscout. |
|
55 |
* |
|
56 |
* Calls init functions for each module in libscout. |
|
57 |
* @param modules A bitmask of the modules that will be initialized. |
|
58 |
*/ |
|
59 |
int init(int modules, int argc, char **argv) |
|
60 |
{ |
|
61 |
ros::init(argc, argv, "libscout"); |
|
62 |
|
|
63 |
ros::NodeHandle node; |
|
64 |
|
|
65 |
MotorControl motors = new MotorControl(node); |
|
66 |
HeadLightControl headlights = new HeadlightControl(node); |
|
67 |
SonarControl sonars = new SonarControl(node); |
|
68 |
|
|
69 |
/** @todo Copy this if for each module that gets added to the library */ |
|
70 |
/*if(modules & LIB_MOTORS) |
|
71 |
{ |
|
72 |
libmotors_init(); |
|
73 |
} |
|
74 |
if(modules & LIB_HEADLIGHTS) |
|
75 |
{ |
|
76 |
libheadlights_init(); |
|
77 |
} |
|
78 |
if(modules & LIB_BUTTONS) |
|
79 |
{ |
|
80 |
libbuttons_init(); |
|
81 |
}*/ |
|
82 |
/** @todo Add other lib inits **/ |
|
83 |
return 0; |
|
84 |
} |
|
85 |
|
scout/libscout/src/libscout.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 |
/** |
|
27 |
* @file libscout.h |
|
28 |
* @brief Contains top level scout library functions |
|
29 |
* |
|
30 |
* Contains functions and definitions for the use of |
|
31 |
* libscout |
|
32 |
* |
|
33 |
* @author Colony Project, CMU Robotics Club |
|
34 |
* @author Ben Wasserman |
|
35 |
**/ |
|
36 |
|
|
37 |
/* Author: Ben Wasserman |
|
38 |
*/ |
|
39 |
|
|
40 |
#ifndef _LIBSCOUT_H_ |
|
41 |
#define _LIBSCOUT_H_ |
|
42 |
|
|
43 |
#include <ros/ros.h> |
|
44 |
#include <libscout/constants.h> |
|
45 |
|
|
46 |
#include "MotorControl.h" |
|
47 |
#include "HeadlightControl.h" |
|
48 |
#include "SonarControl.h" |
|
49 |
|
|
50 |
/* Libscout functions */ |
|
51 |
int init(int modules, int argc, char **argv); |
|
52 |
|
|
53 |
#endif |
|
54 |
|
scout/libscout/src/priya_behavior.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 |
/** |
|
27 |
* @file priya_behavior.cpp |
|
28 |
* @brief A simple robot behavior, smart-runaround style, that uses |
|
29 |
* the behavior class |
|
30 |
* |
|
31 |
* @author Colony Project, CMU Robotics Club |
|
32 |
* @author Alex Zirbel |
|
33 |
* @author Priyanka Deo |
|
34 |
*/ |
|
35 |
|
|
36 |
#include "Behavior.h" |
|
37 |
|
|
38 |
/** |
|
39 |
* @brief Priya_Behavior A simple robot behavior. |
|
40 |
* |
|
41 |
* Inherits Behavior class which contains all basic behavior |
|
42 |
* functionality. |
|
43 |
*/ |
|
44 |
class Priya_Behavior:Behavior |
|
45 |
{ |
|
46 |
|
|
47 |
/** |
|
48 |
* @brief Main. The main function for the behavior. |
|
49 |
* |
|
50 |
* Defined in Behavior class as a virtual. Must be |
|
51 |
* implemented in functional behaviors. |
|
52 |
*/ |
|
53 |
int main(int argc, char **argv) |
|
54 |
{ |
|
55 |
init(argc, argv); |
|
56 |
while(ok()) |
|
57 |
{ |
|
58 |
motors.set_sides(20, 80, MOTOR_ABSOLUTE); |
|
59 |
|
|
60 |
spinOnce(); |
|
61 |
loop_rate.sleep(); |
|
62 |
} |
|
63 |
|
|
64 |
return 0; |
|
65 |
} |
|
66 |
}; |
scout/libscout/src/priya_behavior_process.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 |
/** |
|
27 |
* @file Behavior.cpp |
|
28 |
* @brief A wrapper that executes PriyaBehavior as an executable. |
|
29 |
* |
|
30 |
* Should be auto-generated in the future. |
|
31 |
* |
|
32 |
* @author Colony Project, CMU Robotics Club |
|
33 |
* @author Alex Zirbel |
|
34 |
**/ |
|
35 |
|
|
36 |
|
|
37 |
#include <ros/ros.h> |
|
38 |
#include "PriyaBehavior.h" |
|
39 |
|
|
40 |
using namespace std; |
|
41 |
|
|
42 |
int main (int argc, char **argv) |
|
43 |
{ |
|
44 |
if (argc != 2) |
|
45 |
{ |
|
46 |
cout << "Usage: " << argv[0] << " <scoutname>" << endl; |
|
47 |
exit(1); |
|
48 |
} |
|
49 |
|
|
50 |
ros::init(argc, argv, "libscout"); |
|
51 |
|
|
52 |
PriyaBehavior *behavior = new PriyaBehavior(argv[1]); |
|
53 |
behavior->run(); |
|
54 |
} |
scout/scoutsim/srv/TeleportAbsolute.srv | ||
---|---|---|
1 |
float32 x |
|
2 |
float32 y |
|
3 |
float32 theta |
|
4 |
--- |
scout/scoutsim/srv/TeleportRelative.srv | ||
---|---|---|
1 |
float32 linear |
|
2 |
float32 angular |
|
3 |
--- |
Also available in: Unified diff