2 #include <rokubimini_msgs/Reading.h> 25 if (!
nh_->getParam(
"time_step", time_step))
27 ROS_ERROR(
"[%s] Failed to retrieve 'time_step' parameter",
name_.c_str());
30 implPtr_->setPollingTimeStep(time_step);
100 return implPtr_->getSerialNumber(serialNumber);
105 return implPtr_->getForceTorqueSamplingRate(samplingRate);
110 return implPtr_->setForceTorqueFilter(filter);
115 return implPtr_->setAccelerationFilter(filter);
120 return implPtr_->setAngularRateFilter(filter);
125 return implPtr_->setAccelerationRange(range);
130 return implPtr_->setAngularRateRange(range);
135 return implPtr_->setForceTorqueOffset(forceTorqueOffset);
140 if (!
implPtr_->setSensorConfiguration(sensorConfiguration))
150 if (!
implPtr_->setSensorCalibration(sensorCalibration))
170 return implPtr_->saveConfigParameter();
185 return implPtr_->setHardwareReset();
199 nh_->getNamespace() +
"/" +
getName() +
"/ft_sensor_readings/reading", 10,
false));
202 nh_->getNamespace() +
"/" +
getName() +
"/ft_sensor_readings/wrench", 10,
false));
205 nh_->getNamespace() +
"/" +
getName() +
"/ft_sensor_readings/temperature", 10,
false));
213 rokubimini_msgs::Reading reading_msg;
214 reading_msg.header.stamp = reading.getWrench().header.stamp;
215 reading_msg.header.frame_id = reading.getWrench().header.frame_id;
216 reading_msg.statusword = reading.getStatusword().getData();
217 reading_msg.wrench = reading.getWrench();
218 reading_msg.isForceTorqueSaturated = reading.isForceTorqueSaturated();
219 reading_msg.temperature = reading.getTemperature();
258 std::this_thread::sleep_for(std::chrono::microseconds(500));
259 kill(getpid(), SIGINT);
263 rokubimini_msgs::FirmwareUpdateSerial::Response& response)
265 response.result =
implPtr_->firmwareUpdate(request.file_path);
270 shutdown_thread.detach();
276 rokubimini_msgs::ResetWrench::Response& response)
278 ROS_INFO(
"[%s] Reseting sensor measurements...",
name_.c_str());
298 ROS_ERROR(
"[%s] Device could not switch to config mode",
name_.c_str());
299 response.success =
false;
302 geometry_msgs::Wrench wrench;
309 geometry_msgs::Wrench desired_wrench = request.desired_wrench;
311 Eigen::Matrix<double, 6, 1> new_offset;
313 new_offset(0, 0) = desired_wrench.force.x - wrench.force.x + current_offset(0, 0);
314 new_offset(1, 0) = desired_wrench.force.y - wrench.force.y + current_offset(1, 0);
315 new_offset(2, 0) = desired_wrench.force.z - wrench.force.z + current_offset(2, 0);
316 new_offset(3, 0) = desired_wrench.torque.x - wrench.torque.x + current_offset(3, 0);
317 new_offset(4, 0) = desired_wrench.torque.y - wrench.torque.y + current_offset(4, 0);
318 new_offset(5, 0) = desired_wrench.torque.z - wrench.torque.z + current_offset(5, 0);
320 <<
"New offset is: " << new_offset);
323 ROS_ERROR(
"[%s] Could not write new offset to device",
name_.c_str());
324 response.success =
false;
329 ROS_ERROR(
"[%s] Device could not switch to run mode",
name_.c_str());
330 response.success =
false;
333 response.success =
true;
335 ROS_INFO(
"[%s] Sensor measurements are reset successfully",
name_.c_str());
bool getSerialNumber(unsigned int &serialNumber) override
Gets the serial number of the device.
void publishRosMessages() override
Publishes ROS messages with data from the rokubimini device.
uint64_t noFrameSyncCounter_
The counter for measuring failed frame synchronizations.
std::atomic< bool > computeMeanWrenchFlag_
The flag for enabling the computation of the mean of the wrench measurements. Used withing the "reset...
RosPublisherPtr temperaturePublisher_
The sensor_msgs::Temperature publisher.
bool setAngularRateRange(const unsigned int range) override
Sets an angular rate range to the device.
bool saveConfigParameter() override
Saves the current configuration to the device.
bool firmwareUpdateCallback(rokubimini_msgs::FirmwareUpdateSerial::Request &request, rokubimini_msgs::FirmwareUpdateSerial::Response &response)
The callback for the firmware update ROS service.
void setStatusword(Statusword &statusword)
bool setInitMode()
Triggers a software reset of the sensor bringing it to a known state.
void setSensorConfiguration(const SensorConfiguration &sensorConfiguration)
void doStartupWithCommunication() override
Starts up a Rokubimini Serial device after communication has been established.
bool setAccelerationFilter(const unsigned int filter) override
Sets an acceleration filter to the device.
const Eigen::Matrix< double, 6, 1 > & getForceTorqueOffset() const
bool setHardwareReset()
Triggers a hardware reset of the sensor.
sensor_msgs::Temperature RokubiminiTemperatureRos
bool loadConfig()
Loads the configuration of the device.
ros::ServiceServer firmwareUpdateService_
The service for firmware updates.
bool printUserConfig()
Prints all the user configurable parameters.
void createRosServices() override
Adds ROS services related to the device.
static const uint32_t TOTAL_NUMBER_OF_WRENCH_MESSAGES
rokubimini_msgs::Reading RokubiminiReadingRos
#define ROS_ERROR_THROTTLE(rate,...)
RosPublisherPtr readingPublisher_
The rokubimini_msgs::Reading publisher.
std::string getName() const
void updateProcessReading() override
Updates the RokubiminiSerial object with new measurements.
bool getForceTorqueSamplingRate(int &samplingRate) override
Gets the force torque sampling rate of the device.
void createRosPublishers() override
Adds ROS publishers related to the device.
bool setForceTorqueFilter(const configuration::ForceTorqueFilter &filter) override
Sets a force torque filter to the device.
configuration::Configuration configuration_
bool setSensorConfiguration(const configuration::SensorConfiguration &sensorConfiguration) override
Sets a sensor configuration to the device.
std::atomic< uint32_t > wrenchMessageCount_
The counter that is used for the computation of the mean of the wrench measurements. Used for the "reset service" callback.
const calibration::SensorCalibration & getSensorCalibration() const
bool init()
Initializes communication with a Rokubimini Serial device.
std::atomic< bool > statuswordRequested_
bool setAngularRateFilter(const unsigned int filter) override
Sets an angular rate filter to the device.
void setSensorCalibration(const calibration::SensorCalibration &sensorCalibration)
geometry_msgs::WrenchStamped RokubiminiWrenchRos
#define ROS_DEBUG_STREAM(args)
std::recursive_mutex meanWrenchOffsetMutex_
The mutex for accessing the mean of the wrench measurements. Used for the "reset service" callback...
bool setSensorCalibration(const calibration::SensorCalibration &sensorCalibration) override
Sets a sensor calibration to the device.
Reading getReading() const
RosPublisherPtr wrenchPublisher_
The sensor_msgs::Wrench publisher.
const Statusword & getStatusword() const
void setForceTorqueOffset(const Eigen::Matrix< double, 6, 1 > &forceTorqueOffset)
ros::ServiceServer resetWrenchService_
The service for resetting the sensor wrench measurements.
bool setAccelerationRange(const unsigned int range) override
Sets an acceleration range to the device.
std::multimap< int, ReadingCb, std::greater< int > > readingCbs_
geometry_msgs::Wrench meanWrenchOffset_
The computed mean wrench offset. Used for the "reset service" callback.
bool resetWrenchCallback(rokubimini_msgs::ResetWrench::Request &request, rokubimini_msgs::ResetWrench::Response &response)
The callback for the reset wrench ROS service.
RokubiminiSerialImplPtr implPtr_
The pointer to implementation.
bool deviceIsMissing() const override
Checks if the device is missing.
configuration::Configuration & getConfiguration()
bool setConfigMode()
Sets the device in config mode.
const Eigen::Matrix< double, 6, 6 > & getCalibrationMatrix() const
std::recursive_mutex readingMutex_
void shutdownWithCommunication() override
Shuts down a Rokubimini Serial device before communication has been closed.
void signalShutdown()
Signals shutdown for the ROS node. It's used if a firmware update was successful. ...
bool setForceTorqueOffset(const Eigen::Matrix< double, 6, 1 > &forceTorqueOffset) override
Sets a force torque offset to the device.
bool setRunMode()
Sets the device in run mode.