28 #include <sr_utilities/sr_math_utils.hpp> 37 #define TACTILE_DATA_LENGTH_BYTES TACTILE_DATA_LENGTH_BYTES_v1 41 template<
class StatusType,
class CommandType>
44 template<
class StatusType,
class CommandType>
45 GenericTactiles<StatusType,
47 std::vector<generic_updater::UpdateConfig> update_configs_vector,
56 reset_service_client_ = nodehandle_.advertiseService(
"tactiles/reset", &GenericTactiles::reset,
this);
61 new std::vector<GenericTactileData>(nb_tactiles));
64 for (
unsigned int i = 0; i < nb_tactiles; i++)
66 GenericTactileData tmp_pst;
67 tactiles_vector->push_back(tmp_pst);
71 template<
class StatusType,
class CommandType>
74 int tactile_mask =
static_cast<int16u>(status_data->tactile_data_valid);
76 for (
unsigned int id_sensor = 0; id_sensor < nb_tactiles; ++id_sensor)
78 ROS_DEBUG_STREAM(
" received: " << static_cast<int32u>(status_data->tactile_data_type));
80 switch (static_cast<int32u>(status_data->tactile_data_type))
84 if (sr_math_utils::is_bit_mask_index_true(tactile_mask, id_sensor))
86 if (tactiles_vector != NULL)
88 tactiles_vector->at(id_sensor).which_sensor =
89 static_cast<unsigned int>(
static_cast<int16u>(status_data->tactile[id_sensor].word[0]));
91 ROS_DEBUG_STREAM(
" tact[" << id_sensor <<
"] = " << tactiles_vector->at(id_sensor).which_sensor);
96 if (sr_math_utils::is_bit_mask_index_true(tactile_mask, id_sensor))
98 if (tactiles_vector != NULL)
100 tactiles_vector->at(id_sensor).sample_frequency =
101 static_cast<unsigned int>(
static_cast<int16u>(status_data->tactile[id_sensor].word[0]));
108 if (sr_math_utils::is_bit_mask_index_true(tactile_mask, id_sensor))
110 tactiles_vector->at(id_sensor).manufacturer = sanitise_string(status_data->tactile[id_sensor].string,
118 if (sr_math_utils::is_bit_mask_index_true(tactile_mask, id_sensor))
120 tactiles_vector->at(id_sensor).serial_number = sanitise_string(status_data->tactile[id_sensor].string,
127 if (sr_math_utils::is_bit_mask_index_true(tactile_mask, id_sensor))
129 if (tactiles_vector != NULL)
131 tactiles_vector->at(id_sensor).set_software_version(status_data->tactile[id_sensor].string);
137 if (sr_math_utils::is_bit_mask_index_true(tactile_mask, id_sensor))
139 if (tactiles_vector != NULL)
141 tactiles_vector->at(id_sensor).pcb_version = sanitise_string(status_data->tactile[id_sensor].string,
154 process_received_data_type(static_cast<int32u>(status_data->tactile_data_type));
155 if (sensor_updater->initialization_configs_vector.size() == 0)
162 template<
class StatusType,
class CommandType>
166 for (i = 0; i < sensor_updater->initialization_configs_vector.size(); i++)
168 if (sensor_updater->initialization_configs_vector[i].what_to_update == data)
173 if (i < sensor_updater->initialization_configs_vector.size())
175 sensor_updater->initialization_configs_vector.erase(sensor_updater->initialization_configs_vector.begin() + i);
179 template<
class StatusType,
class CommandType>
185 template<
class StatusType,
class CommandType>
200 template<
class StatusType,
class CommandType>
202 std_srvs::Empty::Response &response)
206 return sensor_updater->reset();
209 template<
class StatusType,
class CommandType>
211 const unsigned int str_size)
213 std::string sanitised_string =
"";
214 for (
unsigned int i = 0; i < str_size; ++i)
216 char tmp =
static_cast<char>(raw_string[i]);
219 if (tmp >=
'\x20' && tmp <=
'\x7E')
221 sanitised_string +=
static_cast<char>(raw_string[i]);
225 sanitised_string +=
'?';
233 return sanitised_string;
236 template<
class StatusType,
class CommandType>
239 return all_tactile_data.get();
TACTILE_SENSOR_TYPE_SOFTWARE_VERSION
TACTILE_SENSOR_TYPE_MANUFACTURER
static const unsigned int nb_tactiles
Number of tactile sensors (TODO: should probably be defined in the protocol)
TACTILE_SENSOR_TYPE_SERIAL_NUMBER
TACTILE_SENSOR_TYPE_PCB_VERSION
#define ROS_DEBUG_STREAM(args)
TACTILE_SENSOR_TYPE_WHICH_SENSORS
TACTILE_SENSOR_TYPE_SAMPLE_FREQUENCY_HZ
#define ROS_INFO_STREAM(args)
#define TACTILE_DATA_LENGTH_BYTES