3 #ifndef __BASIC_CARTESIAN_CONTROL_HPP__
4 #define __BASIC_CARTESIAN_CONTROL_HPP__
13 #include <yarp/os/PeriodicThread.h>
15 #include <yarp/dev/DeviceDriver.h>
16 #include <yarp/dev/PolyDriver.h>
17 #include <yarp/dev/ControlBoardInterfaces.h>
18 #include <yarp/dev/IPreciselyTimed.h>
20 #include <kdl/trajectory.hpp>
108 public yarp::os::PeriodicThread,
116 bool stat(std::vector<double> & x,
int * state =
nullptr,
double * timestamp =
nullptr)
override;
117 bool inv(
const std::vector<double> & xd, std::vector<double> & q)
override;
118 bool movj(
const std::vector<double> & xd)
override;
119 bool relj(
const std::vector<double> & xd)
override;
120 bool movl(
const std::vector<double> & xd)
override;
121 bool movv(
const std::vector<double> & xdotd)
override;
122 bool gcmp()
override;
123 bool forc(
const std::vector<double> &
fd)
override;
125 bool wait(
double timeout)
override;
126 bool tool(
const std::vector<double> & x)
override;
127 bool act(
int command)
override;
128 void pose(
const std::vector<double> & x)
override;
129 void twist(
const std::vector<double> & xdot)
override;
130 void wrench(
const std::vector<double> & w)
override;
133 bool setParameters(
const std::map<int, double> & params)
override;
140 bool open(yarp::os::Searchable & config)
override;
141 bool close()
override;
147 template <
typename Fn>
152 {
if (handler) handler(); }
154 void suppress()
const
155 { handler =
nullptr; }
158 mutable std::function<void()> handler;
161 int getCurrentState()
const;
162 void setCurrentState(
int value);
164 bool checkJointLimits(
const std::vector<double> & q);
165 bool checkJointLimits(
const std::vector<double> & q,
const std::vector<double> & qdot);
166 bool checkJointVelocities(
const std::vector<double> & qdot);
167 bool doFailFastChecks(
const std::vector<double> & initialQ);
168 bool checkControlModes(
int mode);
169 bool setControlModes(
int mode);
170 bool presetStreamingCommand(
int command);
171 bool computeIsocronousSpeeds(
const std::vector<double> & q,
const std::vector<double> & qd, std::vector<double> & qdot);
173 void handleMovj(
const std::vector<double> & q,
const StateWatcher & watcher);
174 void handleMovlVel(
const std::vector<double> & q,
const StateWatcher & watcher);
175 void handleMovlPosd(
const std::vector<double> & q,
const StateWatcher & watcher);
176 void handleMovv(
const std::vector<double> & q,
const StateWatcher & watcher);
177 void handleGcmp(
const std::vector<double> & q,
const StateWatcher & watcher);
178 void handleForc(
const std::vector<double> & q,
const std::vector<double> & qdot,
const std::vector<double> & qdotdot,
const StateWatcher & watcher);
180 yarp::dev::PolyDriver solverDevice;
183 yarp::dev::PolyDriver robotDevice;
184 yarp::dev::IControlMode * iControlMode {
nullptr};
185 yarp::dev::IEncoders * iEncoders {
nullptr};
186 yarp::dev::IPositionControl * iPositionControl {
nullptr};
187 yarp::dev::IPositionDirect * iPositionDirect {
nullptr};
188 yarp::dev::IPreciselyTimed * iPreciselyTimed {
nullptr};
189 yarp::dev::ITorqueControl * iTorqueControl {
nullptr};
190 yarp::dev::IVelocityControl * iVelocityControl {
nullptr};
201 int streamingCommand;
206 mutable std::mutex stateMutex;
218 std::vector<double>
fd;
220 int encoderErrors {0};
221 std::atomic_bool cmcSuccess;
223 std::vector<double> qMin, qMax;
224 std::vector<double> qdotMin, qdotMax;
225 std::vector<double> qRefSpeeds;
Contains roboticslab::ICartesianControl and related vocabs.
Contains roboticslab::ICartesianSolver.
Definition: BasicCartesianControl.hpp:145
The BasicCartesianControl class implements ICartesianControl.
Definition: BasicCartesianControl.hpp:110
bool act(int command) override
Actuate tool.
Definition: ICartesianControlImpl.cpp:421
bool movl(const std::vector< double > &xd) override
Linear move to target position.
Definition: ICartesianControlImpl.cpp:175
void wrench(const std::vector< double > &w) override
Exert force.
Definition: ICartesianControlImpl.cpp:515
std::vector< std::unique_ptr< KDL::Trajectory > > trajectories
Definition: BasicCartesianControl.hpp:215
bool tool(const std::vector< double > &x) override
Change tool.
Definition: ICartesianControlImpl.cpp:402
bool wait(double timeout) override
Wait until completion.
Definition: ICartesianControlImpl.cpp:373
std::vector< double > fd
Definition: BasicCartesianControl.hpp:218
double movementStartTime
Definition: BasicCartesianControl.hpp:212
bool stopControl() override
Stop control.
Definition: ICartesianControlImpl.cpp:348
bool getParameters(std::map< int, double > ¶ms) override
Retrieve multiple configuration parameters.
Definition: ICartesianControlImpl.cpp:693
bool getParameter(int vocab, double *value) override
Retrieve a configuration parameter.
Definition: ICartesianControlImpl.cpp:641
std::vector< double > vmoStored
Definition: BasicCartesianControl.hpp:209
void twist(const std::vector< double > &xdot) override
Instantaneous velocity steps.
Definition: ICartesianControlImpl.cpp:475
bool movj(const std::vector< double > &xd) override
Move in joint space, absolute coordinates.
Definition: ICartesianControlImpl.cpp:89
void pose(const std::vector< double > &x) override
Achieve pose.
Definition: ICartesianControlImpl.cpp:429
bool stat(std::vector< double > &x, int *state=nullptr, double *timestamp=nullptr) override
Current state and position.
Definition: ICartesianControlImpl.cpp:37
bool forc(const std::vector< double > &fd) override
Force control.
Definition: ICartesianControlImpl.cpp:320
bool movv(const std::vector< double > &xdotd) override
Linear move with given velocity.
Definition: ICartesianControlImpl.cpp:251
bool gcmp() override
Gravity compensation.
Definition: ICartesianControlImpl.cpp:306
bool relj(const std::vector< double > &xd) override
Move in joint space, relative coordinates.
Definition: ICartesianControlImpl.cpp:150
bool setParameters(const std::map< int, double > ¶ms) override
Set multiple configuration parameters.
Definition: ICartesianControlImpl.cpp:673
bool setParameter(int vocab, double value) override
Set a configuration parameter.
Definition: ICartesianControlImpl.cpp:573
bool inv(const std::vector< double > &xd, std::vector< double > &q) override
Inverse kinematics.
Definition: ICartesianControlImpl.cpp:68
Abstract base class for a cartesian controller.
Definition: ICartesianControl.h:146
Abstract base class for a cartesian solver.
Definition: ICartesianSolver.h:23
reference_frame
Lists supported reference frames.
Definition: ICartesianSolver.h:27
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6