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"
18#include "CuiAbsolute_ParamsParser.h"
20#define CHECK_JOINT(j) do { int ax; if (getAxes(&ax), (j) != ax - 1) return false; } while (0)
34 public yarp::dev::IEncodersTimedRaw,
42 bool open(yarp::os::Searchable & config)
override;
43 bool close()
override;
47 unsigned int getId()
override;
56 bool getAxes(
int * ax)
override;
57 bool resetEncoderRaw(
int j)
override;
58 bool resetEncodersRaw()
override;
59 bool setEncoderRaw(
int j,
double val)
override;
60 bool setEncodersRaw(
const double * vals)
override;
61 bool getEncoderRaw(
int j,
double * v)
override;
62 bool getEncodersRaw(
double * encs)
override;
63 bool getEncoderSpeedRaw(
int j,
double * sp)
override;
64 bool getEncoderSpeedsRaw(
double * spds)
override;
65 bool getEncoderAccelerationRaw(
int j,
double * spds)
override;
66 bool getEncoderAccelerationsRaw(
double * accs)
override;
70 bool getEncodersTimedRaw(
double * encs,
double * time)
override;
71 bool getEncoderTimedRaw(
int j,
double * encs,
double * time)
override;
75 using encoder_t = yarp::conf::float32_t;
77 enum class CuiMode { PUSH, PULL, OFF };
78 enum class CuiCommand : std::uint8_t { PUSH_START = 1, PUSH_STOP = 2, POLL = 3 };
80 bool performRequest(
const std::string & name,
unsigned int len,
const std::uint8_t * msgData, encoder_t * resp =
nullptr);
83 bool pollEncoderRead(encoder_t * enc);
84 void normalize(encoder_t * v);
86 CuiMode cuiMode {CuiMode::OFF};
89 double encoderTimestamp {0.0};
95 mutable std::mutex mutex;
Definition CuiAbsolute_ParamsParser.h:47
Implementation for the Cui Absolute Encoder custom UC3M circuit as a single CAN bus joint (control bo...
Definition CuiAbsolute.hpp:37
bool finalize() override
Finalize CAN node communications.
Definition ICanBusSharerImpl.cpp:36
bool notifyMessage(const roboticslab::can_message &message) override
Notify observers that a new CAN message has arrived.
Definition ICanBusSharerImpl.cpp:49
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
unsigned int getId() override
Retrieve CAN node ID.
Definition ICanBusSharerImpl.cpp:17
bool registerSender(roboticslab::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
Type state observer for non-arithmetic types.
Definition StateObserver.hpp:95
Proxy CAN message structure.
Definition CanMessage.hpp:20