25#define NEW_JSTATUS_STRUCT 1
26#define VELOCITY_WATCHDOG 0.1
27#define OPENLOOP_WATCHDOG 0.1
28#define PWM_CONSTANT 0.1
36 std::lock_guard lock(_mutex);
38 for (
int i=0;i <_njoints ;i++)
65 std::ostringstream oss;
72bool FakeMotionControlMicro::extractGroup(
Bottle &input,
Bottle &out,
const std::string &
key1,
const std::string &txt,
int size)
83 if(
tmp.size()!=(
size_t) size)
121 _axisName =
new std::string[nj];
129bool FakeMotionControlMicro::dealloc()
154 _angleToEncoder(nullptr),
155 _encodersStamp (nullptr),
157 _jointType (nullptr),
158 useRawEncoderData (
false),
161 verbose (VERY_VERBOSE)
165 verbosewhenok = (
tmp !=
"") ? (
bool)yarp::conf::numeric::from_string<int>(
tmp) :
183 for(
int i=0; i<_njoints; i++)
229 bool init = this->
start();
260 for (i = 0; i < _njoints; i++) {
274 for (i = 0; i < _njoints; i++) {
275 _axisName[_axisMap[i]] =
"joint" +
toString(i);
302 for (i = 0; i < _njoints; i++) {
322 for (i = 0; i < _njoints; i++) {
323 _angleToEncoder[i] = 1; }
332 std::lock_guard lock(_mutex);
347void FakeMotionControlMicro::cleanup()
388 for(
int j=0;
j< _njoints;
j++)
407 for(
int j=0;
j< _njoints;
j++)
425 for(
int j=0;
j< _njoints;
j++)
438 for (
int i = 0; i < _njoints; i++) {
439 stamps[i] = _encodersStamp[i];
449 *stamp = _encodersStamp[
j];
502 for(
int j=0;
j< _njoints;
j++)
519 for(
int j=0;
j< _njoints;
j++)
535 for(
int j=0;
j< _njoints;
j++)
546 for (
int i = 0; i < _njoints; i++) {
547 stamps[i] = _encodersStamp[i];
558 *stamp = _encodersStamp[
m];
570 name = _axisName[
axis];
584 type = _jointType[
axis];
597 message = _hwfault_message[
j];
void checkAndDestroy(T *&p)
bool NOT_YET_IMPLEMENTED(const char *txt)
std::string toString(const T &value)
convert an arbitrary type to string.
static bool NOT_YET_IMPLEMENTED(const char *txt)
static bool DEPRECATED(const char *txt)
std::string toString(const T &value)
convert an arbitrary type to string.
constexpr yarp::conf::vocab32_t VOCAB_CM_POSITION
std::vector< int > m_GENERAL_AxisMap
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::vector< std::string > m_GENERAL_AxisName
std::vector< std::string > m_GENERAL_AxisType
std::vector< int > m_GENERAL_Encoder
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.
~FakeMotionControlMicro()
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.
virtual bool initialised()
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
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A base class for nested structures that can be searched.
void resize(size_t size) override
Resize the vector.
void zero()
Zero the elements of the vector.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
std::string get_string(const std::string &key, bool *found=nullptr)
Read a string from an environment variable.
For streams capable of holding different kinds of content, check what they actually have.
@ VOCAB_JOINTTYPE_REVOLUTE
@ VOCAB_JOINTTYPE_PRISMATIC
@ VOCAB_JOINTTYPE_UNKNOWN
double now()
Return the current time in seconds, relative to an arbitrary starting point.
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.