YARP
Yet Another Robot Platform
ControlBoardWrapperCommon.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_DEV_CONTROLBOARDWRAPPER_CONTROLBOARDWRAPPERCOMMON_H
7 #define YARP_DEV_CONTROLBOARDWRAPPER_CONTROLBOARDWRAPPERCOMMON_H
8 
9 #include "MultiJointData.h"
10 
11 constexpr int PROTOCOL_VERSION_MAJOR = 1;
12 constexpr int PROTOCOL_VERSION_MINOR = 9;
13 constexpr int PROTOCOL_VERSION_TWEAK = 0;
14 
16 {
17 public:
18 // COMMON MEMBERS
20  size_t controlledJoints {0};
21  std::string partName; // to open ports and print more detailed debug messages
22 
23  // RPC calls are concurrent from multiple clients, data used inside the calls has to be protected
24  std::mutex rpcDataMutex; // mutex to avoid concurrency between more clients using rppc port
25  MultiJointData rpcData; // Structure used to re-arrange data from "multiple_joints" calls.
26 
27  std::mutex timeMutex; // mutex to protect access to time member
28  yarp::os::Stamp time; // envelope to attach to the state port
29 
30 // METHODS SHARED BY MULTIPLE INTERFACES
31  /*
32  * IEncodersTimed
33  * IImpedanceControl
34  * IPositionControl
35  * IPositionDirect
36  * ITorqueControl
37  * IVelocityControl
38  */
39  bool getAxes(int* ax);
40 
41  /*
42  * IPositionControl
43  * IVelocityControl
44  */
45  bool setRefAcceleration(int j, double acc);
46  bool setRefAccelerations(const double* accs);
47  bool setRefAccelerations(const int n_joints, const int* joints, const double* accs);
48  bool getRefAcceleration(int j, double* acc);
49  bool getRefAccelerations(double* accs);
50  bool getRefAccelerations(const int n_joints, const int* joints, double* accs);
51  bool stop(int j);
52  bool stop();
53  bool stop(const int n_joint, const int* joints);
54 
55  /*
56  * IMotor
57  * IPWMControl
58  */
59  bool getNumberOfMotors(int* num);
60 
61  /*
62  * IAmplifierControl
63  * ICurrentControl
64  */
65  bool getCurrent(int m, double* curr);
66  bool getCurrents(double* currs);
67 
68 // UTILITIES
69  inline void printError(const std::string& func_name, const std::string& info, bool result)
70  {
71  // FIXME: Check if it is still required.
72  // This method was commented out by these commits:
73  // afc039962f3667cc954e7a50ce6963ec60886611
74  // 0c0de4a9331b9b843ac4b3d3746c074dd0427249
75 
76  // If result is false, this means that en error occurred in function named func_name, otherwise means that the device doesn't implement the interface to witch func_name belongs to.
77  // if(false == result) {
78  // yCError(CONTROLBOARDREMAPPER) << "CBW(" << partName << "): " << func_name.c_str() << " on device" << info.c_str() << " returns false";
79  // } else {
80  // Commented in order to maintain the old behaviour (none message appear if device desn't implement the interface)
81  // yCError(CONTROLBOARDREMAPPER) << "CBW(" << partName << "): " << func_name.c_str() << " on device" << info.c_str() << ": the interface is not available.";
82  // }
83  }
84 };
85 
86 #endif // YARP_DEV_CONTROLBOARDWRAPPER_CONTROLBOARDWRAPPERCOMMON_H
constexpr int PROTOCOL_VERSION_TWEAK
constexpr int PROTOCOL_VERSION_MINOR
constexpr int PROTOCOL_VERSION_MAJOR
bool getCurrent(int m, double *curr)
bool getRefAcceleration(int j, double *acc)
bool setRefAcceleration(int j, double acc)
bool setRefAccelerations(const double *accs)
void printError(const std::string &func_name, const std::string &info, bool result)
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22