Classes | Public Member Functions | Private Member Functions | Private Attributes
ardusim::Ardusim Class Reference

C++ class implementation of the ardusim protocol. More...

#include <inc/Ardusim.h>

List of all members.

Classes

struct  AnemometerCalibData
struct  TopDistances

Public Member Functions

 Ardusim (std::string port_name)
 Constructor.
int checkVersion (int timeout)
 Check version.
bool getAnemometer (std::vector< lse_sensor_msgs::Anemometer > *anemometer)
bool getNose (std::vector< lse_sensor_msgs::Nostril > *nose)
bool getRange (std::vector< lse_sensor_msgs::Range > *range)
void getRequests (std::list< int > *requests)
 Get requests.
bool getSensorData (int timeout)
 Read sensor data from the arduino.
bool getThermistor (std::vector< lse_sensor_msgs::Thermistor > *thermistor)
bool getTPA (std::vector< lse_sensor_msgs::TPA > *tpa)
bool loadAnemometerCalibFile (std::string *file_path)
 Get value.
bool sensorDiscovery (int timeout)
 Scan i2c sensors.
bool setAutoRequests (int timeout)
 Ask for connected sensors.
void setRequests (int *requests, int num_of_requests)
 Set requests.
 ~Ardusim ()
 Destructor.

Private Member Functions

void addValue (std::string *data, int value)
 Add value.
bool autoRequests (int timeout, char mode)
 Auto request sensors from the arduino.
int getValue (std::string *data)
 Get value.
void parseAnemometer (std::string *data)
 Anemometer data parser.
bool parseData (std::string *data)
 Parse data.
void parseNose (std::string *data)
 Nose data parser.
void parseRange (std::string *data)
 Range data parser.
void parseTPA (std::string *data)
 TPA data parser.
bool sendCommand (int timeout, char mode, std::string *reply)
 Send command.

Private Attributes

std::vector
< lse_sensor_msgs::Anemometer
anemometer_msgs_
 Vector of anemometer messages.
std::vector< AnemometerCalibDatacalib_data_
std::vector
< lse_sensor_msgs::Nostril
nose_msgs_
 Vector of nose messages.
ros::Time now_
 Current time.
std::vector
< lse_sensor_msgs::Range
range_msgs_
 Vector of range messages.
std::list< int > requests_
 List of requests.
cereal::CerealPortserial_port_
std::vector
< lse_sensor_msgs::Thermistor
thermistor_msgs_
 Vector of thermistor messages.
std::vector< lse_sensor_msgs::TPAtpa_msgs_
 Vector of tpa messages.

Detailed Description

C++ class implementation of the ardusim protocol.

This class implements the ardusim protocol (arduino sensor interface module). This allows for easy ROS publishing of LSE common sensor data.

Definition at line 80 of file Ardusim.h.


Constructor & Destructor Documentation

ardusim::Ardusim::Ardusim ( std::string  port_name)

Constructor.

Parameters:
port_nameName of the serial port to open.

Definition at line 49 of file Ardusim.cpp.

Destructor.

Definition at line 80 of file Ardusim.cpp.


Member Function Documentation

void ardusim::Ardusim::addValue ( std::string *  data,
int  value 
) [private]

Add value.

Parsing helper function. Adds an int value to a std::string.

Parameters:
dataString.
valueInt value to be added.
See also:
getValue()

Definition at line 318 of file Ardusim.cpp.

bool ardusim::Ardusim::autoRequests ( int  timeout,
char  mode 
) [private]

Auto request sensors from the arduino.

Ask the arduino which sensors are connected to it. This can be user-defined or product of a i2c scan.

Parameters:
timeoutTimeout in milliseconds.
modeArdusim mode.
See also:
sensorDiscovery()
setAutoRequests()
Returns:
True if succeeded, false if not.

Definition at line 140 of file Ardusim.cpp.

int ardusim::Ardusim::checkVersion ( int  timeout)

Check version.

Check the software version running in the arduino for compatibility issues.

Parameters:
timeoutTimeout in milliseconds.
Returns:
The version of the sofware in the arduino.

Definition at line 126 of file Ardusim.cpp.

bool ardusim::Ardusim::getAnemometer ( std::vector< lse_sensor_msgs::Anemometer > *  anemometer)

Definition at line 281 of file Ardusim.cpp.

bool ardusim::Ardusim::getNose ( std::vector< lse_sensor_msgs::Nostril > *  nose)

Definition at line 245 of file Ardusim.cpp.

bool ardusim::Ardusim::getRange ( std::vector< lse_sensor_msgs::Range > *  range)

Definition at line 227 of file Ardusim.cpp.

void ardusim::Ardusim::getRequests ( std::list< int > *  requests)

Get requests.

Ask Ardusim which sensors we are getting!

Parameters:
requestsList of requests.

Definition at line 170 of file Ardusim.cpp.

bool ardusim::Ardusim::getSensorData ( int  timeout)

Read sensor data from the arduino.

Read sensor data from the arduino. The sensors requested are the ones in the list of requests.

Parameters:
timeoutTimeout in milliseconds.
See also:
requests_
sensorDiscovery()
setAutoRequests()
setRequests()
Returns:
True if succeeded, false if not.

Definition at line 188 of file Ardusim.cpp.

bool ardusim::Ardusim::getThermistor ( std::vector< lse_sensor_msgs::Thermistor > *  thermistor)

Definition at line 299 of file Ardusim.cpp.

bool ardusim::Ardusim::getTPA ( std::vector< lse_sensor_msgs::TPA > *  tpa)

Definition at line 263 of file Ardusim.cpp.

int ardusim::Ardusim::getValue ( std::string *  data) [private]

Get value.

Parsing helper function. Gets an int value from a std::string.

Parameters:
dataString.
See also:
addValue()
Returns:
An int value.

Definition at line 329 of file Ardusim.cpp.

bool ardusim::Ardusim::loadAnemometerCalibFile ( std::string *  file_path)

Get value.

Load the calibration data for the anemometer from a file.

Parameters:
file_pathFile path.
See also:
parseAnemometer()
Returns:
Wether the file was loaded or not.

Definition at line 543 of file Ardusim.cpp.

void ardusim::Ardusim::parseAnemometer ( std::string *  data) [private]

Anemometer data parser.

Definition at line 431 of file Ardusim.cpp.

bool ardusim::Ardusim::parseData ( std::string *  data) [private]

Parse data.

Data parsing function. Parses data comming from the arduino.

Parameters:
dataString to be parsed.
Returns:
True if succeeded, false if not.

Definition at line 343 of file Ardusim.cpp.

void ardusim::Ardusim::parseNose ( std::string *  data) [private]

Nose data parser.

Definition at line 393 of file Ardusim.cpp.

void ardusim::Ardusim::parseRange ( std::string *  data) [private]

Range data parser.

Definition at line 375 of file Ardusim.cpp.

void ardusim::Ardusim::parseTPA ( std::string *  data) [private]

TPA data parser.

Definition at line 412 of file Ardusim.cpp.

bool ardusim::Ardusim::sendCommand ( int  timeout,
char  mode,
std::string *  reply 
) [private]

Send command.

Send a command to the arduino.

Parameters:
timeoutTimeout in milliseconds.
modeArdusim mode.
replyReply from the arduino.
Returns:
True if succeeded, false if not.

Definition at line 93 of file Ardusim.cpp.

bool ardusim::Ardusim::sensorDiscovery ( int  timeout) [inline]

Scan i2c sensors.

Commands the arduino to perform a i2c scan to detect connected sensors automatically. Wrapper for autoRequests.

Parameters:
timeoutTimeout in milliseconds.
See also:
autoRequests()
setRequests()
Returns:
True if succeeded, false if not.

Definition at line 115 of file Ardusim.h.

bool ardusim::Ardusim::setAutoRequests ( int  timeout) [inline]

Ask for connected sensors.

Asks the arduino which user-defined sensors are connected. Wrapper for autoRequests.

Parameters:
timeoutTimeout in milliseconds.
See also:
autoRequests()
setRequests()
Returns:
True if succeeded, false if not.

Definition at line 127 of file Ardusim.h.

void ardusim::Ardusim::setRequests ( int *  requests,
int  num_of_requests 
)

Set requests.

Tell the arduino which sensors to read.

Parameters:
requestsArray of requests to read.
num_of_requestsNumber of requests.

Definition at line 177 of file Ardusim.cpp.


Member Data Documentation

Vector of anemometer messages.

Definition at line 266 of file Ardusim.h.

Definition at line 277 of file Ardusim.h.

Vector of nose messages.

Definition at line 262 of file Ardusim.h.

Current time.

Definition at line 188 of file Ardusim.h.

Vector of range messages.

Definition at line 260 of file Ardusim.h.

std::list<int> ardusim::Ardusim::requests_ [private]

List of requests.

Definition at line 186 of file Ardusim.h.

Definition at line 183 of file Ardusim.h.

Vector of thermistor messages.

Definition at line 268 of file Ardusim.h.

Vector of tpa messages.

Definition at line 264 of file Ardusim.h.


The documentation for this class was generated from the following files:


ardusim
Author(s): Gonçalo Cabrita and Pedro Sousa
autogenerated on Mon Jan 6 2014 11:26:58