3#ifndef __I_CARTESIAN_CONTROL__
4#define __I_CARTESIAN_CONTROL__
10#include <yarp/os/Vocab.h>
11#include <yarp/dev/ReturnValue.h>
13#include <ICartesianSolver.h>
31 OK = yarp::os::createVocab32(
'o',
'k'),
32 FAILED = yarp::os::createVocab32(
'f',
'a',
'i',
'l'),
33 SET = yarp::os::createVocab32(
's',
'e',
't'),
34 GET = yarp::os::createVocab32(
'g',
'e',
't'),
35 NOT_SET = yarp::os::createVocab32(
'n',
's',
'e',
't')
45 STATE = yarp::os::createVocab32(
's',
't',
'a',
't'),
46 INV = yarp::os::createVocab32(
'i',
'n',
'v'),
47 MOVEJ = yarp::os::createVocab32(
'm',
'o',
'v',
'j'),
48 MOVEL = yarp::os::createVocab32(
'm',
'o',
'v',
'l'),
49 MOVEV = yarp::os::createVocab32(
'm',
'o',
'v',
'v'),
50 GCMP = yarp::os::createVocab32(
'g',
'c',
'm',
'p'),
51 FORCE = yarp::os::createVocab32(
'f',
'o',
'r',
'c'),
52 STOP = yarp::os::createVocab32(
's',
't',
'o',
'p'),
53 TOOL = yarp::os::createVocab32(
't',
'o',
'o',
'l'),
54 ACT = yarp::os::createVocab32(
'a',
'c',
't')
64 POSE = yarp::os::createVocab32(
'p',
'o',
's',
'e'),
65 TWIST = yarp::os::createVocab32(
't',
'w',
's',
't'),
66 WRENCH = yarp::os::createVocab32(
'w',
'r',
'n',
'c')
76 NONE = yarp::os::createVocab32(
'n',
'c',
't',
'l'),
77 MOVEJ = yarp::os::createVocab32(
'm',
'o',
'v',
'j'),
78 MOVEL = yarp::os::createVocab32(
'm',
'o',
'v',
'l'),
79 MOVEV = yarp::os::createVocab32(
'm',
'o',
'v',
'v'),
80 GCMP = yarp::os::createVocab32(
'g',
'c',
'm',
'p'),
81 FORCE = yarp::os::createVocab32(
'f',
'o',
'r',
'c')
91 NONE = yarp::os::createVocab32(
'a',
'c',
'n'),
92 CLOSE = yarp::os::createVocab32(
'a',
'c',
'c',
'g'),
93 OPEN = yarp::os::createVocab32(
'a',
'c',
'o',
'g'),
94 STOP = yarp::os::createVocab32(
'a',
'c',
's',
'g'),
95 GENERIC = yarp::os::createVocab32(
'a',
'c',
'g')
105 GAIN = yarp::os::createVocab32(
'c',
'p',
'c',
'g'),
107 TRAJ_REF_SPD = yarp::os::createVocab32(
'c',
'p',
't',
's'),
108 TRAJ_REF_ACC = yarp::os::createVocab32(
'c',
'p',
't',
'a'),
109 CMC_PERIOD = yarp::os::createVocab32(
'c',
'p',
'c',
'p'),
110 FRAME = yarp::os::createVocab32(
'c',
'p',
'f'),
121 std::vector<double>
x;
166 virtual yarp::dev::ReturnValue
solvePose(
const std::vector<double> & xd, std::vector<double> & q) = 0;
180 virtual yarp::dev::ReturnValue
moveJoint(
const std::vector<double> & xd) = 0;
193 virtual yarp::dev::ReturnValue
moveLinear(
const std::vector<double> & xd) = 0;
206 virtual yarp::dev::ReturnValue
moveVelocity(
const std::vector<double> & xdotd) = 0;
228 virtual yarp::dev::ReturnValue
forceControl(
const std::vector<double> & fd) = 0;
250 virtual yarp::dev::ReturnValue
changeTool(
const std::vector<double> & x) = 0;
286 virtual void pose(
const std::vector<double> & x) = 0;
297 virtual void twist(
const std::vector<double> & xdot) = 0;
307 virtual void wrench(
const std::vector<double> & w) = 0;
355 virtual yarp::dev::ReturnValue
setParameters(
const std::map<Config, double> & params) = 0;
366 virtual yarp::dev::ReturnValue
getParameters(std::map<Config, double> & params) = 0;
370#ifndef SWIG_PREPROCESSOR_SHOULD_SKIP_THIS
371 [[deprecated(
"use `ICartesianControl::getState` instead")]]
372 virtual bool stat(std::vector<double> & x,
int * state =
nullptr,
double * timestamp =
nullptr)
375 auto ret =
getState(controllerState);
376 x = controllerState.
x;
377 if (state !=
nullptr) *state =
static_cast<int>(controllerState.
mode);
378 if (timestamp !=
nullptr) *timestamp = controllerState.
timestamp;
382 [[deprecated(
"use `ICartesianControl::solvePose` instead")]]
383 virtual bool inv(
const std::vector<double> & xd, std::vector<double> & q)
386 [[deprecated(
"use `ICartesianControl::moveJoint` instead")]]
387 virtual bool movj(
const std::vector<double> & xd)
390 [[deprecated(
"use `ICartesianControl::getState and moveJoint` instead")]]
391 virtual bool relj(
const std::vector<double> & xd)
394 [[deprecated(
"use `ICartesianControl::moveLinear` instead")]]
395 virtual bool movl(
const std::vector<double> & xd)
398 [[deprecated(
"use `ICartesianControl::moveVelocity` instead")]]
399 virtual bool movv(
const std::vector<double> & xdotd)
402 [[deprecated(
"use `ICartesianControl::gravityCompensation` instead")]]
406 [[deprecated(
"use `ICartesianControl::forceControl` instead")]]
407 virtual bool forc(
const std::vector<double> & fd)
410 [[deprecated(
"use `ICartesianControl::getState` instead")]]
411 virtual bool wait(
double timeout = 0.0)
414 [[deprecated(
"use `ICartesianControl::changeTool` instead")]]
415 virtual bool tool(
const std::vector<double> & x)
418 [[deprecated(
"use `ICartesianControl::Actuator` signature instead")]]
419 virtual bool act(
int command)
422 [[deprecated(
"use `ICartesianControl::Config` signature instead")]]
426 [[deprecated(
"use `ICartesianControl::Config` signature instead")]]
430 [[deprecated(
"use `ICartesianControl::Config` signature instead")]]
431 virtual bool setParameters(
const std::map<int, double> & params)
432 {
return std::all_of(params.begin(), params.end(), [
this](
const auto & kv) { return setParameter(static_cast<Config>(kv.first), kv.second); }); }
434 [[deprecated(
"use `ICartesianControl::Config` signature instead")]]
436 {
return std::all_of(params.begin(), params.end(), [
this](
auto & kv) { return getParameter(static_cast<Config>(kv.first), &kv.second); }); }
443#ifndef SWIG_PREPROCESSOR_SHOULD_SKIP_THIS
444[[deprecated(
"use `ICartesianControl::Vocabs::OK` instead")]]
447[[deprecated(
"use `ICartesianControl::Vocabs::FAILED` instead")]]
450[[deprecated(
"use `ICartesianControl::Vocabs::SET` instead")]]
453[[deprecated(
"use `ICartesianControl::Vocabs::GET` instead")]]
456[[deprecated(
"use `ICartesianControl::Vocabs::NOT_SET` instead")]]
459[[deprecated(
"use `ICartesianControl::RPC::STATE` instead")]]
462[[deprecated(
"use `ICartesianControl::RPC::INV` instead")]]
465[[deprecated(
"use `ICartesianControl::RPC::MOVEJ` instead")]]
468[[deprecated(
"use `ICartesianControl::RPC::MOVJ` instead")]]
469constexpr auto VOCAB_CC_RELJ = 0;
471[[deprecated(
"use `ICartesianControl::RPC::MOVEL` instead")]]
474[[deprecated(
"use `ICartesianControl::RPC::MOVEV` instead")]]
477[[deprecated(
"use `ICartesianControl::RPC::GCMP` instead")]]
480[[deprecated(
"use `ICartesianControl::RPC::FORCE` instead")]]
483[[deprecated(
"use `ICartesianControl::RPC::STOP` instead")]]
486[[deprecated(
"use `ICartesianControl::RPC::STATE` instead")]]
487constexpr auto VOCAB_CC_WAIT = 0;
489[[deprecated(
"use `ICartesianControl::RPC::TOOL` instead")]]
492[[deprecated(
"use `ICartesianControl::RPC::ACT` instead")]]
495[[deprecated(
"use `ICartesianControl::Streaming::POSE` instead")]]
498[[deprecated(
"use `ICartesianControl::Streaming::TWIST` instead")]]
501[[deprecated(
"use `ICartesianControl::Streaming::WRENCH` instead")]]
504[[deprecated(
"use `ICartesianControl::State::NONE` instead")]]
507[[deprecated(
"use `ICartesianControl::State::MOVEJ` instead")]]
510[[deprecated(
"use `ICartesianControl::State::MOVEL` instead")]]
513[[deprecated(
"use `ICartesianControl::State::MOVEV` instead")]]
516[[deprecated(
"use `ICartesianControl::State::GCMP` instead")]]
519[[deprecated(
"use `ICartesianControl::State::FORCE` instead")]]
522[[deprecated(
"use `ICartesianControl::Actuator::NONE` instead")]]
525[[deprecated(
"use `ICartesianControl::Actuator::CLOSE` instead")]]
528[[deprecated(
"use `ICartesianControl::Actuator::OPEN` instead")]]
531[[deprecated(
"use `ICartesianControl::Actuator::STOP` instead")]]
534[[deprecated(
"use `ICartesianControl::Actuator::GENERIC` instead")]]
537[[deprecated(
"unused")]]
538constexpr auto VOCAB_CC_CONFIG_PARAMS = 0;
540[[deprecated(
"use `ICartesianControl::Config::GAIN` instead")]]
543[[deprecated(
"use `ICartesianControl::Config::TRAJ_DURATION` instead")]]
546[[deprecated(
"use `ICartesianControl::Config::TRAJ_REF_SPD` instead")]]
549[[deprecated(
"use `ICartesianControl::Config::TRAJ_REF_ACC` instead")]]
552[[deprecated(
"use `ICartesianControl::Config::CMC_PERIOD` instead")]]
555[[deprecated(
"unused")]]
556constexpr auto VOCAB_CC_CONFIG_WAIT_PERIOD = 0;
558[[deprecated(
"use `ICartesianControl::Config::FRAME` instead")]]
561[[deprecated(
"use `ICartesianControl::Config::STREAMING_CMD` instead")]]
Abstract base class for a cartesian controller.
Definition ICartesianControl.h:22
Streaming
Streaming vocabs.
Definition ICartesianControl.h:63
@ TWIST
Instantaneous velocity steps.
virtual ~ICartesianControl()=default
Destructor.
virtual yarp::dev::ReturnValue moveJoint(const std::vector< double > &xd)=0
Move in joint space.
virtual yarp::dev::ReturnValue forceControl(const std::vector< double > &fd)=0
Force control.
virtual yarp::dev::ReturnValue moveVelocity(const std::vector< double > &xdotd)=0
Linear move with given velocity.
virtual yarp::dev::ReturnValue getParameters(std::map< Config, double > ¶ms)=0
Retrieve multiple configuration parameters.
virtual yarp::dev::ReturnValue gravityCompensation()=0
Gravity compensation.
virtual yarp::dev::ReturnValue getState(ControllerState &state)=0
Current state and position.
Mode
Controller mode vocabs.
Definition ICartesianControl.h:75
@ FORCE
Executing FORCE command.
@ MOVEL
Executing MOVEL command.
@ GCMP
Executing GCMP command.
@ MOVEJ
Executing MOVEJ command.
@ MOVEV
Executing MOVEV command.
virtual yarp::dev::ReturnValue setParameter(Config vocab, double value)=0
Set a configuration parameter.
Actuator
Actuator control vocabs.
Definition ICartesianControl.h:90
@ NONE
No actuator or no action.
@ GENERIC
Generic actuator.
Vocabs
General-purpose vocabs.
Definition ICartesianControl.h:30
virtual void twist(const std::vector< double > &xdot)=0
Instantaneous velocity steps.
Config
Controller configuration vocabs.
Definition ICartesianControl.h:104
@ STREAMING_CMD
Preset streaming command.
@ TRAJ_REF_ACC
Trajectory reference acceleration [m/s^2].
@ CMC_PERIOD
CMC period [ms].
@ TRAJ_REF_SPD
Trajectory reference speed [m/s].
@ TRAJ_DURATION
Trajectory duration [s].
virtual yarp::dev::ReturnValue stopControl()=0
Stop control.
virtual yarp::dev::ReturnValue changeTool(const std::vector< double > &x)=0
Change tool.
virtual void pose(const std::vector< double > &x)=0
Achieve pose.
virtual yarp::dev::ReturnValue moveLinear(const std::vector< double > &xd)=0
Linear move to target position.
virtual void wrench(const std::vector< double > &w)=0
Exert force.
RPC
RPC vocabs.
Definition ICartesianControl.h:44
@ STATE
Current state and position.
@ MOVEL
Linear move to target position.
@ GCMP
Gravity compensation.
@ MOVEJ
Move in joint space, absolute coordinates.
@ MOVEV
Linear move with given velocity.
virtual yarp::dev::ReturnValue solvePose(const std::vector< double > &xd, std::vector< double > &q)=0
Inverse kinematics.
virtual yarp::dev::ReturnValue getParameter(Config vocab, double *value)=0
Retrieve a configuration parameter.
virtual yarp::dev::ReturnValue actuateTool(Actuator command)=0
Actuate tool.
virtual yarp::dev::ReturnValue setParameters(const std::map< Config, double > ¶ms)=0
Set multiple configuration parameters.
The main, catch-all namespace for Robotics Lab UC3M.
Definition groups.dox:6
Controller state structure.
Definition ICartesianControl.h:120
float progress
Progress of the current trajectory, if any (0.0 to 1.0)
Definition ICartesianControl.h:125
Mode mode
Current controller mode.
Definition ICartesianControl.h:122
std::vector< double > x
Current pose: translation (3, meters) + rotation (3, radians, scaled axis-angle)
Definition ICartesianControl.h:121
double timestamp
Timestamp of the last received pose.
Definition ICartesianControl.h:123
double duration
Duration of the current trajectory, if any (seconds)
Definition ICartesianControl.h:124
bool success
Whether the last trajectory command was successful.
Definition ICartesianControl.h:126