scoutos / scout / libscout / src / behavior.cpp @ a8480867
History | View | Annotate | Download (2.45 KB)
1 | 737bb380 | Ben Wasserman | /**
|
---|---|---|---|
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 | dec96050 | Priya | /* 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 | 737bb380 | Ben Wasserman | init(LIB_ALL, argc, argv); |
56 | dec96050 | Priya | |
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 | 737bb380 | Ben Wasserman | return 0; |
85 | dec96050 | Priya | } |