Project

General

Profile

Revision c492be62

IDc492be629f06e3cf71fdf832ce2cd5ac1ec779f8
Parent cc558a8d
Child b00761a0

Added by Alex Zirbel over 12 years ago

Updated the licensing information in many files.

This is a broken commit because I decided to do this at a bad time. Sorry! The build will be working after next commit, I promise (and I won't push till then). This commit reflects the licensing in the files after I used my auto-add/remove script.

View differences:

scout/analog/src/analog.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file analog.cpp
scout/analog/src/analog.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file analog.h
scout/bom/src/bom.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file bom.cpp
scout/bom/src/bom.h
1 1
/**
2
 * Copyright (c) 2007 Colony Project
2
 * Copyright (c) 2011 Colony Project
3 3
 * 
4 4
 * Permission is hereby granted, free of charge, to any person
5 5
 * obtaining a copy of this software and associated documentation
......
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25

  
25 26
/**
26 27
 * @file bom.h
27 28
 * @brief Contains bom declarations and functions.
scout/buttons/src/buttons.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file buttons.cpp
scout/buttons/src/buttons.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file buttons.h
scout/cliffsensor/src/cliffsensor.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file cliffsensor.cpp
scout/cliffsensor/src/cliffsensor.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file cliffsensor.h
scout/encoders/src/encoders.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26

  
27 27
/**
scout/encoders/src/encoders.h
1 1
/**
2
 *Copyright (c) 2011 Colony Project
2
 * Copyright (c) 2011 Colony Project
3 3
 * 
4 4
 * Permission is hereby granted, free of charge, to any person
5 5
 * obtaining a copy of this software and associated documentation
......
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
24
 */
26 25

  
27 26
/**
28 27
 * @file encoders.h
scout/headlights/src/headlights.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file headlights.cpp
scout/headlights/src/headlights.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file headlights.h
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(priya_behavior src/priya_behavior_process.cpp src/PriyaBehavior.cpp src/Behavior.cpp src/MotorControl.cpp src/HeadlightControl.cpp)
32
rosbuild_add_executable(priya_behavior src/priya_behavior_process.cpp src/PriyaBehavior.cpp src/Behavior.cpp src/MotorControl.cpp src/HeadlightControl.cpp src/ButtonControl.cpp)
scout/libscout/src/Behavior.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file Behavior.cpp
28
 * @brief Contains basic functions for the structure of all behaviours.
28
 * @brief Contains basic functions for the structure of all behaviors.
29 29
 * 
30 30
 * Contains function implementations needed for all behavior.
31 31
 *
......
38 38

  
39 39
using namespace std;
40 40

  
41
/**
42
 * Constructs a behavior and sets up all control classes.
43
 *
44
 * This constructor is used by all behaviors which inherit the Behavior
45
 * class, so that it is easy to create a behavior with access to ROS
46
 * functionality through the control classes.
47
 *
48
 * @param scoutname If nonempty, specifies which scout in the simulator
49
 *                  will be controlled by this behavior.
50
 */
41 51
Behavior::Behavior(string scoutname)
42 52
{
43 53
    motors = new MotorControl(node, scoutname);
54
    buttons = new ButtonControl(node, scoutname);
55
    sonar = new SonarControl(node, scoutname);
56

  
44 57
    loop_rate = new ros::Rate(10);
45
    //buttons(node);
46
    //sonar(node);
47 58
}
48 59

  
60
/**
61
 * Allows the behavior to check ros::ok(), without being aware of ROS.
62
 */
49 63
bool Behavior::ok()
50 64
{
51 65
    return ros::ok();
52 66
}
53 67

  
68
/**
69
 * Allows the behavior to call ros::spin(), without being aware of ROS.
70
 */
54 71
void Behavior::spin()
55 72
{
56 73
    ros::spin();
57 74
    return;
58 75
}
59 76

  
77
/**
78
 * Allows the behavior to call ros::spinOnce(), without being aware of ROS.
79
 */
60 80
void Behavior::spinOnce()
61 81
{
62 82
    ros::spinOnce();
scout/libscout/src/Behavior.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file Behavior.h
......
41 41

  
42 42
#include "MotorControl.h"
43 43
#include "HeadlightControl.h"
44
#include "ButtonControl.h"
44 45
#include "SonarControl.h"
45 46
#include "constants.h"
46 47

  
......
50 51
        // Initializes ROS for behavior
51 52
        Behavior(std::string scoutname);
52 53

  
53
        // User implemented behavior
54
        /// Extended by subclasses to actually run the behavior.
54 55
        virtual void run() = 0;
55 56

  
56 57
    protected:
57 58
        ros::NodeHandle node;
59

  
60
        /// @todo Should this really be a pointer, or the object itself somehow?
58 61
        ros::Rate *loop_rate;
59 62

  
60 63
        // Declare all used library controls
61 64
        MotorControl * motors;
62
        //ButtonControl buttons;
63
        //SonarControl sonar;
65
        ButtonControl * buttons;
66
        SonarControl * sonar;
64 67

  
65 68
        // Wrappers for ROS functions
66 69
        bool ok();
scout/libscout/src/ButtonControl.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26

  
27 27
/**
scout/libscout/src/ButtonControl.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26

  
27 27
/**
scout/libscout/src/MotorControl.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file MotorControl.cpp
scout/libscout/src/MotorControl.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file MotorControl.h
scout/libscout/src/PriyaBehavior.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file PriyaBehavior.h
......
46 46
class PriyaBehavior : Behavior
47 47
{
48 48
    public:
49
        /// @todo Is this the best way to inherit the Behavior constructor?
50
        PriyaBehavior(std::string scoutname) : Behavior(scoutname) {};
49 51

  
50
        PriyaBehavior(std::string scoutname) : Behavior(scoutname) {}
51
        /**
52
         * @brief Runs the behavior.
53
         */
52
        /** Actually executes the behavior. */
54 53
        void run();
55 54
};
56 55

  
scout/libscout/src/SonarControl.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file SonarControl.cpp
28
 * @brief Contains sonar function imeplementations
28
 * @brief Contains sonar function implementation
29 29
 * 
30 30
 * Contains functions for the use of sonar control.
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 "SonarControl.h"
37 38

  
39
using namespace std;
40

  
38 41
/**
39 42
 * @brief Initialize the sonar module of libscout.
40 43
 *
41 44
 * Initialize the libscout node as a publisher of sonar_set_scan and 
42 45
 * sonar_toggle and a client of query_sonar.
43 46
 */
44
SonarControl::SonarControl(const ros::NodeHandle& libscout_node)
47
SonarControl::SonarControl(const ros::NodeHandle& libscout_node,
48
                           string scoutname)
45 49
    : node(libscout_node)
46 50
{
47 51
    sonar_set_scan_pub =
48
        node.advertise<sonar::sonar_set_scan>("set_sonar_scan", QUEUE_SIZE);
52
        node.advertise<sonar::sonar_set_scan>(scoutname + "/set_sonar_scan",
53
                                              QUEUE_SIZE);
49 54
    sonar_toggle_pub = 
50
	node.advertise<sonar::sonar_toggle>("toggle_sonar", QUEUE_SIZE);
51
    query_sonar =
52
        node.serviceClient<sonar::sonar_direction>("query_sonar");
55
        node.advertise<sonar::sonar_toggle>(scoutname + "/toggle_sonar",
56
                                            QUEUE_SIZE);
57
    sonar_distance_sub = node.subscribe(scoutname + "sonar_distance",
58
                                        QUEUE_SIZE, distance_callback);
59

  
60
    // Initialize all the sonar readings to 0 and timestamps to undefined
61
    for (int i = 0; i < 48; i++)
62
    {
63
        readings[i] = 0;
64
        timestamps[i] = ros::Time::now(); // A common shortcut for no reading
65
    }
66
}
67

  
68
/**
69
 * Update the array of sonar values, and the last read timestamps,
70
 * to reflect the new reading received.
71
 */
72
void SonarControl::distance_callback(const sonar::sonar_distance::ConstPtr& msg)
73
{
74
    // Error checking so that the array doesn't cause a segfault
75
    if (msg->pos < 0 || msg-> pos > 23)
76
    {
77
        ROS_ERROR("SonarControl received an invalid sonar position.");
78
        return;
79
    }
80

  
81
    readings[msg->pos] = msg->distance0;
82
    readings[msg->pos + 24] = msg->distance1;
83
    timestamps[msg->pos] = msg->header.stamp;
84
    timestamps[msg->pos + 24] = msg->header.stamp;
53 85
}
54 86

  
55 87
/**
......
57 89
 *
58 90
 * @param position Value between 0-180 of degree position to set sonar
59 91
 * @return NONE
92
 * @todo should return bool. See below.
60 93
 */
61
void SonarControl::set(int position)
94
void SonarControl::set_single(int position)
62 95
{
63 96
    set_range(position, position);
64 97
}
......
69 102
 * @param start_pos The leftmost (smallest) value that the sonar can take
70 103
 * @param end_pos The rightmost (largest) value that the sonar can take
71 104
 * @return NONE
105
 * @todo Also misimplemented, should return bool. Look at srv def in sonar/
72 106
 */
73 107
void SonarControl::set_range(int start_pos, int end_pos)
74 108
{
75
    /** Turn sonar on */
109
    // Check that the range is valid
110
    if (start_pos < 0 || end_pos < 0 || start_pos > 23 || end_pos > 23)
111
    {
112
        ROS_ERROR("Commanded SonarControl::set_range to a bad value.");
113
        return;
114
    }
115

  
116
    // Sort the start and end positions into increasing order
117
    if (start_pos > end_pos)
118
    {
119
        int temp = start_pos;
120
        start_pos = end_pos;
121
        end_pos = temp;
122
    }
123

  
124
    // Turn sonar on
76 125
    sonar::sonar_toggle on_msg;
77 126
    on_msg.set_on = true;
78 127
    sonar_toggle_pub.publish(on_msg);
79 128

  
80
    /** Set scan range */
129
    // Set scan range
81 130
    sonar::sonar_set_scan msg;
82

  
83
    //TODO Enable some checks of start and end position
84 131
    msg.stop_l = start_pos;
85 132
    msg.stop_r = end_pos;
86 133

  
87 134
    sonar_set_scan_pub.publish(msg);
88
    ros::spinOnce();
135
    ros::spinOnce();  ///<! Sure? Does this belong here?
89 136
}
90 137

  
91 138
/**
92 139
 * @brief Turn off sonar readings
93 140
 *
94 141
 * Stops sonar from panning and taking readings.
142
 * @todo Misimplemented. Needs to use a service call and return the ack as bool
95 143
 *
96 144
 * @return NONE
97 145
 */
98 146
float SonarControl::set_off()
99 147
{
100
    /** Turn sonar off */
101 148
    sonar::sonar_toggle on_msg;
102 149
    on_msg.set_on = false;
103 150
    sonar_toggle_pub.publish(on_msg);
104 151
}
105
/**
106
 * @brief Query the current front sonar readings
107
 *
108
 * Sends a request to the query_sonar service which will reply with the
109
 *  current readings of the sonar.
110
 *
111
 * @TODO Change so we can get multiple sonar readings with one call
112
 *
113
 * @return The reading of the front sonar
114
 */
115
float SonarControl::query_front()
116
{
117
    sonar::sonar_direction srv;
118
    if(query_sonar.call(srv))
119
    {
120
        srv.response.distance0;
121
    }
122
    else
123
    {
124
        ROS_FATAL("Failed to call service query_motors");
125
    }
126

  
127
    return 0;
128
}
129

  
130
/**
131
 * @brief Query the current back sonar readings
132
 *
133
 * Sends a request to the query_sonar service which will reply with the
134
 *  current readings of the sonar.
135
 *
136
 * @TODO Change so we can get multiple sonar readings with one call
137
 *
138
 * @return The reading of the back sonar
139
 */
140
float SonarControl::query_back()
141
{
142
    sonar::sonar_direction srv;
143
    if(query_sonar.call(srv))
144
    {
145
        srv.response.distance1;
146
    }
147
    else
148
    {
149
        ROS_FATAL("Failed to call service query_motors");
150
    }
151

  
152
    return 0;
153
}
154 152

  
155 153
/**
156 154
 * @brief Converts value returne by sonar to physical distances.
......
158 156
 * @param sonar_value The returned value of the sonar
159 157
 * @return The physical distance measured by the sonar.
160 158
 **/
161
float sonar_to_dist(float sonar_value)
162
{
159
//float sonar_to_dist(float sonar_value)
160
//{
163 161
    //TODO impelement later based on sonar readings
164
    return sonar_value;
165
}
162
//    return sonar_value;
163
//}
166 164

  
167 165
/**
168 166
 * @brief Converts values from physical distances to values read by sonar
......
170 168
 * @param distance The physical distance as measured.
171 169
 * @return The value read by the sonar that corresponds to the given distance
172 170
 **/
173
float dist_to_sonar(float distance)
174
{
171
//float dist_to_sonar(float distance)
172
//{
175 173
    //TODO implement later based on sonar readings
176
    return distance;
177
}
174
//    return distance;
175
//}
scout/libscout/src/SonarControl.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file SonarControl.h
......
46 46
{
47 47
    public:
48 48
        /** Set up the motor node and prepare to communicate over ROS */
49
        SonarControl(const ros::NodeHandle& libscout_node);
49
        SonarControl(const ros::NodeHandle& libscout_node,
50
                     std::string scoutname);
50 51

  
51 52
        /** Sets sonar to a position (0-180 deg) specified by input */
52
        void set(int position);
53
        void set_single(int position);
53 54

  
54 55
        /** Sets sonar to scan a range in 0-180 specified by input */
55 56
        void set_range(int start_pos, int end_pos);
56 57

  
57
	/** Stops sonar from panning and taking readings */
58
	void set_off();	
59

  
60
        /** Returns the distance readings of sonars */
61
        float query_front(void);
62
        float query_back(void);
58
        /** Stops sonar from panning and taking readings */
59
        void set_off();	
63 60
    
64 61
    private:
65
        /** Converts between values output by sensor and physical distances */
66
        float sonar_to_dist(float sonar_value);
67
        float dist_to_sonar(float distance);
62
        /** Record the new sonar distance measurement */
63
        void distance_callback(const sonar::sonar_distance::ConstPtr& msg);
68 64

  
69
        /* Front and back distance values read by sonar. */
70
        float front_dist;
71
        float back_dist;
65
        /** Converts between values output by sensor and physical distances */
66
        //float sonar_to_dist(float sonar_value);
67
        //float dist_to_sonar(float distance);
72 68

  
73
        /** ROS publisher and client declaration */
69
        /* ROS publisher and client declaration */
74 70
        ros::Publisher sonar_set_scan_pub;
75 71
        ros::Publisher sonar_toggle_pub;
76
        ros::ServiceClient query_sonar;
72
        ros::Subscriber sonar_distance_sub;
77 73

  
78 74
        ros::NodeHandle node;
79 75
};
scout/libscout/src/constants.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file constants.h
scout/libscout/src/priya_behavior_process.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file Behavior.cpp
......
58 58

  
59 59
    PriyaBehavior *behavior = new PriyaBehavior(scoutname);
60 60
    behavior->run();
61

  
62
    return 0;
61 63
}
scout/motors/src/motors.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file motors.cpp
scout/motors/src/motors.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file motors.h
scout/power/src/power.cpp
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file power.cpp
scout/power/src/power.h
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
24
 */
25 25

  
26 26
/**
27 27
 * @file motors.h
scout/scoutsim/licensing.txt
1
The code in this package was developed using the structure of Willow
2
Garage's turtlesim package.  It was modified by the CMU Robotics Club
3
to be used as a simulator for the Colony Scout robot.
4

  
5
All redistribution of this code is limited to the terms of Willow Garage's
6
licensing terms, as well as under permission from the CMU Robotics Club.
7

  
8
Please see both licensing agreements below.
9

  
10
******************************************************************************
11
** BELOW IS THE LICENSING AGREEMENT FROM WILLOW GARAGE                      **
12
******************************************************************************
13

  
14
Copyright (c) 2009, Willow Garage, Inc.
15
All rights reserved.
16

  
17
Redistribution and use in source and binary forms, with or without
18
modification, are permitted provided that the following conditions are met:
19

  
20
   Redistributions of source code must retain the above copyright
21
      notice, this list of conditions and the following disclaimer.
22
   Redistributions in binary form must reproduce the above copyright
23
      notice, this list of conditions and the following disclaimer in the
24
      documentation and/or other materials provided with the distribution.
25
   Neither the name of the Willow Garage, Inc. nor the names of its
26
      contributors may be used to endorse or promote products derived from
27
      this software without specific prior written permission.
28

  
29
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
33
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39
POSSIBILITY OF SUCH DAMAGE.
40

  
41

  
42
******************************************************************************
43
** BELOW IS THE LICENSING AGREEMENT FROM THE COLONY PROJECT                 **
44
******************************************************************************
45

  
46
Copyright (c) 2011 Colony Project
47

  
48
Permission is hereby granted, free of charge, to any person
49
obtaining a copy of this software and associated documentation
50
files (the "Software"), to deal in the Software without
51
restriction, including without limitation the rights to use,
52
copy, modify, merge, publish, distribute, sublicense, and/or sell
53
copies of the Software, and to permit persons to whom the
54
Software is furnished to do so, subject to the following
55
conditions:
56

  
57
The above copyright notice and this permission notice shall be
58
included in all copies or substantial portions of the Software.
59

  
60
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
61
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
62
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
64
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
65
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
66
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
67
OTHER DEALINGS IN THE SOFTWARE.
scout/scoutsim/src/scout.cpp
1
/*
2
 * This package was developed by the CMU Robotics Club project using code
3
 * from Willow Garage, Inc.  Please see licensing.txt for details.
1
/**
2
 * The code in this package was developed using the structure of Willow
3
 * Garage's turtlesim package.  It was modified by the CMU Robotics Club
4
 * to be used as a simulator for the Colony Scout robot.
4 5
 *
6
 * All redistribution of this code is limited to the terms of Willow Garage's
7
 * licensing terms, as well as under permission from the CMU Robotics Club.
8
 * 
9
 * Copyright (c) 2011 Colony Project
10
 * 
11
 * Permission is hereby granted, free of charge, to any person
12
 * obtaining a copy of this software and associated documentation
13
 * files (the "Software"), to deal in the Software without
14
 * restriction, including without limitation the rights to use,
15
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
16
 * copies of the Software, and to permit persons to whom the
17
 * Software is furnished to do so, subject to the following
18
 * conditions:
19
 * 
20
 * The above copyright notice and this permission notice shall be
21
 * included in all copies or substantial portions of the Software.
22
 * 
23
 * Copyright (c) 2009, Willow Garage, Inc.
5 24
 * All rights reserved.
6
 *
7
 * @brief Keeps track of a single scout robot.
8
 * @file scout.cpp
9
 * @author Colony Project, CMU Robotics Club
10
 * @author Alex Zirbel
25
 * 
26
 * Redistribution and use in source and binary forms, with or without
27
 * modification, are permitted provided that the following conditions are met:
28
 * 
29
 *    Redistributions of source code must retain the above copyright
30
 *       notice, this list of conditions and the following disclaimer.
31
 *    Redistributions in binary form must reproduce the above copyright
32
 *       notice, this list of conditions and the following disclaimer in the
33
 *       documentation and/or other materials provided with the distribution.
34
 *    Neither the name of the Willow Garage, Inc. nor the names of its
35
 *       contributors may be used to endorse or promote products derived from
36
 *       this software without specific prior written permission.
37
 * 
38
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
40
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
42
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
43
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
44
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45
 * OTHER DEALINGS IN THE SOFTWARE.
11 46
 */
12 47

  
13 48
#include "scout.h"
......
43 78
        set_pen_srv = node.advertiseService("set_pen",
44 79
                                            &Scout::setPenCallback,
45 80
                                            this);
46
        teleport_relative_srv =
47
            node.advertiseService("teleport_relative",
48
                                 &Scout::teleportRelativeCallback,
49
                                 this);
50
        teleport_absolute_srv =
51
            node.advertiseService("teleport_absolute",
52
                                 &Scout::teleportAbsoluteCallback,
53
                                 this);
54 81

  
55 82
        meter = scout.GetHeight();
56 83
    }
......
58 85
    /**
59 86
     * A callback function that sets velocity based on a set_motors
60 87
     * request.
88
     * @todo Use "callback" in all callback function names? Or remove?
61 89
     */
62 90
    void Scout::setMotors(const motors::set_motors::ConstPtr& msg)
63 91
    {
......
91 119
        ang_vel = SPEED_SCALE_FACTOR * (r_speed - l_speed);
92 120
    }
93 121

  
122
    float Scout::getSonar(float angle)
123
    {
124

  
125
        return 0.0;
126
    }
127

  
94 128
    bool Scout::setPenCallback(scoutsim::SetPen::Request& req,
95 129
                               scoutsim::SetPen::Response&)
96 130
    {
......
110 144
        return true;
111 145
    }
112 146

  
113
    /// @TODO remove
114
    bool Scout::teleportRelativeCallback(scoutsim::TeleportRelative::Request& req,
115
                                         scoutsim::TeleportRelative::Response&)
116
    {
117
        teleport_requests.push_back(TeleportRequest(0,
118
                                                     0,
119
                                                     req.angular,
120
                                                     req.linear,
121
                                                     true));
122
        return true;
123
    }
124

  
125
    /// @TODO remove
126
    bool Scout::teleportAbsoluteCallback(scoutsim::TeleportAbsolute::Request& req,
127
                                         scoutsim::TeleportAbsolute::Response&)
128
    {
129
        teleport_requests.push_back(TeleportRequest(req.x,
130
                                                     req.y,
131
                                                     req.theta,
132
                                                     0,
133
                                                     false));
134
        return true;
135
    }
136

  
137 147
    void Scout::update(double dt, wxMemoryDC& path_dc,
138 148
                        const wxImage& path_image, wxColour background_color,
139 149
                        float canvas_width, float canvas_height)
140 150
    {
141
        // first process any teleportation requests, in order
142
        V_TeleportRequest::iterator it = teleport_requests.begin();
143
        V_TeleportRequest::iterator end = teleport_requests.end();
144
        for (; it != end; ++it)
145
        {
146
            const TeleportRequest& req = *it;
147

  
148
            Vector2 old_pos = pos;
149
            if (req.relative)
150
            {
151
                orient += req.theta;
152
                pos.x += sin(orient + PI/2.0) * req.linear;
153
                pos.y += cos(orient + PI/2.0) * req.linear;
154
            }
155
            else
156
            {
157
                pos.x = req.pos.x;
158
                pos.y = std::max(0.0f, canvas_height - req.pos.y);
159
                orient = req.theta;
160
            }
161

  
162
            path_dc.SetPen(pen);
163
            path_dc.DrawLine(pos.x * meter, pos.y * meter,
164
                             old_pos.x * meter, old_pos.y * meter);
165
        }
166

  
167
        teleport_requests.clear();
168

  
169
        if (ros::WallTime::now() - last_command_time > ros::WallDuration(1.0))
170
        {
171
            lin_vel = 0.0f;
172
            ang_vel = 0.0f;
173
        }
174

  
175 151
        Vector2 old_pos = pos;
176 152

  
177 153
        orient = fmod(orient + ang_vel * dt, 2*PI);
scout/scoutsim/src/scout.h
1
/*
2
 * This package was developed by the CMU Robotics Club project using code
3
 * from Willow Garage, Inc.  Please see licensing.txt for details.
1
/**
2
 * The code in this package was developed using the structure of Willow
3
 * Garage's turtlesim package.  It was modified by the CMU Robotics Club
4
 * to be used as a simulator for the Colony Scout robot.
4 5
 *
6
 * All redistribution of this code is limited to the terms of Willow Garage's
7
 * licensing terms, as well as under permission from the CMU Robotics Club.
8
 * 
9
 * Copyright (c) 2011 Colony Project
10
 * 
11
 * Permission is hereby granted, free of charge, to any person
12
 * obtaining a copy of this software and associated documentation
13
 * files (the "Software"), to deal in the Software without
14
 * restriction, including without limitation the rights to use,
15
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
16
 * copies of the Software, and to permit persons to whom the
17
 * Software is furnished to do so, subject to the following
18
 * conditions:
19
 * 
20
 * The above copyright notice and this permission notice shall be
21
 * included in all copies or substantial portions of the Software.
22
 * 
23
 * Copyright (c) 2009, Willow Garage, Inc.
5 24
 * All rights reserved.
6
 *
7
 * @file scout.h
8
 * @author Colony Project, CMU Robotics Club
9
 * @author Alex Zirbel
25
 * 
26
 * Redistribution and use in source and binary forms, with or without
27
 * modification, are permitted provided that the following conditions are met:
28
 * 
29
 *    Redistributions of source code must retain the above copyright
30
 *       notice, this list of conditions and the following disclaimer.
31
 *    Redistributions in binary form must reproduce the above copyright
32
 *       notice, this list of conditions and the following disclaimer in the
33
 *       documentation and/or other materials provided with the distribution.
34
 *    Neither the name of the Willow Garage, Inc. nor the names of its
35
 *       contributors may be used to endorse or promote products derived from
36
 *       this software without specific prior written permission.
37
 * 
38
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
40
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
42
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
43
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
44
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45
 * OTHER DEALINGS IN THE SOFTWARE.
10 46
 */
11 47

  
12 48
#ifndef _SCOUTSIM_SCOUT_H_
......
19 55

  
20 56
#include <scoutsim/Pose.h>
21 57
#include <scoutsim/SetPen.h>
22
#include <scoutsim/TeleportRelative.h>
23
#include <scoutsim/TeleportAbsolute.h>
24 58
#include <scoutsim/Color.h>
25 59

  
26 60
#include <wx/wx.h>
27 61

  
62
#include "scout_constants.h"
63

  
28 64
#define PI 3.14159265
65

  
29 66
/// The scale factor so the speed of scout robots is reasonable for the sim
30 67
#define SPEED_SCALE_FACTOR 0.05
31 68

  
......
70 107

  
71 108
        private:
72 109
            void setMotors(const motors::set_motors::ConstPtr& msg);
110
            float getSonar(float angle);
73 111
            bool setPenCallback(scoutsim::SetPen::Request&,
74 112
                                scoutsim::SetPen::Response&);
75
            bool teleportRelativeCallback(scoutsim::TeleportRelative::Request&,
76
                                          scoutsim::TeleportRelative::Response&);
77
            bool teleportAbsoluteCallback(scoutsim::TeleportAbsolute::Request&,
78
                                          scoutsim::TeleportAbsolute::Response&);
79 113

  
80 114
            ros::NodeHandle node;
81 115

  
......
91 125
            int motor_bl_speed;
92 126
            int motor_br_speed;
93 127

  
128
            // Each scout has a unique id number, which is also displayed on its image.
129
            int scout_id;
130

  
94 131
            float lin_vel;
95 132
            float ang_vel;
96 133
            bool pen_on;
......
100 137
            ros::Publisher pose_pub;
101 138
            ros::Publisher color_pub;
102 139
            ros::ServiceServer set_pen_srv;
103
            ros::ServiceServer teleport_relative_srv;
104
            ros::ServiceServer teleport_absolute_srv;
105 140

  
106 141
            ros::WallTime last_command_time;
107 142

  
108 143
            float meter;
109 144

  
110
            struct TeleportRequest
111
            {
112
                TeleportRequest(float x, float y, float new_theta,
113
                                float new_linear, bool new_relative)
114
                    : pos(x, y)
115
                      , theta(new_theta)
116
                      , linear(new_linear)
117
                      , relative(new_relative)
118
                {}
119

  
120
                Vector2 pos;
121
                float theta;
122
                float linear;
123
                bool relative;
124
            };
125

  
126
            typedef std::vector<TeleportRequest> V_TeleportRequest;
127
            V_TeleportRequest teleport_requests;
128 145
    };
129 146
    typedef boost::shared_ptr<Scout> ScoutPtr;
130 147

  
131
}
148

  
132 149

  
133 150
#endif
scout/scoutsim/src/scoutsim.cpp
1
/*
2
 * This package was developed by the CMU Robotics Club project using code
3
 * from Willow Garage, Inc.  Please see licensing.txt for details.
1
/**
2
 * The code in this package was developed using the structure of Willow
3
 * Garage's turtlesim package.  It was modified by the CMU Robotics Club
4
 * to be used as a simulator for the Colony Scout robot.
4 5
 *
6
 * All redistribution of this code is limited to the terms of Willow Garage's
7
 * licensing terms, as well as under permission from the CMU Robotics Club.
8
 * 
9
 * Copyright (c) 2011 Colony Project
10
 * 
11
 * Permission is hereby granted, free of charge, to any person
12
 * obtaining a copy of this software and associated documentation
13
 * files (the "Software"), to deal in the Software without
14
 * restriction, including without limitation the rights to use,
15
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
16
 * copies of the Software, and to permit persons to whom the
17
 * Software is furnished to do so, subject to the following
18
 * conditions:
19
 * 
20
 * The above copyright notice and this permission notice shall be
21
 * included in all copies or substantial portions of the Software.
22
 * 
23
 * Copyright (c) 2009, Willow Garage, Inc.
5 24
 * All rights reserved.
6
 *
7
 * @brief Runs the simulator, keeping track of all the scout robots.
8
 * @file scoutsim.cpp
9
 * @author Colony Project, CMU Robotics Club
10
 * @author Alex Zirbel
25
 * 
26
 * Redistribution and use in source and binary forms, with or without
27
 * modification, are permitted provided that the following conditions are met:
28
 * 
29
 *    Redistributions of source code must retain the above copyright
30
 *       notice, this list of conditions and the following disclaimer.
31
 *    Redistributions in binary form must reproduce the above copyright
32
 *       notice, this list of conditions and the following disclaimer in the
33
 *       documentation and/or other materials provided with the distribution.
34
 *    Neither the name of the Willow Garage, Inc. nor the names of its
35
 *       contributors may be used to endorse or promote products derived from
36
 *       this software without specific prior written permission.
37
 * 
38
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
40
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
42
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
43
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
44
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45
 * OTHER DEALINGS IN THE SOFTWARE.
11 46
 */
12 47

  
13 48
#include <wx/app.h>
......
25 60

  
26 61
class ScoutApp : public wxApp
27 62
{
28
public:
29
  char** local_argv;
30
  ros::NodeHandlePtr nh;
63
    public:
64
        char** local_argv;
65
        ros::NodeHandlePtr nh;
31 66

  
32
  ScoutApp()
33
  {
34
  }
67
        ScoutApp()
68
        {
69
        }
35 70

  
36
  bool OnInit()
37
  {
71
        bool OnInit()
72
        {
38 73
#ifdef __WXMAC__
39
    ProcessSerialNumber PSN;
40
    GetCurrentProcess(&PSN);
41
    TransformProcessType(&PSN,kProcessTransformToForegroundApplication);
42
    SetFrontProcess(&PSN);
74
            ProcessSerialNumber PSN;
75
            GetCurrentProcess(&PSN);
76
            TransformProcessType(&PSN,kProcessTransformToForegroundApplication);
77
            SetFrontProcess(&PSN);
43 78
#endif
44 79

  
45
    // create our own copy of argv, with regular char*s.
46
    local_argv =  new char*[ argc ];
47
    for ( int i = 0; i < argc; ++i )
48
    {
49
      local_argv[ i ] = strdup( wxString( argv[ i ] ).mb_str() );
50
    }
80
            // Create our own copy of argv, with regular char*s.
81
            local_argv = new char*[ argc ];
82
            for ( int i = 0; i < argc; ++i )
83
            {
84
                local_argv[ i ] = strdup( wxString( argv[ i ] ).mb_str() );
85
            }
51 86

  
52
    ros::init(argc, local_argv, "scoutsim");
53
    nh.reset(new ros::NodeHandle);
87
            ros::init(argc, local_argv, "scoutsim");
88
            nh.reset(new ros::NodeHandle);
54 89

  
55
    wxInitAllImageHandlers();
90
            wxInitAllImageHandlers();
56 91

  
57
    scoutsim::SimFrame* frame = new scoutsim::SimFrame(NULL);
92
            scoutsim::SimFrame* frame = new scoutsim::SimFrame(NULL);
58 93

  
59
    SetTopWindow(frame);
60
    frame->Show();
94
            SetTopWindow(frame);
95
            frame->Show();
61 96

  
62
    return true;
63
  }
97
            return true;
98
        }
64 99

  
65
  int OnExit()
66
  {
67
    for ( int i = 0; i < argc; ++i )
68
    {
69
      free( local_argv[ i ] );
70
    }
71
    delete [] local_argv;
100
        int OnExit()
101
        {
102
            for ( int i = 0; i < argc; ++i )
103
            {
104
                free( local_argv[ i ] );
105
            }
106
            delete [] local_argv;
72 107

  
73
    return 0;
74
  }
108
            return 0;
109
        }
75 110
};
76 111

  
77 112
DECLARE_APP(ScoutApp);
78 113
IMPLEMENT_APP(ScoutApp);
79

  
scout/scoutsim/src/sim_frame.cpp
1
/*
2
 * This package was developed by the CMU Robotics Club project using code
3
 * from Willow Garage, Inc.  Please see licensing.txt for details.
1
/**
2
 * The code in this package was developed using the structure of Willow
3
 * Garage's turtlesim package.  It was modified by the CMU Robotics Club
4
 * to be used as a simulator for the Colony Scout robot.
4 5
 *
6
 * All redistribution of this code is limited to the terms of Willow Garage's
7
 * licensing terms, as well as under permission from the CMU Robotics Club.
8
 * 
9
 * Copyright (c) 2011 Colony Project
10
 * 
11
 * Permission is hereby granted, free of charge, to any person
12
 * obtaining a copy of this software and associated documentation
13
 * files (the "Software"), to deal in the Software without
14
 * restriction, including without limitation the rights to use,
15
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
16
 * copies of the Software, and to permit persons to whom the
17
 * Software is furnished to do so, subject to the following
18
 * conditions:
19
 * 
20
 * The above copyright notice and this permission notice shall be
21
 * included in all copies or substantial portions of the Software.
22
 * 
23
 * Copyright (c) 2009, Willow Garage, Inc.
5 24
 * All rights reserved.
6
 *
7
 * @brief Keeps track of the frame (visualization of the whole environment).
8
 * @file sim_frame.cpp
9
 * @author Colony Project, CMU Robotics Club
10
 * @author Alex Zirbel
25
 * 
26
 * Redistribution and use in source and binary forms, with or without
27
 * modification, are permitted provided that the following conditions are met:
28
 * 
29
 *    Redistributions of source code must retain the above copyright
30
 *       notice, this list of conditions and the following disclaimer.
31
 *    Redistributions in binary form must reproduce the above copyright
32
 *       notice, this list of conditions and the following disclaimer in the
33
 *       documentation and/or other materials provided with the distribution.
34
 *    Neither the name of the Willow Garage, Inc. nor the names of its
35
 *       contributors may be used to endorse or promote products derived from
36
 *       this software without specific prior written permission.
37
 * 
38
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
40
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
42
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
43
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
44
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45
 * OTHER DEALINGS IN THE SOFTWARE.
11 46
 */
12 47

  
13 48
#include "sim_frame.h"
......
216 251
                               width_in_meters, height_in_meters);
217 252
        }
218 253

  
219
        ++frame_count;
254
        frame_count++;
220 255
    }
221 256

  
222

  
223 257
    bool SimFrame::clearCallback(std_srvs::Empty::Request&,
224 258
                                 std_srvs::Empty::Response&)
225 259
    {
scout/scoutsim/src/sim_frame.h
1
/*
2
 * This package was developed by the CMU Robotics Club project using code
3
 * from Willow Garage, Inc.  Please see licensing.txt for details.
1
/**
2
 * The code in this package was developed using the structure of Willow
3
 * Garage's turtlesim package.  It was modified by the CMU Robotics Club
4
 * to be used as a simulator for the Colony Scout robot.
4 5
 *
6
 * All redistribution of this code is limited to the terms of Willow Garage's
7
 * licensing terms, as well as under permission from the CMU Robotics Club.
8
 * 
9
 * Copyright (c) 2011 Colony Project
10
 * 
11
 * Permission is hereby granted, free of charge, to any person
12
 * obtaining a copy of this software and associated documentation
13
 * files (the "Software"), to deal in the Software without
14
 * restriction, including without limitation the rights to use,
15
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
16
 * copies of the Software, and to permit persons to whom the
17
 * Software is furnished to do so, subject to the following
18
 * conditions:
19
 * 
20
 * The above copyright notice and this permission notice shall be
21
 * included in all copies or substantial portions of the Software.
22
 * 
23
 * Copyright (c) 2009, Willow Garage, Inc.
5 24
 * All rights reserved.
6
 *
7
 * @file sim_frame.h
8
 * @author Colony Project, CMU Robotics Club
9
 * @author Alex Zirbel
25
 * 
26
 * Redistribution and use in source and binary forms, with or without
27
 * modification, are permitted provided that the following conditions are met:
28
 * 
29
 *    Redistributions of source code must retain the above copyright
30
 *       notice, this list of conditions and the following disclaimer.
31
 *    Redistributions in binary form must reproduce the above copyright
32
 *       notice, this list of conditions and the following disclaimer in the
33
 *       documentation and/or other materials provided with the distribution.
34
 *    Neither the name of the Willow Garage, Inc. nor the names of its
35
 *       contributors may be used to endorse or promote products derived from
36
 *       this software without specific prior written permission.
37
 * 
38
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
40
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
42
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
43
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
44
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45
 * OTHER DEALINGS IN THE SOFTWARE.
10 46
 */
11 47

  
12 48
#include <wx/wx.h>
scout/sonar/msg/sonar_direction.msg
1
# Gives a timestamp so nodes make sure they use current readings
2
Header header
3

  
4
# Distance reading from the front sonar
5
int8 distance0
6
# Distance reading from the back sonar
7
int8 distnace1
scout/sonar/src/sonar.cpp
1 1
/**
2
 * Copyright (c) 2007 Colony Project
2
 * Copyright (c) 2011 Colony Project
3 3
 * 
4 4
 * Permission is hereby granted, free of charge, to any person
5 5
 * obtaining a copy of this software and associated documentation
......
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
24
 */
26 25

  
27 26
/**
28 27
 * @file sonar.cpp
......
34 33
 * @author Alex Zirbel
35 34
 **/
36 35

  
37
#include "scout/sonar.h"
38
#include "ros/ros.h"
36
#include <ros/ros.h>
39 37
#include <cstdlib>
40 38

  
39
#include "sonar.h"
40

  
41 41
/**
42 42
 * @defgroup sonar Sonar
43 43
 * @brief Functions for using the sonar
......
110 110
    is_on = true;
111 111

  
112 112
    /* Initialize hardware for sonar */
113
    //Hardware init functions here
113
    // Hardware init functions here
114 114
    sonar_init();
115 115

  
116 116
    /* Initialize the sonar driver node in ROS */
......
124 124
                                                    handle_sonar_set_scan);
125 125

  
126 126
    ROS_INFO("Sonar: Ready");
127
    // Sonar reading and publishing here
127 128
    ros::spin();
128 129

  
129 130
    return 0;
scout/sonar/src/sonar.h
1 1
/**
2
 * Copyright (c) 2007 Colony Project
2
 * Copyright (c) 2011 Colony Project
3 3
 * 
4 4
 * Permission is hereby granted, free of charge, to any person
5 5
 * obtaining a copy of this software and associated documentation
......
21 21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

  
24
 */
26 25

  
27 26
/**
28 27
 * @file sonar.h
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff