27 #ifndef _TACTILE_SENSORS_HPP_ 28 #define _TACTILE_SENSORS_HPP_ 33 #include <boost/array.hpp> 34 #include <boost/algorithm/string.hpp> 35 #include <boost/algorithm/string/find_iterator.hpp> 36 #include <boost/circular_buffer.hpp> 54 : tactile_data_valid(tactile_data_valid), sample_frequency(sample_frequency),
55 manufacturer(manufacturer), serial_number(serial_number),
56 software_version_current(software_version_current),
57 software_version_server(software_version_server),
58 software_version_modified(software_version_modified),
59 pcb_version(pcb_version)
88 std::vector<std::string> splitted_string;
89 boost::split(splitted_string, version, boost::is_any_of(
"\n"));
91 ROS_DEBUG(
"Tactile version: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
92 static_cast<unsigned char>(version[0]), static_cast<unsigned char>(version[1]),
93 static_cast<unsigned char>(version[2]), static_cast<unsigned char>(version[3]),
94 static_cast<unsigned char>(version[4]), static_cast<unsigned char>(version[5]),
95 static_cast<unsigned char>(version[6]), static_cast<unsigned char>(version[7]),
96 static_cast<unsigned char>(version[8]), static_cast<unsigned char>(version[9]),
97 static_cast<unsigned char>(version[10]), static_cast<unsigned char>(version[11]),
98 static_cast<unsigned char>(version[12]), static_cast<unsigned char>(version[13]),
99 static_cast<unsigned char>(version[14]), static_cast<unsigned char>(version[15]));
100 if (splitted_string.size() >= 3)
102 software_version_current =
convertToInt(splitted_string[0]);
103 software_version_server =
convertToInt(splitted_string[1]);
105 if (splitted_string[2] ==
"No")
107 software_version_modified =
false;
111 software_version_modified =
true;
116 ROS_ERROR(
"Incorrect tactile sensor version format");
117 software_version_current = 0;
118 software_version_server = 0;
119 software_version_modified =
false;
132 std::string full_version;
134 std::stringstream ss;
135 if (software_version_modified)
137 ss <<
"current: " << software_version_current <<
" / server: " << software_version_server <<
" / MODIFIED";
141 ss <<
"current: " << software_version_current <<
" / server: " << software_version_server <<
" / not modified";
144 full_version = ss.str();
153 std::istringstream i(s);
180 pressure(pst3.pressure), temperature(pst3.temperature),
181 debug_1(pst3.debug_1), debug_2(pst3.debug_2),
182 pressure_raw(pst3.pressure_raw), zero_tracking(pst3.zero_tracking), dac_value(pst3.dac_value)
220 std::string full_version;
222 std::stringstream ss;
225 full_version = ss.str();
239 pac_buffer_ = boost::circular_buffer<int16_t>(pac_size_);
240 pac_vector_.reserve(pac_size_);
250 pac0(btac.pac0), pac1(btac.pac1),
251 pdc(btac.pdc), tac(btac.tac),
254 electrodes = std::vector<int16_t>(btac.
electrodes);
255 pac_vector_ = std::vector<int16_t>(btac.
pac_vector_);
256 pac_buffer_ = boost::circular_buffer<int16_t>(btac.
pac_buffer_);
267 pac_buffer_ = boost::circular_buffer<int16_t>(pac_size_);
268 pac_vector_.reserve(pac_size_);
275 std::vector<int16_t>
get_pac(
bool consume =
false)
278 pac_vector_.insert(pac_vector_.begin(), pac_buffer_.begin(), pac_buffer_.end());
288 return get_pac(
true);
301 static const size_t pac_size_ = 270;
325 for (
unsigned int i = 0; i < ubi0.
distal.size(); i++)
327 distal[i] = ubi0.
distal[i];
329 for (
unsigned int i = 0; i < ubi0.
middle.size(); i++)
331 middle[i] = ubi0.
middle[i];
333 for (
unsigned int i = 0; i < ubi0.
proximal.size(); i++)
354 boost::array<uint16_t, 12ul>
distal;
368 for (
unsigned int i = 0; i < ubi0.
palm.size(); i++)
370 palm[i] = ubi0.
palm[i];
378 boost::array<uint16_t, 16ul>
palm;
boost::array< uint16_t, 4ul > middle
GenericTactileData(bool tactile_data_valid, int sample_frequency, std::string manufacturer, std::string serial_number, int software_version_current, int software_version_server, bool software_version_modified, std::string pcb_version)
UBI0PalmData(const UBI0PalmData &ubi0)
BiotacData(const GenericTactileData >d)
virtual ~GenericTactileData()
int software_version_current
double convertToInt(std::string const &s)
std::vector< int16_t > electrodes
std::vector< int16_t > pac_vector_
PST3Data(const GenericTactileData >d)
BiotacData(const BiotacData &btac)
boost::array< uint16_t, 16ul > palm
std::vector< int16_t > consume_pac()
boost::array< uint16_t, 12ul > distal
void set_software_version(std::string version)
bool software_version_modified
UBI0Data(const GenericTactileData >d)
PST3Data(const PST3Data &pst3)
boost::array< uint16_t, 4ul > proximal
UBI0Data(const UBI0Data &ubi0)
std::string serial_number
virtual std::string get_software_version()
virtual std::string get_software_version()
std::vector< int16_t > get_pac(bool consume=false)
boost::circular_buffer< int16_t > pac_buffer_
int software_version_server