32class Jr3Mbed :
public yarp::dev::DeviceDriver,
33 public yarp::dev::ISixAxisForceTorqueSensors,
40 bool open(yarp::os::Searchable & config)
override;
41 bool close()
override;
45 unsigned int getId()
override;
54 std::size_t getNrOfSixAxisForceTorqueSensors()
const override;
55 yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(std::size_t sens_index)
const override;
56 bool getSixAxisForceTorqueSensorName(std::size_t sens_index, std::string & name)
const override;
57 bool getSixAxisForceTorqueSensorFrameName(std::size_t sens_index, std::string & name)
const override;
58 bool getSixAxisForceTorqueSensorMeasure(std::size_t sens_index, yarp::sig::Vector & out,
double & timestamp)
const override;
62 enum class can_ops : std::uint16_t
71 GET_FS_FORCES = 0x480,
72 GET_FS_MOMENTS = 0x500,
80 enum class jr3_state : std::uint8_t
81 { READY = 0x00, NOT_INITIALIZED = 0x01 };
84 { SYNC, ASYNC, INVALID };
86 constexpr unsigned int getCommandId(can_ops op)
const
87 {
return m_canId +
static_cast<unsigned int>(op); }
89 bool performRequest(
const std::string & cmd,
const roboticslab::can_message & msg, std::uint8_t * response,
bool quiet =
false);
90 bool sendStartSyncCommand(
double filter);
91 bool sendStartAsyncCommand(
double filter,
double delay);
92 bool sendCommand(
const std::string & cmd, can_ops op);
94 bool queryFullScales();
96 bool monitorWorker(
const yarp::os::YarpTimerEvent & event);
98 std::array<double, 6> scales;
99 bool shouldQueryFullScales {
false};
101 jr3_mode mode {jr3_mode::INVALID};
106 mutable std::mutex mtx;
108 std::array<std::int16_t, 3> buffer {};
109 std::array<std::int16_t, 6> raw {};
111 std::atomic<yarp::dev::MAS_status> status {yarp::dev::MAS_UNKNOWN};
112 std::atomic_bool isBooting {
false};
113 double timestamp {0.0};
114 std::uint16_t frameCounter {0};
115 double lastDiagnosticsTimestamp {0.0};
116 unsigned int lastFrameCounter {0};
118 yarp::os::Timer * monitorThread {
nullptr};
120 static constexpr unsigned int FULL_SCALE = 16384;
bool notifyMessage(const roboticslab::can_message &message) override
Notify observers that a new CAN message has arrived.
Definition ICanBusSharerImpl.cpp:88
bool registerSender(roboticslab::ICanSenderDelegate *sender) override
Pass a handle to a CAN sender delegate instance.
Definition ICanBusSharerImpl.cpp:130
bool synchronize(double timestamp) override
Perform synchronized action on CAN master's request.
Definition ICanBusSharerImpl.cpp:138