RokubiminiSerial.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 #include <rokubimini_msgs/FirmwareUpdateSerial.h>
6 #include <rokubimini_msgs/ResetWrench.h>
7 #include <geometry_msgs/Wrench.h>
8 
9 namespace rokubimini
10 {
11 namespace serial
12 {
26 {
27 public:
35  RokubiminiSerial() = default;
36  ~RokubiminiSerial() override = default;
37 
47  void doStartupWithCommunication() override;
48 
58  bool init();
59 
69  void updateProcessReading() override;
70 
78  bool deviceIsMissing() const override;
79 
91  void shutdownWithCommunication() override;
92 
108  {
109  implPtr_ = implPtr;
110  }
111 
121  void setState(const uint16_t state)
122  {
123  implPtr_->setState(state);
124  }
125 
136  bool waitForState(const uint16_t state)
137  {
138  return implPtr_->waitForState(state);
139  }
140 
152  // Missing: Methods for calling SDO
153  bool getSerialNumber(unsigned int& serialNumber) override;
154 
167  bool getForceTorqueSamplingRate(int& samplingRate) override;
168 
181  bool setForceTorqueFilter(const configuration::ForceTorqueFilter& filter) override;
182 
194  bool setAccelerationFilter(const unsigned int filter) override;
195 
207  bool setAngularRateFilter(const unsigned int filter) override;
208 
220  bool setAccelerationRange(const unsigned int range) override;
221 
233  bool setAngularRateRange(const unsigned int range) override;
234 
246  bool setForceTorqueOffset(const Eigen::Matrix<double, 6, 1>& forceTorqueOffset) override;
247 
259  bool setSensorConfiguration(const configuration::SensorConfiguration& sensorConfiguration) override;
260 
272  bool setSensorCalibration(const calibration::SensorCalibration& sensorCalibration) override;
273 
281  bool setConfigMode();
282 
290  bool setRunMode();
291 
300  bool setHardwareReset();
301 
310  bool setInitMode();
311 
321  bool saveConfigParameter() override;
322 
330  bool loadConfig();
331 
339  bool printUserConfig();
340 
347  void createRosPublishers() override;
348 
355  void signalShutdown();
356 
367  bool firmwareUpdateCallback(rokubimini_msgs::FirmwareUpdateSerial::Request& request,
368  rokubimini_msgs::FirmwareUpdateSerial::Response& response);
369 
380  bool resetWrenchCallback(rokubimini_msgs::ResetWrench::Request& request,
381  rokubimini_msgs::ResetWrench::Response& response);
388  void createRosServices() override;
389 
397  void publishRosMessages() override;
398 
399 protected:
408 
409  using RosPublisherPtr = std::shared_ptr<ros::Publisher>;
418 
426 
434 
442 
450 
457  uint64_t noFrameSyncCounter_{ 0 };
458 
466  std::atomic<bool> computeMeanWrenchFlag_{ false };
467 
475  std::atomic<uint32_t> wrenchMessageCount_{ 0 };
476 
483  mutable std::recursive_mutex meanWrenchOffsetMutex_;
484 
492  const static uint32_t TOTAL_NUMBER_OF_WRENCH_MESSAGES = 200;
493 
500  geometry_msgs::Wrench meanWrenchOffset_;
501 };
502 
503 } // namespace serial
504 } // namespace rokubimini
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 setState(const uint16_t state)
Sets the state of the device in the bus (unused).
std::shared_ptr< ros::Publisher > RosPublisherPtr
bool setInitMode()
Triggers a software reset of the sensor bringing it to a known state.
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.
bool setHardwareReset()
Triggers a hardware reset of the sensor.
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.
void setImplPointer(const RokubiminiSerialImplPtr &implPtr)
Sets a pointer to the implementation.
static const uint32_t TOTAL_NUMBER_OF_WRENCH_MESSAGES
The Rokubimini Serial class.
bool waitForState(const uint16_t state)
Wait for a state to be reached (unused).
RosPublisherPtr readingPublisher_
The rokubimini_msgs::Reading publisher.
RokubiminiSerial()=default
Default constructor.
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.
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.
bool init()
Initializes communication with a Rokubimini Serial device.
bool setAngularRateFilter(const unsigned int filter) override
Sets an angular rate filter to the device.
std::shared_ptr< RokubiminiSerialImpl > RokubiminiSerialImplPtr
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.
RosPublisherPtr wrenchPublisher_
The sensor_msgs::Wrench publisher.
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.
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.
bool setConfigMode()
Sets the device in config mode.
void shutdownWithCommunication() override
Shuts down a Rokubimini Serial device before communication has been closed.
void signalShutdown()
Signals shutdown for the ROS node. It&#39;s used if a firmware update was successful. ...
System dependencies.
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.


rokubimini_serial
Author(s):
autogenerated on Wed Mar 3 2021 03:09:18