3#ifndef __BASIC_CARTESIAN_CONTROL_HPP__
4#define __BASIC_CARTESIAN_CONTROL_HPP__
12#include <yarp/conf/version.h>
14#include <yarp/os/PeriodicThread.h>
16#include <yarp/dev/DeviceDriver.h>
17#include <yarp/dev/PolyDriver.h>
18#include <yarp/dev/ControlBoardInterfaces.h>
19#include <yarp/dev/IPreciselyTimed.h>
21#include <kdl/trajectory.hpp>
23#include "ICartesianSolver.h"
24#include "ICartesianControl.h"
25#include "BasicCartesianControl_ParamsParser.h"
107 public yarp::os::PeriodicThread,
119 yarp::dev::ReturnValue
solvePose(
const std::vector<double> & xd, std::vector<double> & q)
override;
120 yarp::dev::ReturnValue
moveJoint(
const std::vector<double> & xd)
override;
121 yarp::dev::ReturnValue
moveLinear(
const std::vector<double> & xd)
override;
122 yarp::dev::ReturnValue
moveVelocity(
const std::vector<double> & xdotd)
override;
124 yarp::dev::ReturnValue
forceControl(
const std::vector<double> &
fd)
override;
126 yarp::dev::ReturnValue
changeTool(
const std::vector<double> & x)
override;
130 void pose(
const std::vector<double> & x)
override;
131 void twist(
const std::vector<double> & xdot)
override;
132 void wrench(
const std::vector<double> & w)
override;
137 yarp::dev::ReturnValue setParameters(
const std::map<roboticslab::ICartesianControl::Config, double> & params)
override;
138 yarp::dev::ReturnValue getParameters(std::map<roboticslab::ICartesianControl::Config, double> & params)
override;
144 bool open(yarp::os::Searchable & config)
override;
145 bool close()
override;
151 template <
typename Fn>
156 {
if (handler) handler(); }
158 void suppress()
const
159 { handler =
nullptr; }
162 mutable std::function<void()> handler;
165 double getTimestamp();
167 bool checkJointLimits(
const std::vector<double> & q);
168 bool checkJointLimits(
const std::vector<double> & q,
const std::vector<double> & qdot);
169 bool checkJointVelocities(
const std::vector<double> & qdot);
170 bool doFailFastChecks(
const std::vector<double> & initialQ);
171#if YARP_VERSION_COMPARE(>=, 4,0,0)
172 bool checkControlModes(yarp::dev::ControlModeEnum mode);
173 bool setControlModes(yarp::dev::SelectableControlModeEnum mode);
175 bool checkControlModes(
int mode);
176 bool setControlModes(
int mode);
179 bool computeIsocronousSpeeds(
const std::vector<double> & q,
const std::vector<double> & qd, std::vector<double> & qdot);
181 void handleMovj(
const std::vector<double> & q,
const StateWatcher & watcher);
182 void handleMovelVel(
const std::vector<double> & q,
const StateWatcher & watcher);
183 void handleMovelPosd(
const std::vector<double> & q,
const StateWatcher & watcher);
184 void handleMovv(
const std::vector<double> & q,
const StateWatcher & watcher);
185 void handleGcmp(
const std::vector<double> & q,
const StateWatcher & watcher);
186 void handleForc(
const std::vector<double> & q,
const std::vector<double> & qdot,
const std::vector<double> & qdotdot,
const StateWatcher & watcher);
188 yarp::dev::PolyDriver solverDevice;
191 yarp::dev::PolyDriver robotDevice;
192 yarp::dev::IControlMode * iControlMode {
nullptr};
193 yarp::dev::IEncoders * iEncoders {
nullptr};
194 yarp::dev::IPositionControl * iPositionControl {
nullptr};
195 yarp::dev::IPositionDirect * iPositionDirect {
nullptr};
196 yarp::dev::IPreciselyTimed * iPreciselyTimed {
nullptr};
197 yarp::dev::ITorqueControl * iTorqueControl {
nullptr};
198 yarp::dev::IVelocityControl * iVelocityControl {
nullptr};
202#if YARP_VERSION_COMPARE(>=, 4,0,0)
203 std::size_t numJoints {0};
217 std::vector<double>
fd;
219 int encoderErrors {0};
220 double trajectoryStartTime {0.0};
222 std::atomic<double> maxTrajectoryDuration {0.0};
223 std::atomic<bool> cmcSuccess {
true};
224 std::atomic<float> cmcProgress {1.0f};
226 std::vector<double> qMin, qMax;
227 std::vector<double> qdotMin, qdotMax;
228 std::vector<double> qRefSpeeds;
Definition BasicCartesianControl.hpp:149
Definition BasicCartesianControl_ParamsParser.h:51
The BasicCartesianControl class implements ICartesianControl.
Definition BasicCartesianControl.hpp:110
void wrench(const std::vector< double > &w) override
Exert force.
Definition ICartesianControlImpl.cpp:528
yarp::dev::ReturnValue actuateTool(roboticslab::ICartesianControl::Actuator command) override
Actuate tool.
Definition ICartesianControlImpl.cpp:424
yarp::dev::ReturnValue getState(roboticslab::ICartesianControl::ControllerState &state) override
Current state and position.
Definition ICartesianControlImpl.cpp:29
yarp::dev::ReturnValue moveLinear(const std::vector< double > &xd) override
Linear move to target position.
Definition ICartesianControlImpl.cpp:156
yarp::dev::ReturnValue moveJoint(const std::vector< double > &xd) override
Move in joint space.
Definition ICartesianControlImpl.cpp:77
yarp::dev::ReturnValue forceControl(const std::vector< double > &fd) override
Force control.
Definition ICartesianControlImpl.cpp:343
std::vector< double > vmoStored
Definition BasicCartesianControl.hpp:211
yarp::dev::ReturnValue changeTool(const std::vector< double > &x) override
Change tool.
Definition ICartesianControlImpl.cpp:405
yarp::dev::ReturnValue setParameter(roboticslab::ICartesianControl::Config vocab, double value) override
Set a configuration parameter.
Definition ICartesianControlImpl.cpp:592
void twist(const std::vector< double > &xdot) override
Instantaneous velocity steps.
Definition ICartesianControlImpl.cpp:482
yarp::dev::ReturnValue solvePose(const std::vector< double > &xd, std::vector< double > &q) override
Inverse kinematics.
Definition ICartesianControlImpl.cpp:56
yarp::dev::ReturnValue getParameter(roboticslab::ICartesianControl::Config vocab, double *value) override
Retrieve a configuration parameter.
Definition ICartesianControlImpl.cpp:701
void pose(const std::vector< double > &x) override
Achieve pose.
Definition ICartesianControlImpl.cpp:432
std::vector< std::unique_ptr< KDL::Trajectory > > trajectories
Definition BasicCartesianControl.hpp:214
yarp::dev::ReturnValue stopControl() override
Stop control.
Definition ICartesianControlImpl.cpp:376
yarp::dev::ReturnValue gravityCompensation() override
Gravity compensation.
Definition ICartesianControlImpl.cpp:324
std::vector< double > fd
Definition BasicCartesianControl.hpp:217
yarp::dev::ReturnValue moveVelocity(const std::vector< double > &xdotd) override
Linear move with given velocity.
Definition ICartesianControlImpl.cpp:257
Abstract base class for a cartesian controller.
Definition ICartesianControl.h:22
Streaming
Streaming vocabs.
Definition ICartesianControl.h:63
Actuator
Actuator control vocabs.
Definition ICartesianControl.h:90
Config
Controller configuration vocabs.
Definition ICartesianControl.h:104
Abstract base class for a cartesian solver.
Definition ICartesianSolver.h:19
Frame
Lists supported reference frames.
Definition ICartesianSolver.h:23
Controller state structure.
Definition ICartesianControl.h:120