This software driver implements the communications (and some rudimentary control) for ActivMedia robotic bases (Pioneer DX/AT, PeopleBot, etc).
There is implemented access to robot odometry, ticks counts, velocities, battery charge status, and sonar readings, as well as basic velocity control.
It is required to check MRPT_BUILD_ARIA in the cmake configuration to enable this class to work properly.
See also the application "rawlog-grabber" for a ready-to-use application to gather data from the robot base. Through that "common sensor interface", this object can collect these kinds of observations:
To use this class out of rawlog-grabber, "initialize" must be called to connect to the robot. Before that, set the serial port with setSerialPortConfig.
Example .ini block for rawlog-grabber (format used in "loadConfig"):
PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS: ------------------------------------------------------- [supplied_section_name] robotPort_WIN = COM1 robotPort_LIN = /dev/ttyUSB0 robotBaud = 115200 enableSonars = 0 ; 0:Disabled (default), 1: Enabled capture_rate = 10.0 ; In Hz, the rate at which sonars & odometry are gathered (default=10Hz) joystick_control = 0 ; 0:Disabled (default), 1: Enabled joystick_max_v = 0.1 ; Max joystick control speed (m/s) joystick_max_w_degps = 20 ; Max joystick control speed (deg/s)
Definition at line 71 of file CActivMediaRobotBase.h.
#include <mrpt/hwdrivers/CActivMediaRobotBase.h>
Classes | |
struct | TRobotDescription |
A structure describing the robot. More... | |
Public Member Functions | |
void | initialize () |
Connects to the robot. | |
CActivMediaRobotBase () | |
Constructor. | |
virtual | ~CActivMediaRobotBase () |
Destructor: turns off communications. | |
void | setSerialPortConfig (const std::string &portName, int portBaudRate) |
Manually sets the serial port configuration. | |
std::string | getSerialPort () const |
Returns the current value of the serial port. | |
int | getSerialPortBaudRate () const |
Returns the current value of the serial port baudrate. | |
void | doProcess () |
Collect odometry readings and put them in the "observations" queue: DO NOT call this normally, it's useful only for the application rawloggrabber. | |
void | changeOdometry (const mrpt::poses::CPose2D &newOdometry) |
Change the current robot odometry pose. | |
void | getOdometry (poses::CPose2D &out_odom) |
Get the current robot's odometry. | |
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 | 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 are always fixed to zero). | |
void | getSonarsReadings (bool &thereIsObservation, mrpt::slam::CObservationRange &obs) |
Get the readings from the sonars, only if the observations are new. | |
void | getBatteryCharge (double &out_batery_volts) |
Get the robot battery charge. | |
void | setVelocities (const double lin_vel, const double ang_vel) |
Set the robot linear and angular velocities. | |
void | enableSonars () |
Enable sonars. | |
void | disableSonars () |
Disable sonars. | |
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. | |
void | getRobotInformation (TRobotDescription &info) |
Get information about the robot and its sensors. | |
void | enableJoystickControl (bool enable=true) |
Enable/disable manual control of the robot with a Joystick. | |
bool | isJoystickControlEnabled () const |
Get state of manual control with a joystick. | |
Protected Member Functions | |
void | disconnectAndDisableMotors () |
void | connectAndEnableMotors () |
void | loadConfig_sensorSpecific (const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection) |
Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CActivMediaRobotBase for the possible parameters. | |
Protected Attributes | |
std::string | m_com_port |
The serial port name to use for communications (COM1, ttyS1,...) | |
int | m_robotBaud |
The bauds for ARIA communications to the robot. | |
bool | m_firstIncreOdometry |
Used in getOdometryIncrement. | |
bool | m_enableSonars |
void * | m_robot |
void * | m_sonarDev |
void * | m_simpleConnector |
The connection to the robot. | |
unsigned int | m_lastTimeSonars |
bool | m_enableJoyControl |
For use with rawlog-grabber. | |
float | m_joy_max_v |
float | m_joy_max_w |
CJoystick | m_joystick |
The joystick opened at first usage. | |
mrpt::system::TTimeStamp | m_last_do_process |
double | m_capture_rate |
In Hz, the rate at which sonars & odometry are gathered (default=10Hz) |
mrpt::hwdrivers::CActivMediaRobotBase::CActivMediaRobotBase | ( | ) |
Constructor.
virtual mrpt::hwdrivers::CActivMediaRobotBase::~CActivMediaRobotBase | ( | ) | [virtual] |
Destructor: turns off communications.
void mrpt::hwdrivers::CActivMediaRobotBase::changeOdometry | ( | const mrpt::poses::CPose2D & | newOdometry ) |
Change the current robot odometry pose.
void mrpt::hwdrivers::CActivMediaRobotBase::connectAndEnableMotors | ( | ) | [protected] |
void mrpt::hwdrivers::CActivMediaRobotBase::disableSonars | ( | ) |
Disable sonars.
void mrpt::hwdrivers::CActivMediaRobotBase::disconnectAndDisableMotors | ( | ) | [protected] |
void mrpt::hwdrivers::CActivMediaRobotBase::doProcess | ( | ) | [virtual] |
Collect odometry readings and put them in the "observations" queue: DO NOT call this normally, it's useful only for the application rawloggrabber.
Implements mrpt::hwdrivers::CGenericSensor.
void mrpt::hwdrivers::CActivMediaRobotBase::enableJoystickControl | ( | bool | enable = true ) |
[inline] |
Enable/disable manual control of the robot with a Joystick.
Definition at line 144 of file CActivMediaRobotBase.h.
void mrpt::hwdrivers::CActivMediaRobotBase::enableSonars | ( | ) |
Enable sonars.
void mrpt::hwdrivers::CActivMediaRobotBase::getBatteryCharge | ( | double & | out_batery_volts ) |
Get the robot battery charge.
void mrpt::hwdrivers::CActivMediaRobotBase::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.
void mrpt::hwdrivers::CActivMediaRobotBase::getOdometry | ( | poses::CPose2D & | out_odom ) |
Get the current robot's odometry.
out_odom | The odometry will be returned here. |
void mrpt::hwdrivers::CActivMediaRobotBase::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.
out_odom | The odometry will be returned here. |
out_lin_vel | The linear speed, in m/s, positive is forward. |
out_ang_vel | The angular speed, in rad/s, positive is anticlockwise. |
out_left_encoder_ticks | The current overall count of ticks for the left wheel encoder. |
out_right_encoder_ticks | The current overall count of ticks for the right wheel encoder. |
void mrpt::hwdrivers::CActivMediaRobotBase::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 are always fixed to zero).
out_odom | The odometry increment. |
out_lin_vel | The current linear speed, in m/s, positive is forward (Absolute values, not increments) |
out_ang_vel | The angular speed, in rad/s, positive is anticlockwise (Absolute values, not increments). |
out_left_encoder_ticks | The increment in ticks for the left wheel encoder. |
out_right_encoder_ticks | The increment in ticks for the right wheel encoder. |
void mrpt::hwdrivers::CActivMediaRobotBase::getRobotInformation | ( | TRobotDescription & | info ) |
Get information about the robot and its sensors.
std::string mrpt::hwdrivers::CActivMediaRobotBase::getSerialPort | ( | ) | const [inline] |
Returns the current value of the serial port.
Definition at line 70 of file CActivMediaRobotBase.h.
int mrpt::hwdrivers::CActivMediaRobotBase::getSerialPortBaudRate | ( | ) | const [inline] |
Returns the current value of the serial port baudrate.
Definition at line 73 of file CActivMediaRobotBase.h.
References DEFINE_GENERIC_SENSOR, and HWDRIVERS_IMPEXP.
void mrpt::hwdrivers::CActivMediaRobotBase::getSonarsReadings | ( | bool & | thereIsObservation, |
mrpt::slam::CObservationRange & | obs | ||
) |
Get the readings from the sonars, only if the observations are new.
void mrpt::hwdrivers::CActivMediaRobotBase::initialize | ( | ) | [virtual] |
Connects to the robot.
Reimplemented from mrpt::hwdrivers::CGenericSensor.
bool mrpt::hwdrivers::CActivMediaRobotBase::isJoystickControlEnabled | ( | ) | const [inline] |
Get state of manual control with a joystick.
Definition at line 147 of file CActivMediaRobotBase.h.
void mrpt::hwdrivers::CActivMediaRobotBase::loadConfig_sensorSpecific | ( | const mrpt::utils::CConfigFileBase & | configSource, |
const std::string & | iniSection | ||
) | [protected, virtual] |
Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes) See hwdrivers::CActivMediaRobotBase for the possible parameters.
Implements mrpt::hwdrivers::CGenericSensor.
void mrpt::hwdrivers::CActivMediaRobotBase::setSerialPortConfig | ( | const std::string & | portName, |
int | portBaudRate | ||
) |
Manually sets the serial port configuration.
portName | Examples: Windows: "COM1" , Linux: "/dev/ttyUSB0" |
portBaudRate | 9600, 115200, etc.. |
void mrpt::hwdrivers::CActivMediaRobotBase::setVelocities | ( | const double | lin_vel, |
const double | ang_vel | ||
) |
Set the robot linear and angular velocities.
lin_vel | Linear speed, in m/s. |
ang_vel | Angular speed, in rad/s. |
double mrpt::hwdrivers::CActivMediaRobotBase::m_capture_rate [protected] |
In Hz, the rate at which sonars & odometry are gathered (default=10Hz)
Definition at line 168 of file CActivMediaRobotBase.h.
std::string mrpt::hwdrivers::CActivMediaRobotBase::m_com_port [protected] |
The serial port name to use for communications (COM1, ttyS1,...)
Definition at line 150 of file CActivMediaRobotBase.h.
bool mrpt::hwdrivers::CActivMediaRobotBase::m_enableJoyControl [protected] |
For use with rawlog-grabber.
Definition at line 162 of file CActivMediaRobotBase.h.
bool mrpt::hwdrivers::CActivMediaRobotBase::m_enableSonars [protected] |
Definition at line 154 of file CActivMediaRobotBase.h.
bool mrpt::hwdrivers::CActivMediaRobotBase::m_firstIncreOdometry [protected] |
Used in getOdometryIncrement.
Definition at line 153 of file CActivMediaRobotBase.h.
float mrpt::hwdrivers::CActivMediaRobotBase::m_joy_max_v [protected] |
Definition at line 163 of file CActivMediaRobotBase.h.
float mrpt::hwdrivers::CActivMediaRobotBase::m_joy_max_w [protected] |
Definition at line 163 of file CActivMediaRobotBase.h.
The joystick opened at first usage.
Definition at line 165 of file CActivMediaRobotBase.h.
Definition at line 167 of file CActivMediaRobotBase.h.
unsigned int mrpt::hwdrivers::CActivMediaRobotBase::m_lastTimeSonars [protected] |
Definition at line 160 of file CActivMediaRobotBase.h.
void* mrpt::hwdrivers::CActivMediaRobotBase::m_robot [protected] |
Definition at line 156 of file CActivMediaRobotBase.h.
int mrpt::hwdrivers::CActivMediaRobotBase::m_robotBaud [protected] |
The bauds for ARIA communications to the robot.
Definition at line 151 of file CActivMediaRobotBase.h.
void* mrpt::hwdrivers::CActivMediaRobotBase::m_simpleConnector [protected] |
The connection to the robot.
Definition at line 158 of file CActivMediaRobotBase.h.
void* mrpt::hwdrivers::CActivMediaRobotBase::m_sonarDev [protected] |
Definition at line 157 of file CActivMediaRobotBase.h.
Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:46:17 UTC 2011 |