YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeMotionControlMicro.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_DEVICE_FAKE_MOTIONCONTROLMICRO
7#define YARP_DEVICE_FAKE_MOTIONCONTROLMICRO
8
9#include <yarp/os/Time.h>
10#include <yarp/os/Bottle.h>
11#include <yarp/sig/Vector.h>
17
18#include <mutex>
20
42{
43private:
44 enum VerboseLevel
45 {
46 MUTE = 0, // only errors that prevent device from working
47 QUIET = 1, // adds errors that can cause malfunctioning
48 DEFAULT = 2, // adds warnings // DEFAULT // show noisy messages about back-compatible changes
49 CHATTY = 3, // adds info messages
50 VERBOSE = 4, // adds debug messages
51 VERY_VERBOSE = 5, // adds trace of events (shows thread running and catch if they get stuck)
52 VERY_VERY_VERBOSE = 6 // adds messages printed every cycle, so too much verbose for usage, only for deep debugging
53 };
54
55 std::recursive_mutex _mutex;
56 int _njoints;
57 int *_axisMap;
58 double *_angleToEncoder;
59 double *_encodersStamp;
61 std::string *_axisName;
62 yarp::dev::JointTypeEnum *_jointType;
64 bool verbosewhenok;
65 bool useRawEncoderData;
66
67
68 // internal stuff
69 int *_controlModes = nullptr;
70 int *_hwfault_code = nullptr;
71 std::string *_hwfault_message = nullptr;
72 yarp::sig::Vector pos, dpos, vel, speed, acc, loc, amp;
73 double prev_time;
74 bool opened;
75
76 // debugging
77 VerboseLevel verbose;
78public:
79
82
83 // Device Driver
84 bool open(yarp::os::Searchable &par) override;
85 bool close() override;
86 bool fromConfig(yarp::os::Searchable &config);
87
88 virtual bool initialised();
89
93 bool alloc(int njoints);
94
98 void resizeBuffers();
99
100 bool threadInit() override;
101 void threadRelease() override;
102
103 // IJointFault
104 bool getLastJointFaultRaw(int j, int& fault, std::string& message) override;
105
107 bool getNumberOfMotorEncodersRaw(int* num) override;
108 bool resetMotorEncoderRaw(int j) override;
109 bool resetMotorEncodersRaw() override;
110 bool setMotorEncoderRaw(int j, double val) override;
111 bool setMotorEncodersRaw(const double* vals) override;
112 bool getMotorEncoderRaw(int j, double* v) override;
113 bool getMotorEncodersRaw(double* encs) override;
114 bool getMotorEncoderSpeedRaw(int j, double* sp) override;
115 bool getMotorEncoderSpeedsRaw(double* spds) override;
116 bool getMotorEncoderAccelerationRaw(int j, double* spds) override;
117 bool getMotorEncoderAccelerationsRaw(double* accs) override;
118 bool getMotorEncodersTimedRaw(double* encs, double* stamps) override;
119 bool getMotorEncoderTimedRaw(int m, double* encs, double* stamp) override;
120 bool getMotorEncoderCountsPerRevolutionRaw(int m, double* v) override;
121 bool setMotorEncoderCountsPerRevolutionRaw(int m, const double cpr) override;
123
125 bool getAxes(int* ax) override;
126 bool resetEncoderRaw(int j) override;
127 bool resetEncodersRaw() override;
128 bool setEncoderRaw(int j, double val) override;
129 bool setEncodersRaw(const double *vals) override;
130 bool getEncoderRaw(int j, double *v) override;
131 bool getEncodersRaw(double *encs) override;
132 bool getEncoderSpeedRaw(int j, double *sp) override;
133 bool getEncoderSpeedsRaw(double *spds) override;
134 bool getEncoderAccelerationRaw(int j, double *spds) override;
135 bool getEncoderAccelerationsRaw(double *accs) override;
137
139 bool getEncodersTimedRaw(double *encs, double *stamps) override;
140 bool getEncoderTimedRaw(int j, double *encs, double *stamp) override;
142
144 bool getAxisNameRaw(int axis, std::string& name) override;
145 bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum& type) override;
147
148 void run() override;
149private:
150 void cleanup();
151 bool dealloc();
152
153 bool extractGroup(yarp::os::Bottle &input, yarp::os::Bottle &out, const std::string &key1, const std::string &txt, int size);
154};
155
156#endif // YARP_DEVICE_FAKE_MOTIONCONTROLMICRO
define control board standard interfaces
contains the definition of a Vector type
This class is the parameters parser for class FakeMotionControlMicro.
fakeMotionControlMicro: This device implements a minimal subset of mandatory interfaces to run with c...
void threadRelease() override
Release method.
bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type) override
bool getMotorEncoderSpeedRaw(int j, double *sp) override
Read the istantaneous speed of a motor encoder.
bool alloc(int njoints)
Allocated buffers.
bool setEncodersRaw(const double *vals) override
Set the value of all encoders.
bool getEncoderRaw(int j, double *v) override
Read the value of an encoder.
bool getNumberOfMotorEncodersRaw(int *num) override
Get the number of available motor encoders.
bool getMotorEncoderAccelerationsRaw(double *accs) override
Read the instantaneous acceleration of all motor encoders.
bool getAxes(int *ax) override
Get the number of controlled axes.
bool fromConfig(yarp::os::Searchable &config)
bool resetEncodersRaw() override
Reset encoders.
bool getMotorEncoderTimedRaw(int m, double *encs, double *stamp) override
Read the instantaneous position of a motor encoder.
bool resetEncoderRaw(int j) override
Reset encoder, single joint.
bool getEncoderSpeedsRaw(double *spds) override
Read the instantaneous acceleration of an axis.
bool close() override
Close the DeviceDriver.
bool getEncodersRaw(double *encs) override
Read the position of all axes.
bool getMotorEncodersRaw(double *encs) override
Read the position of all motor encoders.
bool getEncodersTimedRaw(double *encs, double *stamps) override
Read the instantaneous acceleration of all axes.
bool setMotorEncoderRaw(int j, double val) override
Set the value of the motor encoder for a given motor.
bool getMotorEncodersTimedRaw(double *encs, double *stamps) override
Read the instantaneous position of all motor encoders.
void run() override
Loop function.
void resizeBuffers()
Resize previously allocated buffers.
bool resetMotorEncodersRaw() override
Reset motor encoders.
bool open(yarp::os::Searchable &par) override
Open the DeviceDriver.
bool getEncoderTimedRaw(int j, double *encs, double *stamp) override
Read the instantaneous acceleration of all axes.
bool getMotorEncoderCountsPerRevolutionRaw(int m, double *v) override
Gets number of counts per revolution for motor encoder m.
bool getMotorEncoderRaw(int j, double *v) override
Read the value of a motor encoder.
bool setEncoderRaw(int j, double val) override
Set the value of the encoder for a given joint.
bool threadInit() override
Initialization method.
bool getEncoderAccelerationRaw(int j, double *spds) override
Read the instantaneous acceleration of an axis.
bool getEncoderSpeedRaw(int j, double *sp) override
Read the instantaneous speed of an axis.
bool getMotorEncoderAccelerationRaw(int j, double *spds) override
Read the instantaneous acceleration of a motor encoder.
bool setMotorEncodersRaw(const double *vals) override
Set the value of all motor encoders.
bool getAxisNameRaw(int axis, std::string &name) override
bool getMotorEncoderSpeedsRaw(double *spds) override
Read the instantaneous speed of all motor encoders.
bool resetMotorEncoderRaw(int j) override
Reset motor encoder, single motor.
bool setMotorEncoderCountsPerRevolutionRaw(int m, const double cpr) override
Sets number of counts per revolution for motor encoder m.
bool getEncoderAccelerationsRaw(double *accs) override
Read the instantaneous acceleration of all axes.
bool getLastJointFaultRaw(int j, int &fault, std::string &message) override
Interface implemented by all device drivers.
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:72
Control board, extend encoder raw interface adding timestamps.
Interface for getting info about the fault which may occur on a robot.
Definition IJointFault.h:35
Control board, encoder interface.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition Searchable.h:31