3 #ifndef __CUI_ABSOLUTE_HPP__
4 #define __CUI_ABSOLUTE_HPP__
11 #include <yarp/conf/numeric.h>
13 #include <yarp/dev/DeviceDriver.h>
14 #include <yarp/dev/IEncodersTimed.h>
16 #include "ICanBusSharer.hpp"
17 #include "StateObserver.hpp"
19 #define CHECK_JOINT(j) do { int ax; if (getAxes(&ax), (j) != ax - 1) return false; } while (0)
36 public yarp::dev::IEncodersTimedRaw,
42 : canId(0), timeout(0.0), maxRetries(0), retry(0), reverse(
false),
43 cuiMode(CuiMode::OFF), pushDelay(0),
44 encoder(), encoderTimestamp(0.0),
45 sender(
nullptr), pushStateObserver(
nullptr), pollStateObserver(
nullptr)
53 bool open(yarp::os::Searchable & config)
override;
54 bool close()
override;
58 unsigned int getId()
override;
67 bool getAxes(
int * ax)
override;
68 bool resetEncoderRaw(
int j)
override;
69 bool resetEncodersRaw()
override;
70 bool setEncoderRaw(
int j,
double val)
override;
71 bool setEncodersRaw(
const double * vals)
override;
72 bool getEncoderRaw(
int j,
double * v)
override;
73 bool getEncodersRaw(
double * encs)
override;
74 bool getEncoderSpeedRaw(
int j,
double * sp)
override;
75 bool getEncoderSpeedsRaw(
double * spds)
override;
76 bool getEncoderAccelerationRaw(
int j,
double * spds)
override;
77 bool getEncoderAccelerationsRaw(
double * accs)
override;
81 bool getEncodersTimedRaw(
double * encs,
double * time)
override;
82 bool getEncoderTimedRaw(
int j,
double * encs,
double * time)
override;
86 using encoder_t = yarp::conf::float32_t;
88 enum class CuiMode { PUSH, PULL, OFF };
89 enum class CuiCommand : std::uint8_t { PUSH_START = 1, PUSH_STOP = 2, POLL = 3 };
91 bool performRequest(
const std::string & name,
unsigned int len,
const std::uint8_t * msgData, encoder_t * resp =
nullptr);
94 bool pollEncoderRead(encoder_t * enc);
95 void normalize(encoder_t * v);
104 std::uint8_t pushDelay;
107 double encoderTimestamp;
113 mutable std::mutex mutex;
Implementation for the Cui Absolute Encoder custom UC3M circuit as a single CAN bus joint (control bo...
Definition: CuiAbsolute.hpp:38
bool finalize() override
Finalize CAN node communications.
Definition: ICanBusSharerImpl.cpp:36
bool initialize() override
Perform CAN node initialization.
Definition: ICanBusSharerImpl.cpp:24
bool synchronize(double timestamp) override
Perform synchronized action on CAN master's request.
Definition: ICanBusSharerImpl.cpp:92
bool notifyMessage(const can_message &message) override
Notify observers that a new CAN message has arrived.
Definition: ICanBusSharerImpl.cpp:49
unsigned int getId() override
Retrieve CAN node ID.
Definition: ICanBusSharerImpl.cpp:17
bool registerSender(ICanSenderDelegate *sender) override
Pass a handle to a CAN sender delegate instance.
Definition: ICanBusSharerImpl.cpp:84
Abstract base for a CAN bus sharer.
Definition: ICanBusSharer.hpp:25
Implementation-agnostic consumer for TX CAN transfers.
Definition: ICanSenderDelegate.hpp:22
Data-free state observer.
Definition: StateObserver.hpp:75
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6
Proxy CAN message structure.
Definition: CanMessage.hpp:20