yarp-devices
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
roboticslab::Jr3Mbed Class Reference

Implementation of a CAN node on an Mbed board that publishes data from a JR3 sensor.

#include <Jr3Mbed.hpp>

Inheritance diagram for roboticslab::Jr3Mbed:
roboticslab::ICanBusSharer roboticslab::ICanMessageNotifier

Public Member Functions

bool open (yarp::os::Searchable &config) override
 
bool close () override
 
unsigned int getId () override
 Retrieve CAN node ID.
 
bool notifyMessage (const can_message &message) override
 Notify observers that a new CAN message has arrived.
 
bool initialize () override
 Perform CAN node initialization.
 
bool finalize () override
 Finalize CAN node communications.
 
bool registerSender (ICanSenderDelegate *sender) override
 Pass a handle to a CAN sender delegate instance.
 
bool synchronize (double timestamp) override
 Perform synchronized action on CAN master's request.
 
std::size_t getNrOfSixAxisForceTorqueSensors () const override
 
yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus (std::size_t sens_index) const override
 
bool getSixAxisForceTorqueSensorName (std::size_t sens_index, std::string &name) const override
 
bool getSixAxisForceTorqueSensorFrameName (std::size_t sens_index, std::string &name) const override
 
bool getSixAxisForceTorqueSensorMeasure (std::size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
 
- Public Member Functions inherited from roboticslab::ICanBusSharer
virtual ~ICanBusSharer ()=default
 Destructor.
 
virtual std::vector< unsigned int > getAdditionalIds ()
 Retrieve more associated CAN node IDs, if any.
 
- Public Member Functions inherited from roboticslab::ICanMessageNotifier
virtual ~ICanMessageNotifier ()=default
 Virtual destructor.
 

Private Types

enum class  can_ops : std::uint16_t {
  ACK = 0x100 , START_SYNC = 0x180 , START_ASYNC = 0x200 , STOP = 0x280 ,
  ZERO_OFFS = 0x300 , SET_FILTER = 0x380 , GET_STATE = 0x400 , GET_FS_FORCES = 0x480 ,
  GET_FS_MOMENTS = 0x500 , RESET = 0x580 , FORCES = 0x600 , MOMENTS = 0x680 ,
  BOOTUP = 0x700
}
 
enum class  jr3_state : std::uint8_t { READY = 0x00 , NOT_INITIALIZED = 0x01 }
 
enum class  jr3_mode { SYNC , ASYNC , INVALID }
 

Private Member Functions

constexpr unsigned int getCommandId (can_ops op) const
 
bool performRequest (const std::string &cmd, const can_message &msg, std::uint8_t *response, bool quiet=false)
 
bool sendStartSyncCommand (double filter)
 
bool sendStartAsyncCommand (double filter, double delay)
 
bool sendCommand (const std::string &cmd, can_ops op)
 
bool ping ()
 
bool queryFullScales ()
 
bool monitorWorker (const yarp::os::YarpTimerEvent &event)
 

Private Attributes

unsigned int canId {0}
 
double filter {0.0}
 
double asyncPeriod {0.0}
 
std::string name
 
std::array< double, 6 > scales
 
bool shouldQueryFullScales {false}
 
jr3_mode mode {jr3_mode::INVALID}
 
ICanSenderDelegatesender {nullptr}
 
TypedStateObserver< std::uint8_t[]> * ackStateObserver {nullptr}
 
std::mutex mtx
 
std::array< std::int16_t, 3 > buffer {}
 
std::array< std::int16_t, 6 > raw {}
 
std::atomic< yarp::dev::MAS_status > status {yarp::dev::MAS_UNKNOWN}
 
std::atomic_bool isBooting {false}
 
double timestamp {0.0}
 
std::uint16_t frameCounter {0}
 
double diagnosticsPeriod {0.0}
 
double lastDiagnosticsTimestamp {0.0}
 
unsigned int lastFrameCounter {0}
 
yarp::os::Timer * monitorThread {nullptr}
 

Static Private Attributes

static constexpr unsigned int FULL_SCALE = 16384
 

The documentation for this class was generated from the following files: