RokubiminiEthercat.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 #include <utility>
6 #include <rokubimini_msgs/FirmwareUpdateEthercat.h>
7 #include <rokubimini_msgs/ResetWrench.h>
8 #include <Eigen/Dense>
9 namespace rokubimini
10 {
11 namespace ethercat
12 {
26 {
27 public:
36  RokubiminiEthercat() = default;
37 
44  RokubiminiEthercat(const std::string& name, NodeHandlePtr nh) : Rokubimini(name, std::move(nh)){ /* do nothing */ };
45  // RokubiminiEthercat() = default;
46  ~RokubiminiEthercat() override = default;
47 
55  void preSetupConfiguration() override;
56 
65  void postSetupConfiguration() override;
66 
76  void updateProcessReading() override;
77 
85  bool deviceIsMissing() const override;
86 
98  void shutdownWithCommunication() override;
99 
115  {
116  slavePtr_ = slavePtr;
117  }
118 
129  void setState(const uint16_t state)
130  {
131  slavePtr_->setState(state);
132  }
133 
144  bool waitForState(const uint16_t state)
145  {
146  return slavePtr_->waitForState(state);
147  }
148 
159  // Missing: Methods for calling SDO
160  bool getSerialNumber(unsigned int& samplingRate) override;
161 
174  bool getForceTorqueSamplingRate(int& samplingRate) override;
175 
188  bool setForceTorqueFilter(const configuration::ForceTorqueFilter& filter) override;
189 
201  bool setAccelerationFilter(const unsigned int filter) override;
202 
214  bool setAngularRateFilter(const unsigned int filter) override;
215 
227  bool setAccelerationRange(const unsigned int range) override;
228 
240  bool setAngularRateRange(const unsigned int range) override;
241 
253  bool setForceTorqueOffset(const Eigen::Matrix<double, 6, 1>& forceTorqueOffset) override;
254 
266  bool setSensorConfiguration(const configuration::SensorConfiguration& sensorConfiguration) override;
267 
279  bool setSensorCalibration(const calibration::SensorCalibration& sensorCalibration) override;
280 
288  bool setConfigMode();
289 
297  bool setRunMode();
307  bool saveConfigParameter() override;
308 
315  void createRosPublishers() override;
316 
323  void signalShutdown();
324 
335  bool firmwareUpdateCallback(rokubimini_msgs::FirmwareUpdateEthercat::Request& request,
336  rokubimini_msgs::FirmwareUpdateEthercat::Response& response);
337 
348  bool resetWrenchCallback(rokubimini_msgs::ResetWrench::Request& request,
349  rokubimini_msgs::ResetWrench::Response& response);
356  void createRosServices() override;
357 
365  void publishRosMessages() override;
366 
373  void createRosDiagnostics() override;
374 
381  void publishRosDiagnostics() override;
382 
390 
404  void setRunsAsync(bool runsAsync);
405 
415 
424  void publishDataFlagsDiagnostics(const ros::TimerEvent& event);
425 
426  template <typename Value>
427  bool sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess, Value& value);
428 
442  bool sendSdoReadGeneric(const std::string& indexString, const std::string& subindexString,
443  const std::string& valueTypeString, std::string& valueString);
444 
458  template <typename Value>
459  bool sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess, const Value value);
460 
475  bool sendSdoWriteGeneric(const std::string& indexString, const std::string& subindexString,
476  const std::string& valueTypeString, const std::string& valueString);
477 
478 protected:
487 
488  using RosPublisherPtr = std::shared_ptr<ros::Publisher>;
489 
498 
506 
514 
522 
530 
538 
546  std::atomic<bool> computeMeanWrenchFlag_{ false };
547 
555  std::atomic<uint32_t> wrenchMessageCount_{ 0 };
556 
563  mutable std::recursive_mutex meanWrenchOffsetMutex_;
564 
573 
580  Eigen::Matrix<double, 6, Eigen::Dynamic> resetServiceWrenchSamples_;
581 };
582 
583 template <>
584 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
585  int8_t& value);
586 template <>
587 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
588  int16_t& value);
589 template <>
590 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
591  int32_t& value);
592 template <>
593 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
594  int64_t& value);
595 template <>
596 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
597  uint8_t& value);
598 template <>
599 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
600  uint16_t& value);
601 template <>
602 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
603  uint32_t& value);
604 template <>
605 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
606  uint64_t& value);
607 template <>
608 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
609  float& value);
610 template <>
611 bool RokubiminiEthercat::sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess,
612  double& value);
613 
614 template <>
615 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
616  const int8_t value);
617 template <>
618 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
619  const int16_t value);
620 template <>
621 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
622  const int32_t value);
623 template <>
624 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
625  const int64_t value);
626 template <>
627 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
628  const uint8_t value);
629 template <>
630 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
631  const uint16_t value);
632 template <>
633 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
634  const uint32_t value);
635 template <>
636 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
637  const uint64_t value);
638 template <>
639 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
640  const float value);
641 template <>
642 bool RokubiminiEthercat::sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess,
643  const double value);
644 
645 } // namespace ethercat
646 } // namespace rokubimini
void shutdownWithCommunication() override
Shuts down a Rokubimini Ethercat device before communication has been closed.
void preSetupConfiguration() override
Pre-setup configuration hook.
void setState(const uint16_t state)
Sets the desired EtherCAT state machine state of the device in the bus.
void postSetupConfiguration() override
Post-setup configuration hook.
void createRosDiagnostics() override
Adds ROS diagnostics related to the operation of rokubimini.
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.
void updateConnectionStatus(diagnostic_updater::DiagnosticStatusWrapper &stat)
Shows the Device Status of the rokubimini.
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.
RokubiminiEthercat(const std::string &name, NodeHandlePtr nh)
void signalShutdown()
Signals shutdown for the ROS node. It&#39;s used if a firmware update was successful. ...
unsigned short uint16_t
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.
unsigned char uint8_t
bool setForceTorqueOffset(const Eigen::Matrix< double, 6, 1 > &forceTorqueOffset) override
Sets a force torque offset to the device.
bool setForceTorqueFilter(const configuration::ForceTorqueFilter &filter) override
Sets a force torque filter to the device.
void publishConnectionStatusDiagnostics()
Publishes the Connection Status Diagnostics to the "/diagnostics" topic.
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.
bool getForceTorqueSamplingRate(int &samplingRate) override
Gets the force torque sampling rate of the device.
unsigned int uint32_t
signed short int16_t
ros::ServiceServer resetWrenchService_
The service for resetting the sensor wrench measurements.
bool waitForState(const uint16_t state)
Wait for an EtherCAT state machine state to be reached.
std::shared_ptr< ros::Publisher > RosPublisherPtr
unsigned __int64 uint64_t
void publishRosDiagnostics() override
Publish ROS diagnostics related to the operation of rokubimini.
void publishDataFlagsDiagnostics(const ros::TimerEvent &event)
Publishes the Data Flags Diagnostics to the "/diagnostics" topic.
RokubiminiEthercat()=default
Default constructor.
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.
signed char int8_t
void createRosServices() override
Adds ROS services related to the device.
std::shared_ptr< RokubiminiEthercatSlave > RokubiminiEthercatSlavePtr
bool setConfigMode()
Sets the device in config mode.
bool setRunMode()
Sets the device in run mode.
void setSlavePointer(const RokubiminiEthercatSlavePtr &slavePtr)
Sets a pointer to the implementation.
std::atomic< bool > computeMeanWrenchFlag_
The flag for enabling the computation of the mean of the wrench measurements. Used withing the "reset...
std::recursive_mutex meanWrenchOffsetMutex_
The mutex for accessing the mean of the wrench measurements. Used for the "reset service" callback...
Eigen::Matrix< double, 6, Eigen::Dynamic > resetServiceWrenchSamples_
The wrench samples used by the "reset service" callback for calculating the mean wrench offset...
RosPublisherPtr wrenchPublisher_
The sensor_msgs::Wrench publisher.
ros::ServiceServer firmwareUpdateService_
The service for firmware updates.
bool deviceIsMissing() const override
Checks if the device is missing.
signed __int64 int64_t
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)
signed int int32_t
void publishRosMessages() override
Publishes ROS messages with data from the rokubimini device.
const std::string response
bool setAngularRateRange(const unsigned int range) override
Sets an angular rate range to the device.
std::shared_ptr< ros::NodeHandle > NodeHandlePtr


rokubimini_ethercat
Author(s):
autogenerated on Sat Apr 15 2023 02:51:33