#include <serial_glove.hpp>
Public Member Functions | |
CybergloveSerial (std::string serial_port, boost::function< void(std::vector< float >, bool)> callback) | |
int | get_nb_msgs_received () |
int | set_filtering (bool value) |
int | set_frequency (std::string frequency) |
int | set_transmit_info (bool value) |
int | start_stream () |
~CybergloveSerial () | |
Static Public Attributes | |
static const unsigned short | glove_size = 22 |
Private Member Functions | |
void | stream_callback (char *world, int length) |
Private Attributes | |
bool | button_on |
boost::function< void(std::vector < float >, bool)> | callback_function |
boost::shared_ptr < cereal::CerealPort > | cereal_port |
int | current_value |
int | glove_pos_index |
std::vector< float > | glove_positions |
A vector containing the current joints positions. | |
bool | light_on |
int | nb_msgs_received |
bool | no_errors |
Did we get any garbage in the received message? |
This class uses the Cereal Port ROS package to connect to and interact with the Cyberglove.
Definition at line 99 of file serial_glove.hpp.
cyberglove::CybergloveSerial::CybergloveSerial | ( | std::string | serial_port, |
boost::function< void(std::vector< float >, bool)> | callback | ||
) |
Initializes the connection with the cyberglove through the given serial port.
serial_port | the path to the serial port, /dev/ttyS0 by default |
callback | a pointer to a callback function, which will be called each time a complete joint message is received. |
Definition at line 42 of file serial_glove.cpp.
Definition at line 59 of file serial_glove.cpp.
We keep the count of all the messages received for the glove.
Definition at line 191 of file serial_glove.cpp.
int cyberglove::CybergloveSerial::set_filtering | ( | bool | value | ) |
Turns on or off the filtering (done directly in the cyberglove). By default the filtering is activated. We recommend turning it off if you want to do oversampling, to get the fastest rate (the rate is divided by 2-3 if the filtering is on)
value | true if you want to turn it on. |
Definition at line 66 of file serial_glove.cpp.
int cyberglove::CybergloveSerial::set_frequency | ( | std::string | frequency | ) |
Set the transmit frequency for the cyberglove.
frequency | use the elements of the struct cyberglove_freq::CybergloveFreq |
Definition at line 106 of file serial_glove.cpp.
int cyberglove::CybergloveSerial::set_transmit_info | ( | bool | value | ) |
Turns on or off the status transmission: if it's on, then a char is added to the message to describe the current status of the glove. For this status byte, the bit 1 corresponds to the button status, and the bit 2 corresponds to the light status.
value | true if you want to turn it on. |
Definition at line 86 of file serial_glove.cpp.
Start streaming the data from the cyberglove, calling the callback function each time the full message is received.
Definition at line 116 of file serial_glove.cpp.
void cyberglove::CybergloveSerial::stream_callback | ( | char * | world, |
int | length | ||
) | [private] |
The callback function for the raw data coming from the serial port, bound to the cereal_port callback. The data received here is not received message by messages: it's a stream of data, coming at different intervals (the whole messages are received at a given frequency though)
world | a table of char containing the binary values from the serial port |
length | the length of the received message. |
Definition at line 129 of file serial_glove.cpp.
bool cyberglove::CybergloveSerial::button_on [private] |
Definition at line 194 of file serial_glove.hpp.
boost::function<void(std::vector<float>, bool)> cyberglove::CybergloveSerial::callback_function [private] |
The pointer to the function called each time a full message is received. This function is linked when instantiating the class.
Definition at line 192 of file serial_glove.hpp.
boost::shared_ptr<cereal::CerealPort> cyberglove::CybergloveSerial::cereal_port [private] |
CerealPort is the ROS library used to talk to the serial port.
Definition at line 168 of file serial_glove.hpp.
int cyberglove::CybergloveSerial::current_value [private] |
Definition at line 186 of file serial_glove.hpp.
int cyberglove::CybergloveSerial::glove_pos_index [private] |
Definition at line 182 of file serial_glove.hpp.
std::vector<float> cyberglove::CybergloveSerial::glove_positions [private] |
A vector containing the current joints positions.
Definition at line 184 of file serial_glove.hpp.
const unsigned short cyberglove::CybergloveSerial::glove_size = 22 [static] |
The number of sensors in the glove.
Definition at line 161 of file serial_glove.hpp.
bool cyberglove::CybergloveSerial::light_on [private] |
Definition at line 194 of file serial_glove.hpp.
int cyberglove::CybergloveSerial::nb_msgs_received [private] |
Definition at line 182 of file serial_glove.hpp.
bool cyberglove::CybergloveSerial::no_errors [private] |
Did we get any garbage in the received message?
Definition at line 197 of file serial_glove.hpp.