yarp-devices
Loading...
Searching...
No Matches
LacqueyFetch.hpp
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3#ifndef __LACQUEY_FETCH_HPP__
4#define __LACQUEY_FETCH_HPP__
5
6#include <cstdint>
7
8#include <string>
9
10#include <yarp/conf/numeric.h>
11
12#include <yarp/dev/DeviceDriver.h>
13#include <yarp/dev/IAxisInfo.h>
14#include <yarp/dev/IControlMode.h>
15#include <yarp/dev/IPWMControl.h>
16
17#include "ICanBusSharer.hpp"
18#include "LacqueyFetch_ParamsParser.h"
19
20#define CHECK_JOINT(j) do { int n; if (getNumberOfMotorsRaw(&n), (j) != n - 1) return false; } while (0)
21
33class LacqueyFetch : public yarp::dev::DeviceDriver,
34 public yarp::dev::IAxisInfoRaw,
35 public yarp::dev::IControlModeRaw,
36 public yarp::dev::IPWMControlRaw,
39{
40public:
41 // --------- DeviceDriver declarations. Implementation in LacqueyFetch.cpp ---------
42
43 bool open(yarp::os::Searchable & config) override;
44 bool close() override;
45
46 // --------- ICanBusSharer declarations. Implementation in LacqueyFetch.cpp ---------
47
48 unsigned int getId() override;
49 bool notifyMessage(const roboticslab::can_message & message) override;
50 bool initialize() override;
51 bool finalize() override;
52 bool registerSender(roboticslab::ICanSenderDelegate * sender) override;
53 bool synchronize(double timestamp) override;
54
55 // --------- IAxisInfoRaw declarations. Implementation in IAxisInfoRawImpl.cpp ---------
56
57 bool getAxes(int * ax) override;
58 bool getAxisNameRaw(int j, std::string & name) override;
59 bool getJointTypeRaw(int j, yarp::dev::JointTypeEnum & type) override;
60
61 // --------- IControlModeRaw declarations. Implementation in IControlModeRawImpl.cpp ---------
62
63 bool getControlModeRaw(int j, int * mode) override;
64 bool getControlModesRaw(int * modes) override;
65 bool getControlModesRaw(int n_joint, const int * joints, int * modes) override;
66 bool setControlModeRaw(int j, int mode) override;
67 bool setControlModesRaw(int * modes) override;
68 bool setControlModesRaw(int n_joint, const int * joints, int * modes) override;
69
70 // ------- IPWMControlRaw declarations. Implementation in IPWMControlRawImpl.cpp -------
71
72 bool getNumberOfMotorsRaw(int * number) override;
73 bool setRefDutyCycleRaw(int m, double ref) override;
74 bool setRefDutyCyclesRaw(const double * refs) override;
75 bool getRefDutyCycleRaw(int m, double * ref) override;
76 bool getRefDutyCyclesRaw(double * refs) override;
77 bool getDutyCycleRaw(int m, double * val) override;
78 bool getDutyCyclesRaw(double * vals) override;
79
80private:
81 static constexpr unsigned int CAN_OP = 0x780; // keep in sync with firmware
82
83 bool send(unsigned int len, const std::uint8_t * msgData)
84 { return sender && sender->prepareMessage({CAN_OP + m_canId, len, msgData}); }
85
86 yarp::conf::float32_t refDutyCycles {0};
87 roboticslab::ICanSenderDelegate * sender {nullptr};
88};
89
90#endif // __LACQUEY_FETCH_HPP__
Definition LacqueyFetch_ParamsParser.h:43
Implementation for the Lacquey Fetch hand custom UC3M circuit as a single CAN bus joint (control boar...
Definition LacqueyFetch.hpp:39
unsigned int getId() override
Retrieve CAN node ID.
Definition ICanBusSharerImpl.cpp:9
bool finalize() override
Finalize CAN node communications.
Definition ICanBusSharerImpl.cpp:23
bool registerSender(roboticslab::ICanSenderDelegate *sender) override
Pass a handle to a CAN sender delegate instance.
Definition ICanBusSharerImpl.cpp:37
bool synchronize(double timestamp) override
Perform synchronized action on CAN master's request.
Definition ICanBusSharerImpl.cpp:45
bool notifyMessage(const roboticslab::can_message &message) override
Notify observers that a new CAN message has arrived.
Definition ICanBusSharerImpl.cpp:30
bool initialize() override
Perform CAN node initialization.
Definition ICanBusSharerImpl.cpp:16
Abstract base for a CAN bus sharer.
Definition ICanBusSharer.hpp:25
Implementation-agnostic consumer for TX CAN transfers.
Definition ICanSenderDelegate.hpp:22
virtual bool prepareMessage(const can_message &msg)=0
Register CAN message for write.
Proxy CAN message structure.
Definition CanMessage.hpp:20