2 #include <rokubimini_msgs/Reading.h> 75 return slavePtr_->getSerialNumber(serialNumber);
80 return slavePtr_->getForceTorqueSamplingRate(samplingRate);
85 return slavePtr_->setForceTorqueFilter(filter);
90 return slavePtr_->setAccelerationFilter(filter);
95 return slavePtr_->setAngularRateFilter(filter);
100 return slavePtr_->setAccelerationRange(range);
105 return slavePtr_->setAngularRateRange(range);
110 return slavePtr_->setForceTorqueOffset(forceTorqueOffset);
115 if (!
slavePtr_->setSensorConfiguration(sensorConfiguration))
125 if (!
slavePtr_->setSensorCalibration(sensorCalibration))
155 nh_->getNamespace() +
"/" +
getName() +
"/ft_sensor_readings/reading", 10,
false));
158 nh_->getNamespace() +
"/" +
getName() +
"/ft_sensor_readings/wrench", 10,
false));
164 nh_->getNamespace() +
"/" +
getName() +
"/ft_sensor_readings/temperature", 10,
false));
170 rokubimini_msgs::Reading reading_msg;
171 reading_msg.header.stamp = reading.getWrench().header.stamp;
173 reading_msg.statusword = reading.getStatusword().getData();
174 reading_msg.imu = reading.getImu();
175 reading_msg.wrench = reading.getWrench();
176 reading_msg.externalImu = reading.getExternalImu();
177 reading_msg.isForceTorqueSaturated = reading.isForceTorqueSaturated();
178 reading_msg.temperature = reading.getTemperature();
207 std::this_thread::sleep_for(std::chrono::microseconds(500));
208 kill(getpid(), SIGINT);
212 rokubimini_msgs::FirmwareUpdateEthercat::Response& response)
214 response.result =
slavePtr_->firmwareUpdate(request.file_path, request.file_name, request.password);
219 shutdown_thread.detach();
225 rokubimini_msgs::ResetWrench::Response& response)
227 ROS_INFO(
"[%s] Reseting sensor measurements...",
name_.c_str());
246 ROS_ERROR(
"[%s] Device could not switch to config mode",
name_.c_str());
247 response.success =
false;
250 geometry_msgs::Wrench wrench;
256 geometry_msgs::Wrench desired_wrench = request.desired_wrench;
258 Eigen::Matrix<double, 6, 1> new_offset;
260 new_offset(0, 0) = desired_wrench.force.x - wrench.force.x + current_offset(0, 0);
261 new_offset(1, 0) = desired_wrench.force.y - wrench.force.y + current_offset(1, 0);
262 new_offset(2, 0) = desired_wrench.force.z - wrench.force.z + current_offset(2, 0);
263 new_offset(3, 0) = desired_wrench.torque.x - wrench.torque.x + current_offset(3, 0);
264 new_offset(4, 0) = desired_wrench.torque.y - wrench.torque.y + current_offset(4, 0);
265 new_offset(5, 0) = desired_wrench.torque.z - wrench.torque.z + current_offset(5, 0);
267 <<
"New offset is: " << new_offset);
270 ROS_ERROR(
"[%s] Could not write new offset to device",
name_.c_str());
271 response.success =
false;
276 ROS_ERROR(
"[%s] Device could not switch to run mode",
name_.c_str());
277 response.success =
false;
280 response.success =
true;
282 ROS_INFO(
"[%s] Sensor measurements are reset successfully",
name_.c_str());
293 const std::string& valueTypeString, std::string& valueString)
295 return slavePtr_->sendSdoReadGeneric(indexString, subindexString, valueTypeString, valueString);
299 const std::string& valueTypeString,
const std::string& valueString)
301 return slavePtr_->sendSdoWriteGeneric(indexString, subindexString, valueTypeString, valueString);
308 return slavePtr_->sendSdoReadInt8(index, subindex, completeAccess, value);
315 return slavePtr_->sendSdoReadInt16(index, subindex, completeAccess, value);
322 return slavePtr_->sendSdoReadInt32(index, subindex, completeAccess, value);
329 return slavePtr_->sendSdoReadInt64(index, subindex, completeAccess, value);
336 return slavePtr_->sendSdoReadUInt8(index, subindex, completeAccess, value);
343 return slavePtr_->sendSdoReadUInt16(index, subindex, completeAccess, value);
350 return slavePtr_->sendSdoReadUInt32(index, subindex, completeAccess, value);
357 return slavePtr_->sendSdoReadUInt64(index, subindex, completeAccess, value);
364 return slavePtr_->sendSdoReadFloat(index, subindex, completeAccess, value);
371 return slavePtr_->sendSdoReadDouble(index, subindex, completeAccess, value);
378 return slavePtr_->sendSdoWriteInt8(index, subindex, completeAccess, value);
385 return slavePtr_->sendSdoWriteInt16(index, subindex, completeAccess, value);
392 return slavePtr_->sendSdoWriteInt32(index, subindex, completeAccess, value);
399 return slavePtr_->sendSdoWriteInt64(index, subindex, completeAccess, value);
406 return slavePtr_->sendSdoWriteUInt8(index, subindex, completeAccess, value);
413 return slavePtr_->sendSdoWriteUInt16(index, subindex, completeAccess, value);
420 return slavePtr_->sendSdoWriteUInt32(index, subindex, completeAccess, value);
427 return slavePtr_->sendSdoWriteUInt64(index, subindex, completeAccess, value);
434 return slavePtr_->sendSdoWriteFloat(index, subindex, completeAccess, value);
441 return slavePtr_->sendSdoWriteDouble(index, subindex, completeAccess, value);
void shutdownWithCommunication() override
Shuts down a Rokubimini Ethercat device before communication has been closed.
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.
void createRosPublishers() override
Adds ROS publishers related to the device.
RokubiminiEthercatSlavePtr slavePtr_
The pointer to implementation.
bool saveConfigParameter() override
Saves the current configuration to the device.
bool sendSdoReadGeneric(const std::string &indexString, const std::string &subindexString, const std::string &valueTypeString, std::string &valueString)
Sends a generic reading SDO to the Ethercat device.
geometry_msgs::WrenchStamped RokubiminiWrenchRos
void setStatusword(Statusword &statusword)
void signalShutdown()
Signals shutdown for the ROS node. It's used if a firmware update was successful. ...
bool setAccelerationRange(const unsigned int range) override
Sets an acceleration range to the device.
bool resetWrenchCallback(rokubimini_msgs::ResetWrench::Request &request, rokubimini_msgs::ResetWrench::Response &response)
The callback for the reset wrench ROS service.
void setSensorConfiguration(const SensorConfiguration &sensorConfiguration)
bool setForceTorqueOffset(const Eigen::Matrix< double, 6, 1 > &forceTorqueOffset) override
Sets a force torque offset to the device.
const Eigen::Matrix< double, 6, 1 > & getForceTorqueOffset() const
bool setForceTorqueFilter(const configuration::ForceTorqueFilter &filter) override
Sets a force torque filter to the device.
sensor_msgs::Temperature RokubiminiTemperatureRos
bool sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess, const Value value)
RosPublisherPtr readingPublisher_
The rokubimini_msgs::Reading publisher.
bool setSensorCalibration(const calibration::SensorCalibration &sensorCalibration) override
Sets a sensor calibration to the device.
bool setSensorConfiguration(const configuration::SensorConfiguration &sensorConfiguration) override
Sets a sensor configuration to the device.
bool firmwareUpdateCallback(rokubimini_msgs::FirmwareUpdateEthercat::Request &request, rokubimini_msgs::FirmwareUpdateEthercat::Response &response)
The callback for the firmware update ROS service.
void updateProcessReading() override
Updates the RokubiminiEthercat object with new measurements.
bool setAngularRateFilter(const unsigned int filter) override
Sets an angular rate filter to the device.
bool setAccelerationFilter(const unsigned int filter) override
Sets an acceleration filter to the device.
RosPublisherPtr imuPublisher_
The sensor_msgs::Imu publisher.
std::string getName() const
bool getForceTorqueSamplingRate(int &samplingRate) override
Gets the force torque sampling rate of the device.
rokubimini_msgs::Reading RokubiminiReadingRos
sensor_msgs::Imu RokubiminiImuRos
ros::ServiceServer resetWrenchService_
The service for resetting the sensor wrench measurements.
configuration::Configuration configuration_
unsigned __int64 uint64_t
bool sendSdoWriteGeneric(const std::string &indexString, const std::string &subindexString, const std::string &valueTypeString, const std::string &valueString)
Sends a generic write SDO to the Ethercat device.
static const uint32_t TOTAL_NUMBER_OF_WRENCH_MESSAGES
void createRosServices() override
Adds ROS services related to the device.
bool setConfigMode()
Sets the device in config mode.
std::atomic< bool > statuswordRequested_
bool setRunMode()
Sets the device in run mode.
void setSensorCalibration(const calibration::SensorCalibration &sensorCalibration)
std::atomic< bool > computeMeanWrenchFlag_
The flag for enabling the computation of the mean of the wrench measurements. Used withing the "reset...
#define ROS_DEBUG_STREAM(args)
void doStartupWithCommunication() override
std::recursive_mutex meanWrenchOffsetMutex_
The mutex for accessing the mean of the wrench measurements. Used for the "reset service" callback...
RosPublisherPtr wrenchPublisher_
The sensor_msgs::Wrench publisher.
Reading getReading() const
ros::ServiceServer firmwareUpdateService_
The service for firmware updates.
bool deviceIsMissing() const override
Checks if the device is missing.
const Statusword & getStatusword() const
void setForceTorqueOffset(const Eigen::Matrix< double, 6, 1 > &forceTorqueOffset)
std::multimap< int, ReadingCb, std::greater< int > > readingCbs_
bool getSerialNumber(unsigned int &samplingRate) override
Gets the serial number of the device.
RosPublisherPtr temperaturePublisher_
The sensor_msgs::Temperature publisher.
bool sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess, Value &value)
configuration::Configuration & getConfiguration()
std::recursive_mutex readingMutex_
geometry_msgs::Wrench meanWrenchOffset_
The computed mean wrench offset. Used for the "reset service" callback.
void publishRosMessages() override
Publishes ROS messages with data from the rokubimini device.
bool setAngularRateRange(const unsigned int range) override
Sets an angular rate range to the device.