Odometer monitor class. More...
#include <odometer.h>
Public Member Functions | |
Mandatory common functions | |
These functions are mandatory to all low level classes in the atlacar_base namespace. All these must operate in a similar fashion across class. The constructor must only initialize variable values, all major initializations must be done in the init() function, setupMessaging() subscribes and advertises command messages and status (in that order). The loop() function will block the program in a constant loop relaying information to the hardware. The loop() function can operate in two fashions: setting a spin rate and calling ros::spinOnce() or calling directly ros::spin() if the command callback has been setup properly. In this class (Odometer) it works by calling the ros::spinOnce() at a predefined rate.
| |
Odometer (const ros::NodeHandle &nh, std::string ip, std::string port) | |
Class constructor. More... | |
~Odometer () | |
Class destructor. More... | |
void | init () |
Initialize the class. More... | |
void | setupMessaging () |
Start ros message subscribing and advertising. More... | |
void | loop () |
Start main control loop. More... | |
Private Member Functions | |
void | connectHandler (void) |
This function will be called (asynchronously) on a successful connection. More... | |
void | diagnostics (diagnostic_updater::DiagnosticStatusWrapper &stat) |
Diagnostics function handler. More... | |
void | newData (string data) |
This function will be called (asynchronously) upon arrival of new data. More... | |
Private Attributes | |
AsyncClient | comm_ |
Asynchronous tcp/ip communication object. More... | |
boost::asio::io_service | io_service_ |
Input/Output communication service. More... | |
ros::NodeHandle | nh_ |
Ros node handler. More... | |
std::string | server_ip_ |
Ip of the Arduino server. More... | |
std::string | server_port_ |
Port of the Arduino server. More... | |
odometer::OdometerStatus | status_ |
Status message. More... | |
diagnostic_updater::HeaderlessTopicDiagnostic | status_freq_ |
Frequency diagnostics tool. More... | |
double | status_max_frequency_ |
Maximum admissible frequency. More... | |
double | status_min_frequency_ |
Minimum admissible frequency. More... | |
ros::Publisher | status_pub_ |
Ros status publisher. More... | |
diagnostic_updater::Updater | updater_ |
Diagnostics class. More... | |
Odometer monitor class.
This class handles all communications with the vehicle odometer. This system obtains the real velocity of the vehicle left read wheel.
Definition at line 64 of file odometer.h.
|
inline |
Class constructor.
Mandatory. Should only be used for variable initialization.
The constructor is used to set the server ip and port, initializing the communications service and object and the ros node handler. It also initializes the frequency diagnostics tool with the allowed maximum and minimum frequency.
Definition at line 89 of file odometer.h.
|
inline |
Class destructor.
Definition at line 103 of file odometer.h.
|
inlineprivate |
This function will be called (asynchronously) on a successful connection.
This function sends the start command to the Arduino, this order will signal the Arduino to start sending data.
Definition at line 183 of file odometer.h.
|
inlineprivate |
Diagnostics function handler.
stat | diagnostics information storage |
This function preforms diagnostics on the communication with the Arduino and reports back to the diagnostics tool.
Definition at line 232 of file odometer.h.
|
inline |
Initialize the class.
Mandatory. To specific initialization tasks, anything that cannot be preformed in the constructor should be done here.
This function initializes the diagnostics tool and sets the communication handlers for received data and connection established.
Definition at line 114 of file odometer.h.
|
inline |
Start main control loop.
Mandatory. Do the main loop of the program, call ros spin or spinOnce as needed, should only quit on ros exit command.
This function launches the io service in a separate thread and then starts to do spin ros. The while cycle is used to update the diagnostics tool only. Once the ros::ok() returns false the io service is stopped the thread closed and the loop quits.
Definition at line 150 of file odometer.h.
|
inlineprivate |
This function will be called (asynchronously) upon arrival of new data.
data | incoming data in std::string format |
This function handles new data coming from the Arduino. The new data is interpreted and a status message is published. This function uses boost::qi parser to interpret the message, this parser is quite complicated but very expansible, see the documentation for a tutorial on its use (its pretty funny).
Definition at line 201 of file odometer.h.
|
inline |
Start ros message subscribing and advertising.
Mandatory. Subscribe command messages and advertise status messages.
This function only advertises the status messages.
Definition at line 135 of file odometer.h.
|
private |
Asynchronous tcp/ip communication object.
Definition at line 277 of file odometer.h.
|
private |
Input/Output communication service.
Definition at line 275 of file odometer.h.
|
private |
Ros node handler.
Definition at line 258 of file odometer.h.
|
private |
Ip of the Arduino server.
Definition at line 253 of file odometer.h.
|
private |
Port of the Arduino server.
Definition at line 255 of file odometer.h.
|
private |
Status message.
Definition at line 264 of file odometer.h.
|
private |
Frequency diagnostics tool.
Definition at line 269 of file odometer.h.
|
private |
Maximum admissible frequency.
Definition at line 271 of file odometer.h.
|
private |
Minimum admissible frequency.
Definition at line 273 of file odometer.h.
|
private |
Ros status publisher.
Definition at line 261 of file odometer.h.
|
private |
Diagnostics class.
Definition at line 267 of file odometer.h.