Main MRPT website > C++ reference for MRPT 1.4.0
CActivMediaRobotBase.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef CActivMediaRobotBase_H
10#define CActivMediaRobotBase_H
11
14#include <mrpt/poses/CPose2D.h>
17
18namespace mrpt
19{
20 namespace hwdrivers
21 {
22 /** This software driver implements the communications (and some rudimentary control) for ActivMedia robotic bases (Pioneer DX/AT, PeopleBot, etc).
23 * There is implemented access to robot odometry, ticks counts, velocities, battery charge status, and sonar readings, as well as
24 * basic velocity control.
25 *
26 * It is required to check MRPT_BUILD_ARIA in the cmake configuration to enable this class to work properly.
27 *
28 * See also the application "rawlog-grabber" for a ready-to-use application to gather data from the robot base.
29 * Through that "common sensor interface", this object can collect these kinds of observations:
30 * - mrpt::obs::CObservationOdometry : For odometry
31 * - mrpt::obs::CObservationRange : For sonars
32 *
33 * To use this class out of rawlog-grabber, "initialize" must be called to connect to the robot.
34 * Before that, set the serial port with setSerialPortConfig.
35 *
36 *
37 *
38 * Example .ini block for rawlog-grabber (format used in "loadConfig"):
39 *
40 * \code
41 * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
42 * -------------------------------------------------------
43 * [supplied_section_name]
44 * robotPort_WIN = COM1
45 * robotPort_LIN = /dev/ttyUSB0
46 * robotBaud = 115200
47 * enableSonars = 0 ; 0:Disabled (default), 1: Enabled
48 * capture_rate = 10.0 ; In Hz, the rate at which sonars & odometry are gathered (default=10Hz)
49 *
50 * joystick_control = 0 ; 0:Disabled (default), 1: Enabled
51 * joystick_max_v = 0.1 ; Max joystick control speed (m/s)
52 * joystick_max_w_degps = 20 ; Max joystick control speed (deg/s)
53 *
54 * \endcode
55 * \ingroup mrpt_hwdrivers_grp
56 */
58 {
60 public:
61
62 /** A structure describing the robot */
64 {
65 TRobotDescription(); //!< Init
66 size_t nFrontBumpers; //!< Number of front bumpers
67 size_t nRearBumpers; //!< Number of rear bumpers
68 size_t nSonars; //!< Number of sonars
69 };
70
71
72 /** Connects to the robot */
73 void initialize();
74
75 /** Constructor
76 */
78
79 /** Destructor: turns off communications */
81
82 /** Manually sets the serial port configuration.
83 * \param portName Examples: Windows: "COM1" , Linux: "/dev/ttyUSB0"
84 * \param portBaudRate 9600, 115200, etc..
85 * \sa loadConfig
86 */
88 const std::string &portName,
89 int portBaudRate );
90
91 /** Returns the current value of the serial port */
92 std::string getSerialPort() const { return m_com_port; }
93
94 /** Returns the current value of the serial port baudrate */
95 int getSerialPortBaudRate() const { return m_robotBaud; }
96
97
98 /** Collect odometry readings and put them in the "observations" queue: DO NOT call this normally, it's useful only for the application rawloggrabber.
99 */
100 void doProcess();
101
102 /** Change the current robot odometry pose
103 */
104 void changeOdometry(const mrpt::poses::CPose2D &newOdometry);
105
106 /** Get the current robot's odometry
107 * \param out_odom The odometry will be returned here.
108 * \sa getOdometryFull, getOdometryIncrement
109 */
111
112 /** Get the current robot's odometry
113 * \param out_odom The odometry will be returned here.
114 * \param out_lin_vel The linear speed, in m/s, positive is forward.
115 * \param out_ang_vel The angular speed, in rad/s, positive is anticlockwise.
116 * \param out_left_encoder_ticks The current overall count of ticks for the left wheel encoder.
117 * \param out_right_encoder_ticks The current overall count of ticks for the right wheel encoder.
118 * \sa getOdometry, getOdometryIncrement
119 */
121 poses::CPose2D &out_odom,
122 double &out_lin_vel,
123 double &out_ang_vel,
124 int64_t &out_left_encoder_ticks,
125 int64_t &out_right_encoder_ticks
126 );
127
128 /** Get the robot's odometry increment since the last call to this method (the first time the increments are always fixed to zero).
129 * \param out_odom The odometry increment.
130 * \param out_lin_vel The current linear speed, in m/s, positive is forward (Absolute values, not increments)
131 * \param out_ang_vel The angular speed, in rad/s, positive is anticlockwise (Absolute values, not increments).
132 * \param out_left_encoder_ticks The increment in ticks for the left wheel encoder.
133 * \param out_right_encoder_ticks The increment in ticks for the right wheel encoder.
134 * \sa getOdometry, getOdometryFull
135 */
137 poses::CPose2D &out_incr_odom,
138 double &out_lin_vel,
139 double &out_ang_vel,
140 int64_t &out_incr_left_encoder_ticks,
141 int64_t &out_incr_right_encoder_ticks
142 );
143
144 /** Get the readings from the sonars, only if the observations are new.
145 */
146 void getSonarsReadings( bool &thereIsObservation, mrpt::obs::CObservationRange &obs );
147
148 /** Get the robot battery charge - normalized to 12V */
149 void getBatteryCharge( double &out_batery_volts );
150 /** Get the robot real battery charge */
151 void getRealBatteryCharge( double &out_batery_volts );
152
153 /** Set the robot linear and angular velocities
154 * \param lin_vel Linear speed, in m/s.
155 * \param ang_vel Angular speed, in rad/s.
156 */
157 void setVelocities( const double lin_vel, const double ang_vel);
158
159 void enableSonars(); //!< Enable sonars
160 void disableSonars(); //!< Disable sonars
161
162
163 void getBumpers(vector_bool &bumper_state); //!< Get state of bumpers: at output, the vector will be resized to the number of bumpers, and elements with "true" means bumper is pressed.
164
165 void getRobotInformation(TRobotDescription &info); //!< Get information about the robot and its sensors
166
167 /** Enable/disable manual control of the robot with a Joystick */
168 void enableJoystickControl(bool enable=true) { m_enableJoyControl = enable; }
169
170 /** Get state of manual control with a joystick */
171 bool isJoystickControlEnabled() const { return m_enableJoyControl;}
172
173 /** Disable motors but keeps the connection with ARIA*/
175
176 /** Enable motors after a call to DisableMotors()*/
178
179 /** Get the motors state*/
180 bool areMotorsEnabled() const;
181
182 protected:
183 std::string m_com_port; //!< The serial port name to use for communications (COM1, ttyS1,...)
184 int m_robotBaud; //!< The bauds for ARIA communications to the robot.
185
186 bool m_firstIncreOdometry; //!< Used in getOdometryIncrement
188
189
190 void* /*ArRobot*/ m_robot;
191 void* /*ArSonarDevice*/ m_sonarDev;
192 void* /*ArSimpleConnector* */ m_simpleConnector; //!< The connection to the robot
193
194 unsigned int m_lastTimeSonars;
195
196 bool m_enableJoyControl; //!< For use with rawlog-grabber
197 float m_joy_max_v, m_joy_max_w;
198
199 CJoystick m_joystick; //!< The joystick opened at first usage.
200
202 double m_capture_rate; //!< In Hz, the rate at which sonars & odometry are gathered (default=10Hz)
203
206
207 /** See the class documentation at the top for expected parameters */
209 const mrpt::utils::CConfigFileBase &configSource,
210 const std::string &iniSection );
211
212
213 }; // End of class
214
215 } // End of namespace
216} // End of namespace
217#endif
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
This software driver implements the communications (and some rudimentary control) for ActivMedia robo...
void getRealBatteryCharge(double &out_batery_volts)
Get the robot real battery charge.
void getSonarsReadings(bool &thereIsObservation, mrpt::obs::CObservationRange &obs)
Get the readings from the sonars, only if the observations are new.
void changeOdometry(const mrpt::poses::CPose2D &newOdometry)
Change the current robot odometry pose.
void getOdometryIncrement(poses::CPose2D &out_incr_odom, double &out_lin_vel, double &out_ang_vel, int64_t &out_incr_left_encoder_ticks, int64_t &out_incr_right_encoder_ticks)
Get the robot's odometry increment since the last call to this method (the first time the increments ...
void getRobotInformation(TRobotDescription &info)
Get information about the robot and its sensors.
void getOdometry(poses::CPose2D &out_odom)
Get the current robot's odometry.
CJoystick m_joystick
The joystick opened at first usage.
void DisableMotors()
Disable motors but keeps the connection with ARIA.
void getOdometryFull(poses::CPose2D &out_odom, double &out_lin_vel, double &out_ang_vel, int64_t &out_left_encoder_ticks, int64_t &out_right_encoder_ticks)
Get the current robot's odometry.
void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
See the class documentation at the top for expected parameters.
void getBumpers(vector_bool &bumper_state)
Get state of bumpers: at output, the vector will be resized to the number of bumpers,...
int getSerialPortBaudRate() const
Returns the current value of the serial port baudrate.
bool isJoystickControlEnabled() const
Get state of manual control with a joystick.
bool areMotorsEnabled() const
Get the motors state.
void enableJoystickControl(bool enable=true)
Enable/disable manual control of the robot with a Joystick.
double m_capture_rate
In Hz, the rate at which sonars & odometry are gathered (default=10Hz)
std::string getSerialPort() const
Returns the current value of the serial port.
void * m_simpleConnector
The connection to the robot.
bool m_enableJoyControl
For use with rawlog-grabber.
void getBatteryCharge(double &out_batery_volts)
Get the robot battery charge - normalized to 12V.
void setVelocities(const double lin_vel, const double ang_vel)
Set the robot linear and angular velocities.
void doProcess()
Collect odometry readings and put them in the "observations" queue: DO NOT call this normally,...
void disableSonars()
Disable sonars.
int m_robotBaud
The bauds for ARIA communications to the robot.
void initialize()
Connects to the robot.
std::string m_com_port
The serial port name to use for communications (COM1, ttyS1,...)
void EnableMotors()
Enable motors after a call to DisableMotors()
bool m_firstIncreOdometry
Used in getOdometryIncrement.
void setSerialPortConfig(const std::string &portName, int portBaudRate)
Manually sets the serial port configuration.
virtual ~CActivMediaRobotBase()
Destructor: turns off communications.
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
Access to joysticks and gamepads (read buttons and position), and request number of joysticks in the ...
Definition: CJoystick.h:26
Declares a class derived from "CObservation" that encapsules a single range measurement,...
A class used to store a 2D pose.
Definition: CPose2D.h:37
This class allows loading and storing values and vectors of different types from a configuration text...
std::vector< bool > vector_bool
A type for passing a vector of bools.
Definition: types_simple.h:29
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
Definition: datetime.h:30
#define HWDRIVERS_IMPEXP
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Sun Nov 27 02:56:26 UTC 2022