yarp-devices
TextilesHand.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __TEXTILES_HAND_HPP__
4 #define __TEXTILES_HAND_HPP__
5 
6 #include <yarp/conf/version.h>
7 
8 #include <yarp/dev/PolyDriver.h>
9 #include <yarp/dev/DeviceDriver.h>
10 #include <yarp/dev/IControlMode.h>
11 #if YARP_VERSION_COMPARE(<, 3, 9, 0)
12 # include <yarp/dev/IEncodersTimed.h>
13 # include <yarp/dev/IPositionControl.h>
14 # include <yarp/dev/IVelocityControl.h>
15 #endif
16 #include <yarp/dev/IPositionDirect.h>
17 #include <yarp/dev/ISerialDevice.h>
18 
19 namespace roboticslab
20 {
21 
32 class TextilesHand : public yarp::dev::DeviceDriver,
33  public yarp::dev::IControlMode,
34 #if YARP_VERSION_COMPARE(<, 3, 9, 0)
35  public yarp::dev::IEncodersTimed,
36  public yarp::dev::IPositionControl,
37  public yarp::dev::IVelocityControl,
38 #endif
39  public yarp::dev::IPositionDirect
40 {
41 public:
42  // --------- DeviceDriver Declarations. Implementation in DeviceDriverImpl.cpp ---------
43 
44  bool open(yarp::os::Searchable & config) override;
45  bool close() override;
46 
47  // --------- IControlMode Declarations. Implementation in IControlModeImpl.cpp ---------
48 
49  bool getControlMode(int j, int * mode) override;
50  bool getControlModes(int * modes) override;
51  bool getControlModes(int n_joint, const int * joints, int * modes) override;
52  bool setControlMode(int j, int mode) override;
53  bool setControlModes(int * modes) override;
54  bool setControlModes(int n_joint, const int * joints, int * modes) override;
55 
56 #if YARP_VERSION_COMPARE(<, 3, 9, 0)
57  // ---------- IEncoders Declarations. Implementation in IEncodersImpl.cpp ----------
58 
59  //bool getAxes(int * ax) override;
60  bool resetEncoder(int j) override { return false; }
61  bool resetEncoders() override { return false; }
62  bool setEncoder(int j, double val) override { return false; }
63  bool setEncoders(const double * vals) override { return false; }
64  bool getEncoder(int j, double * v) override { return false; }
65  bool getEncoders(double * encs) override { return false; }
66  bool getEncoderSpeed(int j, double * sp) override { return false; }
67  bool getEncoderSpeeds(double * spds) override { return false; }
68  bool getEncoderAcceleration(int j, double * spds) override { return false; }
69  bool getEncoderAccelerations(double * accs) override { return false; }
70 
71  // ---------- IEncodersTimed Declarations. Implementation in IEncodersImpl.cpp ----------
72 
73  bool getEncoderTimed(int j, double * encs, double * time) override { return false; }
74  bool getEncodersTimed(double * encs, double * time) override { return false; }
75 
76  // ------- IPositionControl declarations. Implementation in IPositionControlImpl.cpp -------
77 
78  //bool getAxes(int * ax) override;
79  bool positionMove(int j, double ref) override { return false; }
80  bool positionMove(const double * refs) override { return false; }
81  bool positionMove(int n_joint, const int * joints, const double * refs) override { return false; }
82  bool relativeMove(int j, double delta) override { return false; }
83  bool relativeMove(const double * deltas) override { return false; }
84  bool relativeMove(int n_joint, const int * joints, const double * deltas) override { return false; }
85  bool checkMotionDone(int j, bool * flag) override { return false; }
86  bool checkMotionDone(bool * flag) override { return false; }
87  bool checkMotionDone(int n_joint, const int * joints, bool * flag) override { return false; }
88  bool setRefSpeed(int j, double sp) override { return false; }
89  bool setRefSpeeds(const double * spds) override { return false; }
90  bool setRefSpeeds(int n_joint, const int * joints, const double * spds) override { return false; }
91  bool setRefAcceleration(int j, double acc) override { return false; }
92  bool setRefAccelerations(const double * accs) override { return false; }
93  bool setRefAccelerations(int n_joint, const int * joints, const double * accs) override { return false; }
94  bool getRefSpeeds(int n_joint, const int * joints, double * spds) override { return false; }
95  bool getRefSpeed(int j, double * ref) override { return false; }
96  bool getRefSpeeds(double * spds) override { return false; }
97  bool getRefAcceleration(int j, double * acc) override { return false; }
98  bool getRefAccelerations(double * accs) override { return false; }
99  bool getRefAccelerations(int n_joint, const int * joints, double * accs) override { return false; }
100  bool stop(int j) override { return false; }
101  bool stop() override { return false; }
102  bool stop(int n_joint, const int *joints) override { return false; }
103  bool getTargetPosition(int joint, double * ref) override { return false; }
104  bool getTargetPositions(double * refs) override { return false; }
105  bool getTargetPositions(int n_joint, const int * joints, double * refs) override { return false; }
106 
107  // --------- IVelocityControl Declarations. Implementation in IVelocityControlImpl.cpp ---------
108 
109  //bool getAxes(int * ax) override;
110  bool velocityMove(int j, double spd) override { return false; }
111  bool velocityMove(const double * spds) override { return false; }
112  bool velocityMove(int n_joint, const int * joints, const double * spds) override { return false; }
113  bool getRefVelocity(int joint, double * vel) override { return false; }
114  bool getRefVelocities(double * vels) override { return false; }
115  bool getRefVelocities(int n_joint, const int * joints, double * vels) override { return false; }
116  //bool setRefAcceleration(int j, double acc) override;
117  //bool setRefAccelerations(const double * accs) override;
118  //bool setRefAccelerations(int n_joint, const int * joints, const double * accs) override;
119  //bool getRefAcceleration(int j, double * acc) override;
120  //bool getRefAccelerations(double * accs) override;
121  //bool getRefAccelerations(int n_joint, const int * joints, double * accs) override;
122  //bool stop(int j) override;
123  //bool stop() override;
124  //bool stop(int n_joint, const int *joints) override;
125 #endif // YARP_VERSION_COMPARE(<, 3, 9, 0)
126 
127  // ------- IPositionDirect declarations. Implementation in IPositionDirectImpl.cpp -------
128 
129  bool getAxes(int * ax) override;
130  bool setPosition(int j, double ref) override;
131  bool setPositions(const double * refs) override;
132  bool setPositions(int n_joint, const int * joints, const double * refs) override;
133  bool getRefPosition(int joint, double * ref) override;
134  bool getRefPositions(double * refs) override;
135  bool getRefPositions(int n_joint, const int * joints, double * refs) override;
136 
137 private:
138  double lastTarget {0.0};
139 
140  yarp::dev::PolyDriver serialDevice;
141  yarp::dev::ISerialDevice * iSerialDevice {nullptr};
142 };
143 
144 } // namespace roboticslab
145 
146 #endif // __TEXTILES_HAND_HPP__
Implementation for the custom UC3M Textiles Hand as a single CAN bus joint (control board raw interfa...
Definition: TextilesHand.hpp:40
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6