Revision 071926c2

View differences:

scout/analog/CMakeLists.txt
1
cmake_minimum_required(VERSION 2.4.6)
2
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
3

  
4
# Set the build type.  Options are:
5
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
6
#  Debug          : w/ debug symbols, w/o optimization
7
#  Release        : w/o debug symbols, w/ optimization
8
#  RelWithDebInfo : w/ debug symbols, w/ optimization
9
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
10
#set(ROS_BUILD_TYPE RelWithDebInfo)
11

  
12
rosbuild_init()
13

  
14
#set the default path for built executables to the "bin" directory
15
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
16
#set the default path for built libraries to the "lib" directory
17
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
18

  
19
#uncomment if you have defined messages
20
#rosbuild_genmsg()
21
#uncomment if you have defined services
22
rosbuild_gensrv()
23

  
24
#common commands for building c++ executables and libraries
25
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
26
#target_link_libraries(${PROJECT_NAME} another_library)
27
#rosbuild_add_boost_directories()
28
#rosbuild_link_boost(${PROJECT_NAME} thread)
29
#rosbuild_add_executable(example examples/example.cpp)
30
#target_link_libraries(example ${PROJECT_NAME})
31

  
32
rosbuild_add_executable(analog_node src/analog.cpp)
scout/analog/Makefile
1
include $(shell rospack find mk)/cmake.mk
scout/analog/mainpage.dox
1
/**
2
\mainpage
3
\htmlinclude manifest.html
4

  
5
\b analog is is the ros node that will read analog input from external devices connected to the Scout.
6

  
7
<!-- 
8
Analog will contain the functions necessary for reading analog input.
9
-->
10

  
11

  
12
\section codeapi Code API
13

  
14
<!--
15
Provide links to specific auto-generated API documentation within your
16
package that is of particular interest to a reader. Doxygen will
17
document pretty much every part of your code, so do your best here to
18
point the reader to the actual API.
19

  
20
If your codebase is fairly large or has different sets of APIs, you
21
should use the doxygen 'group' tag to keep these APIs together. For
22
example, the roscpp documentation has 'libros' group.
23
-->
24

  
25

  
26
*/
scout/analog/manifest.xml
1
<package>
2
  <description brief="analog">
3
     analog
4
     Module to read analog input.
5
  </description>
6
  <author>Dev</author>
7
  <license>BSD</license>
8
  <review status="unreviewed" notes=""/>
9
  <url>https://www.roboticsclub.org/redmine/projects/colonyscout/wiki</url>
10
  <depend package="roscpp"/>
11
  <depend package="std_msgs"/>
12

  
13
</package>
14

  
15

  
scout/analog/src/analog.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 analog.cpp
28
 * @brief Contains code to read analog data.
29
 *
30
 * Implementation of functions for analog use.
31
 *
32
 * @author Colony Project, CMU Robotics Club
33
 * @author Dev Gurjar
34
 **/
35

  
36
#include <ros/ros.h>
37

  
38
#include "analog.h"
39

  
40
/**
41
 * @defgroup analog Analog
42
 * @brief Functions for reading analog input
43
 *
44
 * @{
45
 **/
46

  
47
/* Analog state variables */
48
/** @todo Fix types: static */
49
unsigned int port; /**< The current port from which we are reading from. */
50

  
51
/**
52
 * @brief Outputs current analog data at a given port
53
 *
54
 * Serves the service query_analog by responding to service requests with the
55
 * speeds of the motors.
56
 * @param req The request. The only field is the units requested.
57
 * @param res The response. The fields will be filled with values.
58
 */
59
bool analog_query(analog::query_analog::Request &req,
60
                  analog::query_analog::Response &res)
61
{
62
    int port = req.port;
63
    res.sensor_data = get_sensor_data(port);
64

  
65
    ROS_DEBUG("Analog data queried");
66
    return true;
67
}
68

  
69
/* 
70
 * @brief 
71
 *
72
 * Given a port number, returns the analog data present at the port
73
 * 
74
 * @param port The port we want to read from
75
 */
76
unsigned int get_sensor_data(int port)
77
{
78
    ROS_DEBUG("Got Analog data from the sensor [Unimplemented]");
79
    return 0;
80
}
81

  
82
/**
83
 * @brief Analog driver. Provides an interface to read data from analog ports.
84
 */
85
int main(int argc, char **argv)
86
{
87
    /* Initialize in ROS the motors driver node */
88
    ros::init(argc, argv, "analog_driver");
89

  
90
    /* Advertise that this serves the query_analog service */
91
    ros::NodeHandle n;
92
    ros::ServiceServer service = n.advertiseService("query_analog",
93
                                                    analog_query);
94

  
95
    /* Initialize hardware for analog */
96

  
97
    // Hardware init functions here
98
    ros::spin();
99

  
100
    return 0;
101
}
102

  
103
/** @} **/
scout/analog/src/analog.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 analog.h
28
 * @brief Contains analog declarations and functions.
29
 * 
30
 * Contains functions and definitions for the use of
31
 * analog.
32
 *
33
 * @author Colony Project, CMU Robotics Club
34
 * @author Dev Gurjar
35
 **/
36

  
37
#ifndef _ANALOG_H_
38
#define _ANALOG_H_
39

  
40
#include "analog/query_analog.h"
41

  
42
/** @brief Analog port 0 **/
43
#define AN0 0x00
44
/** @brief Analog port 1 **/
45
#define AN1 0x01
46
/** @brief Analog port 2 **/
47
#define AN2 0x02
48
/** @brief Analog port 3 **/
49
#define AN3 0x03
50
/** @brief Analog port 4 **/
51
#define AN4 0x04
52
/** @brief Analog port 5 **/
53
#define AN5 0x05
54
/** @brief Analog port 6 **/
55
#define AN6 0x06
56
/** @brief Analog port 7 **/
57
#define AN7 0x07
58
/** @brief Analog port 8 **/
59
#define AN8 0x08
60
/** @brief Analog port 9 **/
61
#define AN9 0x09
62
/** @brief Analog port 10 **/
63
#define AN10 0x0A
64
/** @brief Analog port 11 **/
65
#define AN11 0x0B
66
/** @brief Analog port 12 **/
67
#define AN12 0x0C
68
/** @brief Analog port 13 **/
69
#define AN13 0x0D
70
/** @brief Analog port 14 **/
71
#define AN14 0x0E
72
/** @brief Analog port 15 **/
73
#define AN15 0x0F
74

  
75
/** @brief Struct to hold the value of a particular analog port **/
76
typedef struct
77
{
78
  uint8_t adc8;
79
  uint16_t adc10;
80
} adc_t;
81

  
82
/* The number of messages in the queue. If messages arrive faster than they are
83
 * handled, old ones are thrown out */
84
#define QUEUE_SIZE 10
85

  
86
/** @brief Initialize the analog module and driver. **/
87
int main(int argc, char **argv);
88

  
89
/** @brief given a port, returns the analog reading at that port **/
90
unsigned int get_sensor_data(int port);
91

  
92
/** @brief Responds to service to query analog input. **/
93
bool analog_query(analog::query_analog::Request &req,
94
                  analog::query_analog::Response &res);
95
#endif
scout/analog/srv/query_analog.srv
1
int8 port
2
---
3
int8 sensor_data
scout/bom/CMakeLists.txt
1
cmake_minimum_required(VERSION 2.4.6)
2
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
3

  
4
# Set the build type.  Options are:
5
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
6
#  Debug          : w/ debug symbols, w/o optimization
7
#  Release        : w/o debug symbols, w/ optimization
8
#  RelWithDebInfo : w/ debug symbols, w/ optimization
9
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
10
#set(ROS_BUILD_TYPE RelWithDebInfo)
11

  
12
rosbuild_init()
13

  
14
#set the default path for built executables to the "bin" directory
15
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
16
#set the default path for built libraries to the "lib" directory
17
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
18

  
19
#uncomment if you have defined messages
20
rosbuild_genmsg()
21
#uncomment if you have defined services
22
rosbuild_gensrv()
23

  
24
#common commands for building c++ executables and libraries
25
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
26
#target_link_libraries(${PROJECT_NAME} another_library)
27
#rosbuild_add_boost_directories()
28
#rosbuild_link_boost(${PROJECT_NAME} thread)
29
#rosbuild_add_executable(example examples/example.cpp)
30
#target_link_libraries(example ${PROJECT_NAME})
scout/bom/Makefile
1
include $(shell rospack find mk)/cmake.mk
scout/bom/mainpage.dox
1
/**
2
\mainpage
3
\htmlinclude manifest.html
4

  
5
\b bom is the ros node that will orient the robots toward each other and tell the direction that any sources of IR are coming from. It can also provide information relating to the orientation of the other robot and which robot it is.
6

  
7
<!-- 
8
Bom will contain the functions necessary for reading the values obtained by the bearing and orientation module. It will also provide commands for asking the module to get readings from specific robots.
9
-->
10

  
11

  
12
\section codeapi Code API
13

  
14
<!--
15
Provide links to specific auto-generated API documentation within your
16
package that is of particular interest to a reader. Doxygen will
17
document pretty much every part of your code, so do your best here to
18
point the reader to the actual API.
19

  
20
If your codebase is fairly large or has different sets of APIs, you
21
should use the doxygen 'group' tag to keep these APIs together. For
22
example, the roscpp documentation has 'libros' group.
23
-->
24

  
25

  
26
*/
scout/bom/manifest.xml
1
<package>
2
  <description brief="bom">
3
     Bearing and Orientation Module
4
     Module to to orient and direct the robots toward each other or
5
     other sources of IR.
6
  </description>
7
  <author>James</author>
8
  <license>BSD</license>
9
  <review status="unreviewed" notes=""/>
10
  <url>https://www.roboticsclub.org/redmine/projects/colonyscout/wiki</url>
11
  <depend package="roscpp"/>
12
  <depend package="std_msgs"/>
13

  
14
</package>
15

  
16

  
scout/bom/msg/bom.msg
1
int8 sender
2
int8 send_dir
3
int8 recv_dir
4

  
5
# TODO these may need to be changed
6
int8 FRONT = 0
7
int8 LEFT  = 1
8
int8 BACK  = 2
9
int8 RIGHT = 3
scout/cliffsensor/CMakeLists.txt
1
cmake_minimum_required(VERSION 2.4.6)
2
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
3

  
4
# Set the build type.  Options are:
5
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
6
#  Debug          : w/ debug symbols, w/o optimization
7
#  Release        : w/o debug symbols, w/ optimization
8
#  RelWithDebInfo : w/ debug symbols, w/ optimization
9
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
10
#set(ROS_BUILD_TYPE RelWithDebInfo)
11

  
12
rosbuild_init()
13

  
14
#set the default path for built executables to the "bin" directory
15
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
16
#set the default path for built libraries to the "lib" directory
17
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
18

  
19
#uncomment if you have defined messages
20
rosbuild_genmsg()
21
#uncomment if you have defined services
22
rosbuild_gensrv()
23

  
24
#common commands for building c++ executables and libraries
25
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
26
#target_link_libraries(${PROJECT_NAME} another_library)
27
#rosbuild_add_boost_directories()
28
#rosbuild_link_boost(${PROJECT_NAME} thread)
29
#rosbuild_add_executable(example examples/example.cpp)
30
#target_link_libraries(example ${PROJECT_NAME})
31

  
32
rosbuild_add_executable(cliffsensor_node src/cliffsensor.cpp)
scout/cliffsensor/Makefile
1
include $(shell rospack find mk)/cmake.mk
scout/cliffsensor/mainpage.dox
1
/**
2
\mainpage
3
\htmlinclude manifest.html
4

  
5
\b cliffsensor is the ros node that will read from the cliffsensors and detect cliffs and tell the motors to stop driving.
6

  
7
<!-- 
8
Cliffsensor will contain the functions necessary for reading from the cliffsensors and detecting cliffs (and behaviors associated with the cliffsensor).
9
-->
10

  
11

  
12
\section codeapi Code API
13

  
14
<!--
15
Provide links to specific auto-generated API documentation within your
16
package that is of particular interest to a reader. Doxygen will
17
document pretty much every part of your code, so do your best here to
18
point the reader to the actual API.
19

  
20
If your codebase is fairly large or has different sets of APIs, you
21
should use the doxygen 'group' tag to keep these APIs together. For
22
example, the roscpp documentation has 'libros' group.
23
-->
24

  
25

  
26
*/
scout/cliffsensor/manifest.xml
1
<package>
2
  <description brief="cliffsensor">
3
     cliffsensor
4
     Module to read from the cliffsensor, detect cliffs, and behaviors for cliffsensor.
5
  </description>
6
  <author>Priya</author>
7
  <license>BSD</license>
8
  <review status="unreviewed" notes=""/>
9
  <url>https://www.roboticsclub.org/redmine/projects/colonyscout/wiki</url>
10
  <depend package="roscpp"/>
11
  <depend package="std_msgs"/>
12

  
13
</package>
14

  
15

  
scout/cliffsensor/msg/cliff_status_changed.msg
1
int8 front_raw
2
int8 left_raw
3
int8 right_raw
4
int8 cliff_status
scout/cliffsensor/src/cliffsensor.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 cliffsensor.cpp
28
 * @brief Contains code to control the cliffsensor.
29
 *
30
 * Implementation of functions for cliffsensor use.
31
 *
32
 * @author Colony Project, CMU Robotics Club
33
 * @author Priyanka Deo
34
 **/
35

  
36
#include "ros/ros.h"
37
#include "cliffsensor.h"
38
#include <cstdlib>
39

  
40
/**
41
 * @defgroup cliffsensor Cliffsensor
42
 * @brief Functions for using the cliffsensors
43
 *
44
 * @{
45
 **/
46

  
47
/* Cliffsensor state variables
48
 */
49
static int front_raw; /**< The current raw value data of the front cliffsensor. */
50
static int left_raw; /**< The current raw value data of the left cliffsensor. */
51
static int back_raw; /**< The current raw value data of the right cliffsensor. */
52
static bool is_cliff; /**< Boolean to represent whether or not there is a cliff. */
53

  
54
/**
55
 * @brief Changes cliff sensor status
56
 *
57
 * Changes cliff sensor status based on subscription to topic cliff_status_changed
58
 *
59
 * @param msg The message from the cliff_status_changed topic, containing 
60
 * status of all cliff sensors.
61
 */
62
void changed_cliff_status(const cliffsensor::cliff_status_changed::ConstPtr& msg)
63
{
64
  return;
65
}
66

  
67
/**
68
 * @brief Outputs status of cliffsensors
69
 *
70
 * Serves the service query_cliff by responding to service requests with the
71
 * status of the cliff sensors.
72
 * @param req The request. The only field is the units requested.
73
 * @param res The response. The fields will be filled with values.
74
 */
75
bool cliff_query(cliffsensor::query_cliff::Request &req,
76
                  cliffsensor::query_cliff::Response &res)
77
{
78
    int threshold = 500; //TODO fix after figuring out what sensors give us
79
    res.front_raw = front_raw; 
80
    res.left_raw = left_raw;
81
    res.right_raw = back_raw;
82
    res.cliff_status = is_cliff;
83

  
84
    ROS_DEBUG("Cliffsensor status queried");
85
    return true;
86
}
87

  
88
/**
89
 * @brief Cliffsensor driver. This is a ROS node that controls cliffsensor status.
90
 *
91
 * This is the main function for the cliffsensors node. It is run when the node
92
 * starts and initializes the cliffsensors. It then subscribes to the
93
 * cliff_status_changed topics, and advertises the
94
 * query_cliff service.
95
 * 
96
 * @param argc The number of command line arguments (should be 1)
97
 * @param argv The array of command line arguments
98
 **/
99
int main(int argc, char **argv)
100
{
101
    /* Initialize in ROS the cliffsensor driver node */
102
    ros::init(argc, argv, "cliffsensor_driver");
103

  
104
    /* Advertise that this serves the query_cliff service */
105
    ros::NodeHandle n;
106
    ros::ServiceServer service = n.advertiseService("query_cliff",
107
                                                    cliff_query);
108

  
109
    /* Subscribe to the cliff_status_changed topic */
110
    ros::Subscriber sub0 = n.subscribe("cliff_status_changed", 
111
                                        4, changed_cliff_status);
112

  
113
    /* Initialize hardware for cliffsensors */
114
    // Hardware init functions here
115

  
116
    ROS_INFO("Ready to query cliffsensors.");
117
    ros::spin();
118

  
119
    return 0;
120
}
121

  
122
/** @} **/
scout/cliffsensor/src/cliffsensor.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 cliffsensor.h
28
 * @brief Contains cliffsensor declarations and functions.
29
 * 
30
 * Contains functions and definitions for the use of
31
 * cliffsensors.
32
 *
33
 * @author Colony Project, CMU Robotics Club
34
 * @author Priyanka Deo
35
 **/
36

  
37
#ifndef _CLIFFSENSOR_H_
38
#define _CLIFFSENSOR_H_
39

  
40
#include "cliffsensor/query_cliff.h"
41
#include "cliffsensor/cliff_status_changed.h"
42

  
43
#define CLIFF_DETECTED 0x0
44
#define NO_CLIFF 0x1
45

  
46
/** @brief Initialize the cliffsensor module and driver. **/
47
int main(int argc, char **argv);
48

  
49
/** @brief Responds to topic to change cliff sensor status. **/
50
void changed_cliff_status(const cliffsensor::cliff_status_changed::ConstPtr& msg);
51

  
52
/** @brief Responds to service to query cliffsensor data. **/
53
bool cliff_query(cliffsensor::query_cliff::Request &req,
54
                  cliffsensor::query_cliff::Response &res);
55

  
56
#endif
scout/cliffsensor/srv/query_cliff.srv
1
int8 units
2
---
3
int8 front_raw
4
int8 left_raw
5
int8 right_raw
6
int8 cliff_status
scout/headlights/CMakeLists.txt
1
cmake_minimum_required(VERSION 2.4.6)
2
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
3

  
4
# Set the build type.  Options are:
5
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
6
#  Debug          : w/ debug symbols, w/o optimization
7
#  Release        : w/o debug symbols, w/ optimization
8
#  RelWithDebInfo : w/ debug symbols, w/ optimization
9
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
10
#set(ROS_BUILD_TYPE RelWithDebInfo)
11

  
12
rosbuild_init()
13

  
14
#set the default path for built executables to the "bin" directory
15
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
16
#set the default path for built libraries to the "lib" directory
17
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
18

  
19
#uncomment if you have defined messages
20
rosbuild_genmsg()
21
#uncomment if you have defined services
22
#rosbuild_gensrv()
23

  
24
#common commands for building c++ executables and libraries
25
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
26
#target_link_libraries(${PROJECT_NAME} another_library)
27
#rosbuild_add_boost_directories()
28
#rosbuild_link_boost(${PROJECT_NAME} thread)
29
#rosbuild_add_executable(example examples/example.cpp)
30
#target_link_libraries(example ${PROJECT_NAME})
31

  
32
rosbuild_add_executable(headlights_node src/headlights.cpp)
scout/headlights/Makefile
1
include $(shell rospack find mk)/cmake.mk
scout/headlights/mainpage.dox
1
/**
2
\mainpage
3
\htmlinclude manifest.html
4

  
5
\b headlights is the ROS node that will control the multicolor headlights on scout
6

  
7
<!-- 
8
Headlights will contain the functions necessary for controling the headlights
9
-->
10

  
11

  
12
\section codeapi Code API
13

  
14
<!--
15
Provide links to specific auto-generated API documentation within your
16
package that is of particular interest to a reader. Doxygen will
17
document pretty much every part of your code, so do your best here to
18
point the reader to the actual API.
19

  
20
If your codebase is fairly large or has different sets of APIs, you
21
should use the doxygen 'group' tag to keep these APIs together. For
22
example, the roscpp documentation has 'libros' group.
23
-->
24

  
25

  
26
*/
scout/headlights/manifest.xml
1
<package>
2
  <description brief="headlights">
3
     motors
4
     Module to drive the headlights and provide all headlights functionality.
5
  </description>
6
  <author>Ben Wasserman</author>
7
  <license>BSD</license>
8
  <review status="unreviewed" notes=""/>
9
  <url>https://www.roboticsclub.org/redmine/projects/colonyscout/wiki</url>
10
  <depend package="roscpp"/>
11
  <depend package="std_msgs"/>
12

  
13
</package>
14

  
15

  
scout/headlights/msg/set_headlights.msg
1
int16 left_red
2
int16 left_green
3
int16 left_blue
4
int16 right_red
5
int16 right_green
6
int16 right_blue
scout/headlights/src/headlights.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 headlights.cpp
28
 * @brief Contains code to control the headlights.
29
 *
30
 * Implementation of functions for headlights use.
31
 *
32
 * @author Colony Project, CMU Robotics Club
33
 **/
34

  
35
#include "ros/ros.h"
36
#include "headlights.h"
37
//#include "libscout/src/constants.h"
38
#include <cstdlib>
39

  
40
/**
41
 * @defgroup headlights headlights
42
 * @brief Functions for using the headlights
43
 *
44
 * @{
45
 **/
46

  
47
/* Headlight state variables
48
 * Each color intensity is stored as a value out of the max bunary value that 
49
 * can be written to the output pins that control the LEDs.
50
 */
51
/** @todo Fix types: static */
52
struct headlight
53
{
54
	char red;
55
	char green;
56
	char blue;
57
};
58
headlight left, right;
59

  
60
/**
61
 * @brief Sets headlight colors
62
 *
63
 * Sets the headlight colors based on subscription to the set_headlights topic.
64
 *
65
 * @param msg The message from the set_headlights topic, containing colors.
66
 */
67
void headlights_set(const headlights::set_headlights::ConstPtr& msg)
68
{
69
		/* Set state variables from message */
70
		if(msg->left_red > NO_SET)
71
		{
72
			left.red = msg->left_red;
73
		}
74
		if(msg->left_green > NO_SET)
75
		{
76
			left.green = msg->left_green;
77
		}
78
		if(msg->left_blue > NO_SET)
79
		{
80
			left.blue = msg->left_blue;
81
		}
82
		if(msg->right_red > NO_SET)
83
		{
84
			right.red = msg->right_red;
85
		}
86
		if(msg->right_green > NO_SET)
87
		{
88
			right.green = msg->right_green;
89
		}
90
		if(msg->right_blue > NO_SET)
91
		{
92
			right.blue = msg->right_blue;
93
		}
94
		
95
    /* Write colors to hardware */
96
    /** @todo Add code to write colors to hardware */
97
}
98

  
99
/**
100
 * @brief headlights driver. This is a ROS node that controls headlight colors.
101
 *
102
 * This is the main function for the headlights node. It is run when the node
103
 * starts and initializes the headlights. It then subscribes to the
104
 * set_headlights topic.
105
 * 
106
 * @param argc The number of command line arguments (should be 1)
107
 * @param argv The array of command line arguments
108
 **/
109
int main(int argc, char **argv)
110
{
111
    /* Initialize in ROS the headlights driver node */
112
    ros::init(argc, argv, "headlights_driver");
113

  
114
    /* Create the nodehandle for this node*/
115
    ros::NodeHandle n;
116

  
117
    /* Subscribe to the set_headlights topic */
118
    ros::Subscriber sub0 = n.subscribe("set_headlights", QUEUE_SIZE, headlights_set);
119

  
120
    /* Initialize hardware for headlights */
121
    // Hardware init functions here
122

  
123
    ROS_INFO("Ready to set headlights.");
124
    ros::spin();
125

  
126
    return 0;
127
}
128

  
129
/** @} **/
scout/headlights/src/headlights.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 headlights.h
28
 * @brief Contains motor declarations and functions.
29
 * 
30
 * Contains functions and definitions for the use of
31
 * headlights.
32
 *
33
 * @author Colony Project, CMU Robotics Club
34
 **/
35

  
36
#ifndef _HEADLIGHTS_H_
37
#define _HEADLIGHTS_H_
38

  
39
#include "headlights/set_headlights.h"
40

  
41
#define FULL 0xFF
42
#define HALF 0xC0
43
#define OFF  0x00
44
#define NO_SET -1
45

  
46
/* The number of messages in the queue. If messages arrive faster than they are
47
 * handled, old ones are thrown out */
48
#define QUEUE_SIZE 4
49

  
50

  
51
/** @brief Initialize the headlights module and driver. **/
52
int main(int argc, char **argv);
53

  
54
/** @brief Responds to topic to set motor speeds and configs. **/
55
void headlights_set(const headlights::set_headlights::ConstPtr& msg);
56

  
57
#endif
scout/libscout/manifest.xml
13 13
  <depend package="roscpp"/>
14 14
  <depend package="motors"/>
15 15
  <depend package="encoders"/>
16
  <depend package="headlights"/>
17 16
  <depend package="buttons"/>
18
  <depend package="sonar"/>
19 17
  <depend package="linesensor"/>
20
<!--  <depend package="cliffsensor"/> -->
21 18

  
22 19
</package>
23 20

  
scout/libscout/src/CliffsensorControl.cpp
71 71
 * status of all cliff sensors.
72 72
 *
73 73
 */
74
void CliffsensorControl::changed_cliff_status(const cliffsensor::cliff_status_changed::ConstPtr& msg)
74
void CliffsensorControl::changed_cliff_status(const ::messages::cliff_status_changed::ConstPtr& msg)
75 75
{
76 76
    front_raw = msg->front_raw;
77 77
    left_raw = msg->left_raw;
scout/libscout/src/CliffsensorControl.h
38 38
#ifndef _CLIFFSENSOR_H_
39 39
#define _CLIFFSENSOR_H_
40 40

  
41
#include <cliffsensor/query_cliff.h>
42
#include <cliffsensor/cliff_status_changed.h>
41
#include <messages/query_cliff.h>
42
#include <messages/cliff_status_changed.h>
43 43
#include "constants.h"
44 44

  
45 45
#define CLIFF_DETECTED 0x0
......
52 52

  
53 53
        /** @brief Responds to topic to change cliff sensor status. **/
54 54
        void changed_cliff_status(
55
                        const cliffsensor::cliff_status_changed::ConstPtr& msg);
55
                        const messages::cliff_status_changed::ConstPtr& msg);
56 56

  
57 57
        int get_front_raw();
58 58
        int get_left_raw();
scout/libscout/src/HeadlightControl.cpp
50 50
                                   string scoutname)
51 51
    : node(libscout_node)
52 52
{
53
    set_headlights_pub = node.advertise<headlights::set_headlights>
53
    set_headlights_pub = node.advertise< ::messages::set_headlights>
54 54
        (scoutname + "/set_headlights", QUEUE_SIZE, true);
55 55
}
56 56

  
......
85 85
 */
86 86
void HeadlightControl::set_rgb(int red, int green, int blue, int which)
87 87
{
88
    headlights::set_headlights msg;
88
    ::messages::set_headlights msg;
89 89

  
90 90
    if(which & HL_LEFT)
91 91
    {
scout/libscout/src/HeadlightControl.h
39 39
#define _HEADLIGHT_CONTROL_H_
40 40

  
41 41
#include <ros/ros.h>
42
#include <headlights/set_headlights.h>
42
#include <messages/set_headlights.h>
43 43

  
44 44
#include "constants.h"
45 45

  
scout/libscout/src/SonarControl.cpp
51 51
    : node(libscout_node)
52 52
{
53 53
    sonar_set_scan_client =
54
        node.serviceClient<sonar::sonar_set_scan>(scoutname+"/set_sonar_scan");
54
        node.serviceClient< ::messages::sonar_set_scan>(scoutname+"/set_sonar_scan");
55 55
    sonar_toggle_client = 
56
        node.serviceClient<sonar::sonar_toggle>(scoutname + "/toggle_sonar");
56
        node.serviceClient< ::messages::sonar_toggle>(scoutname + "/toggle_sonar");
57 57
    sonar_distance_sub = node.subscribe(scoutname + "/sonar_distance",
58 58
                                        QUEUE_SIZE,
59 59
                                        &SonarControl::distance_callback,
......
76 76
 * Update the array of sonar values, and the last read timestamps,
77 77
 * to reflect the new reading received.
78 78
 */
79
void SonarControl::distance_callback(const sonar::sonar_distance::ConstPtr& msg)
79
void SonarControl::distance_callback(const ::messages::sonar_distance::ConstPtr& msg)
80 80
{
81 81
    // Error checking so that the array doesn't cause a segfault
82 82
    if (msg->pos < 0 || msg-> pos > 23)
......
128 128
    set_on();
129 129

  
130 130
    // Set scan range
131
    sonar::sonar_set_scan srv;
131
    ::messages::sonar_set_scan srv;
132 132
    srv.request.stop_l = start_pos;
133 133
    srv.request.stop_r = end_pos;
134 134

  
......
173 173
 */
174 174
void SonarControl::set_power(bool is_on)
175 175
{
176
    sonar::sonar_toggle srv;
176
    ::messages::sonar_toggle srv;
177 177
    srv.request.set_on = is_on;
178 178

  
179 179
    // Check if the service call failed or if the response was false
scout/libscout/src/SonarControl.h
38 38
#define _SONAR_CONTROL_H_
39 39

  
40 40
#include <ros/ros.h>
41
#include <sonar/sonar_set_scan.h>
42
#include <sonar/sonar_toggle.h>
43
#include <sonar/sonar_distance.h>
41
#include <messages/sonar_set_scan.h>
42
#include <messages/sonar_toggle.h>
43
#include <messages/sonar_distance.h>
44 44

  
45 45
#include "constants.h"
46 46

  
......
68 68

  
69 69
    private:
70 70
        /** Record the new sonar distance measurement */
71
        void distance_callback(const sonar::sonar_distance::ConstPtr& msg);
71
        void distance_callback(const messages::sonar_distance::ConstPtr& msg);
72 72

  
73 73
        /** Sends a sonar_toggle message. */
74 74
        void set_power(bool is_on);
scout/messages/msg/bom.msg
1
int8 sender
2
int8 send_dir
3
int8 recv_dir
4

  
5
# TODO these may need to be changed
6
int8 FRONT = 0
7
int8 LEFT  = 1
8
int8 BACK  = 2
9
int8 RIGHT = 3
scout/messages/msg/cliff_status_changed.msg
1
int8 front_raw
2
int8 left_raw
3
int8 right_raw
4
int8 cliff_status
scout/messages/msg/set_headlights.msg
1
int16 left_red
2
int16 left_green
3
int16 left_blue
4
int16 right_red
5
int16 right_green
6
int16 right_blue
scout/messages/msg/sonar_distance.msg
1
# Gives a timestamp so nodes make sure they use current readings
2
time stamp
3

  
4
# Position of the sonar (0-23), where 0 is right
5
int8 pos
6

  
7
# Distance reading from the front sonar in mm
8
uint16 distance0
9
# Distance reading from the back sonar in mm
10
uint16 distance1
scout/messages/srv/query_cliff.srv
1
int8 units
2
---
3
int8 front_raw
4
int8 left_raw
5
int8 right_raw
6
int8 cliff_status
scout/messages/srv/sonar_set_scan.srv
1
# Specify the left and right position stops for the scan.
2
# Valid position stops are 0 to 23.
3
int8 stop_l
4
int8 stop_r
5
---
6
# Sonar responds with an acknowledgement; true means no errors
7
bool ack
scout/messages/srv/sonar_toggle.srv
1
# Set to true to turn the sonar on; false to turn off
2
bool set_on
3
---
4
# Sonar responds with an acknowledgement; true means no errors
5
bool ack
scout/scoutsim/manifest.xml
16 16
  <depend package="motors" />
17 17
  <depend package="encoders" />
18 18
  <depend package="linesensor" />
19
  <depend package="sonar" />
20 19
  <depend package="geometry_msgs" />
21 20
  <depend package="messages"/>
22 21
  
23 22
  <rosdep name="wxwidgets"/>
24 23

  
25
  <!--<export>
26
    <cpp cflags="-I${prefix}/msg/cpp -I${prefix}/srv/cpp"/>
27
  </export>-->
28 24
  <export>
29 25
    <cpp cflags="-I${prefix}/msg/cpp -I${prefix}/srv/cpp -I${prefix}/include" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/libk"/>
30 26
  </export>
scout/scoutsim/src/scout.cpp
88 88

  
89 89
        pose_pub = node.advertise<Pose>("pose", 1);
90 90
        color_pub = node.advertise<Color>("color_sensor", 1);
91
        sonar_pub = node.advertise<sonar::sonar_distance>("sonar_distance", 1);
91
        sonar_pub = node.advertise< ::messages::sonar_distance>("sonar_distance", 1);
92 92
        set_pen_srv = node.advertiseService("set_pen",
93 93
                                            &Scout::setPenCallback,
94 94
                                            this);
......
180 180

  
181 181
    }
182 182

  
183
    bool Scout::handle_sonar_toggle(sonar::sonar_toggle::Request  &req,
184
                         sonar::sonar_toggle::Response &res)
183
    bool Scout::handle_sonar_toggle(::messages::sonar_toggle::Request  &req,
184
                         ::messages::sonar_toggle::Response &res)
185 185
    {
186 186
        if (req.set_on && !sonar_on)
187 187
        {
......
202 202
        return true;
203 203
    }
204 204

  
205
    bool Scout::handle_sonar_set_scan(sonar::sonar_set_scan::Request  &req,
206
                                      sonar::sonar_set_scan::Response &res)
205
    bool Scout::handle_sonar_set_scan(::messages::sonar_set_scan::Request  &req,
206
                                      ::messages::sonar_set_scan::Response &res)
207 207
    {
208 208
        // Code to set the sonar to scan from
209 209
        // req.stop_l to req.stop_r
......
371 371
                                          sonar_position + 24, sonar_dc);
372 372

  
373 373
        // Publish
374
        sonar::sonar_distance msg;
374
        ::messages::sonar_distance msg;
375 375
        msg.pos = sonar_position;
376 376
        msg.distance0 = d_front;
377 377
        msg.distance1 = d_back;
scout/scoutsim/src/scout.h
55 55
#include <motors/set_motors.h>
56 56
#include <encoders/query_encoders.h>
57 57
#include <linesensor/query_linesensor.h>
58
#include <sonar/sonar_distance.h>
59
#include <sonar/sonar_toggle.h>
60
#include <sonar/sonar_set_scan.h>
58
#include <messages/sonar_distance.h>
59
#include <messages/sonar_toggle.h>
60
#include <messages/sonar_set_scan.h>
61 61

  
62 62
#include <scoutsim/Pose.h>
63 63
#include <scoutsim/SetPen.h>
......
131 131
                                         encoders::query_encoders::Response&);
132 132
            bool query_linesensor_callback(linesensor::query_linesensor::Request&,
133 133
                                           linesensor::query_linesensor::Response&);
134
            bool handle_sonar_toggle(sonar::sonar_toggle::Request  &req,
135
                                     sonar::sonar_toggle::Response &res);
136
            bool handle_sonar_set_scan(sonar::sonar_set_scan::Request  &req,
137
                                       sonar::sonar_set_scan::Response &res);
134
            bool handle_sonar_toggle(messages::sonar_toggle::Request  &req,
135
                                     messages::sonar_toggle::Response &res);
136
            bool handle_sonar_set_scan(messages::sonar_set_scan::Request  &req,
137
                                       messages::sonar_set_scan::Response &res);
138 138
            unsigned int rgb_to_grey(unsigned char r,
139 139
                                     unsigned char g,
140 140
                                     unsigned char b);
scout/sonar/CMakeLists.txt
1
cmake_minimum_required(VERSION 2.4.6)
2
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
3

  
4
# Set the build type.  Options are:
5
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
6
#  Debug          : w/ debug symbols, w/o optimization
7
#  Release        : w/o debug symbols, w/ optimization
8
#  RelWithDebInfo : w/ debug symbols, w/ optimization
9
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
10
#set(ROS_BUILD_TYPE RelWithDebInfo)
11

  
12
rosbuild_init()
13

  
14
#set the default path for built executables to the "bin" directory
15
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
16
#set the default path for built libraries to the "lib" directory
17
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
18

  
19
#uncomment if you have defined messages
20
rosbuild_genmsg()
21
#uncomment if you have defined services
22
rosbuild_gensrv()
23

  
24
#common commands for building c++ executables and libraries
25
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
26
#target_link_libraries(${PROJECT_NAME} another_library)
27
#rosbuild_add_boost_directories()
28
#rosbuild_link_boost(${PROJECT_NAME} thread)
29
#rosbuild_add_executable(example examples/example.cpp)
30
#target_link_libraries(example ${PROJECT_NAME})
scout/sonar/Makefile
1
include $(shell rospack find mk)/cmake.mk
scout/sonar/mainpage.dox
1
/**
2
\mainpage
3
\htmlinclude manifest.html
4

  
5
\b The sonar node manages the readings and motion of the sonar sensor. The
6
sonar works by constantly scanning, and publishing the distance readings
7
into a ros topic viewable by other nodes.
8

  
9
\section codeapi Code API
10

  
11
<!--
12
Provide links to specific auto-generated API documentation within your
13
package that is of particular interest to a reader. Doxygen will
14
document pretty much every part of your code, so do your best here to
15
point the reader to the actual API.
16

  
17
If your codebase is fairly large or has different sets of APIs, you
18
should use the doxygen 'group' tag to keep these APIs together. For
19
example, the roscpp documentation has 'libros' group.
20
-->
21

  
22

  
23
*/
scout/sonar/manifest.xml
1
<package>
2
  <description brief="sonar">
3

  
4
     Operates the sonar sensor and provides a way to access distance readings.
5

  
6
  </description>
7
  <author>Alex</author>
8
  <license>BSD</license>
9
  <review status="unreviewed" notes=""/>
10
  <url>http://ros.org/wiki/sonar</url>
11
  <depend package="roscpp"/>
12
  <depend package="std_msgs"/>
13

  
14
</package>
15

  
16

  
scout/sonar/msg/sonar_distance.msg
1
# Gives a timestamp so nodes make sure they use current readings
2
time stamp
3

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff