79#ifndef __AFFACTIONPRIMITIVES_H__
80#define __AFFACTIONPRIMITIVES_H__
83#include <condition_variable>
90#include <yarp/os/all.h>
91#include <yarp/dev/all.h>
92#include <yarp/sig/all.h>
96#define ACTIONPRIM_DISABLE_EXECTIME -1.0
300 virtual void printMessage(
const int logtype,
const char *format, ...)
const;
302 virtual bool handleTorsoDOF(yarp::os::Property &opt,
const std::string &key);
307 virtual bool _pushAction(
const bool execArm,
const yarp::sig::Vector &
x,
308 const yarp::sig::Vector &o,
const double execTime,
309 const bool oEnabled,
const bool execHand,
const HandWayPoint &handWP,
311 virtual bool _pushAction(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
312 const std::string &handSeqKey,
const double execTime,
442 virtual bool open(yarp::os::Property &opt);
453 virtual void close();
475 virtual bool pushAction(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
476 const std::string &handSeqKey,
499 const std::string &handSeqKey,
515 virtual bool pushAction(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
540 virtual bool pushAction(
const std::string &handSeqKey,
555 virtual bool pushAction(
const std::deque<ActionPrimitivesWayPoint> &wayPoints,
572 virtual bool pushAction(
const std::deque<ActionPrimitivesWayPoint> &wayPoints,
597 virtual bool reachPose(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
658 virtual bool addHandSeqWP(
const std::string &handSeqKey,
const yarp::sig::Vector &poss,
659 const yarp::sig::Vector &vels,
const yarp::sig::Vector &tols,
660 const yarp::sig::Vector &thres,
const double tmo);
670 const yarp::os::Bottle &sequence);
698 virtual bool getHandSequence(
const std::string &handSeqKey, yarp::os::Bottle &sequence);
754 virtual bool getCartesianIF(yarp::dev::ICartesianControl *&ctrl)
const;
791 virtual bool getPose(yarp::sig::Vector &
x, yarp::sig::Vector &o)
const;
968 virtual bool grasp(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
969 const yarp::sig::Vector &d);
993 virtual bool touch(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
994 const yarp::sig::Vector &d);
1021 virtual bool tap(
const yarp::sig::Vector &
x1,
const yarp::sig::Vector &o1,
1022 const yarp::sig::Vector &
x2,
const yarp::sig::Vector &o2,
1028class ActionPrimitivesLayer2;
1041 virtual void exec();
1055 virtual void exec();
1095 virtual void init();
1145 virtual bool open(yarp::os::Property &opt);
1156 virtual void close();
1173 virtual bool grasp(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
1174 const yarp::sig::Vector &d1,
const yarp::sig::Vector &d2);
1187 virtual bool grasp(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
1188 const yarp::sig::Vector &d);
1201 virtual bool touch(
const yarp::sig::Vector &
x,
const yarp::sig::Vector &o,
1202 const yarp::sig::Vector &d);
1210 virtual bool getExtWrench(yarp::sig::Vector &wrench)
const;
#define ACTIONPRIM_DISABLE_EXECTIME
Class for defining routines to be called when action is completed.
ActionPrimitivesCallback()
Default Constructor.
virtual void exec()=0
Defines the callback body to be called at the action end.
A derived class defining a first abstraction layer on top of actionPrimitives father class.
ActionPrimitivesLayer1()
Default Constructor.
virtual bool tap(const yarp::sig::Vector &x1, const yarp::sig::Vector &o1, const yarp::sig::Vector &x2, const yarp::sig::Vector &o2, const double execTime=ACTIONPRIM_DISABLE_EXECTIME)
Tap the given target (combined action).
virtual bool grasp(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const yarp::sig::Vector &d)
Grasp the given target (combined action).
ActionPrimitivesLayer1(yarp::os::Property &opt)
Constructor.
virtual bool touch(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const yarp::sig::Vector &d)
Touch the given target (combined action).
A class that inherits from ActionPrimitivesLayer1 and integrates the force-torque sensing in order to...
virtual bool disableContactDetection()
Self-explaining :)
virtual bool grasp(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const yarp::sig::Vector &d1, const yarp::sig::Vector &d2)
More evolute version of grasp.
virtual bool isContactDetectionEnabled(bool &f) const
Self-explaining :)
virtual bool open(yarp::os::Property &opt)
Configure the object.
virtual bool getExtForceThres(double &thres) const
Retrieve the current threshold on the external force used to stop the limb while reaching.
virtual bool isValid() const
Check if the object is initialized correctly.
virtual bool enableContactDetection()
Self-explaining :)
liftAndGraspCallback * execLiftAndGrasp
yarp::sig::Vector grasp_o
virtual bool getExtWrench(yarp::sig::Vector &wrench) const
Retrieve the current wrench on the end-effector.
virtual ~ActionPrimitivesLayer2()
Destructor.
virtual bool touch(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const yarp::sig::Vector &d)
More evolute version of touch, exploiting contact detection.
yarp::sig::Vector encDataArm
virtual bool checkContact(bool &f) const
Check whether the reaching has been stopped due to a contact with external objects.
yarp::sig::Vector wrenchExternal
virtual void close()
Deallocate the object.
virtual bool grasp(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const yarp::sig::Vector &d)
The usual grasp is still available.
yarp::sig::Vector encDataTorso
virtual bool setExtForceThres(const double thres)
Set the threshold on the external force used to stop the limb while reaching.
yarp::sig::Vector grasp_d2
ActionPrimitivesLayer2()
Default Constructor.
virtual void postReachCallback()
yarp::os::BufferedPort< yarp::sig::Vector > wbdynPortIn
touchCallback * execTouch
ActionPrimitivesLayer2(yarp::os::Property &opt)
Constructor.
The base class defining actions.
yarp::sig::Vector disableTorsoSw
virtual bool removeHandSeq(const std::string &handSeqKey)
Remove an already existing hand motion sequence.
std::vector< int > fingersJnts
std::multimap< int, int > fingers2JntsMap
ActionPrimitives(yarp::os::Property &opt)
Constructor.
virtual bool areFingersInPosition(bool &f)
Query if fingers are in position (cumulative response).
virtual void disableTorsoDof()
virtual bool lockActions()
Disable the possibility to yield any new action.
virtual void postReachCallback()
virtual bool syncCheckInterrupt(const bool disable=false)
Suddenly interrupt any blocking call that is pending on querying the action status.
virtual bool pushAction(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const double execTime=ACTIONPRIM_DISABLE_EXECTIME, ActionPrimitivesCallback *clb=NULL)
Insert the arm-primitive action reach for target in the actions queue.
virtual bool cmdHand(const Action &action)
virtual bool isValid() const
Check if the object is initialized correctly.
std::condition_variable cv_motionDoneEvent
virtual bool enableReachingTimeout(const double tmo)
Enable timeout while reaching.
perception::Model * graspModel
virtual bool execPendingHandSequences()
virtual bool _pushAction(const bool execArm, const yarp::sig::Vector &x, const yarp::sig::Vector &o, const double execTime, const bool oEnabled, const bool execHand, const HandWayPoint &handWP, const bool handSeqTerminator, ActionPrimitivesCallback *clb)
virtual bool getTorsoJoints(yarp::sig::Vector &torso)
Return the control status of torso joints.
virtual bool wait(const Action &action)
virtual bool setTorsoJoints(const yarp::sig::Vector &torso)
Change the control status of torso joints.
virtual bool pushAction(const yarp::sig::Vector &x, const double execTime=ACTIONPRIM_DISABLE_EXECTIME, ActionPrimitivesCallback *clb=NULL)
Insert the arm-primitive action reach for target in the actions queue.
std::deque< bool > fingerInPosition
std::set< int > fingersJntsSet
virtual bool handCheckMotionDone(const int jnt)
virtual bool setTrackingMode(const bool f)
Set the task space controller in tracking or non-tracking mode.
yarp::dev::PolyDriver polyHand
virtual bool disableArmWaving()
Disable the waving mode.
virtual bool addHandSequence(const std::string &handSeqKey, const yarp::os::Bottle &sequence)
Define an hand motion sequence from a configuration bottle.
virtual bool isValidHandSeq(const std::string &handSeqKey)
Check whether a sequence key is defined.
virtual ~ActionPrimitives()
Destructor.
virtual bool unlockActions()
Enable the possibility to yield new actions.
virtual bool getPose(yarp::sig::Vector &x, yarp::sig::Vector &o) const
Get the current arm pose.
virtual void close()
Deallocate the object.
iCub::action::ActionPrimitives::ActionsQueue actionsQueue
yarp::dev::IControlMode * modCtrl
ActionPrimitivesCallback * actionClb
virtual bool areFingersMoving(bool &f)
Query if fingers are moving.
virtual bool pushAction(const yarp::sig::Vector &x, const std::string &handSeqKey, const double execTime=ACTIONPRIM_DISABLE_EXECTIME, ActionPrimitivesCallback *clb=NULL)
Insert a combination of arm and hand primitive actions in the actions queue.
yarp::os::PeriodicThread * armWaver
virtual bool cmdArmWP(const Action &action)
virtual bool getHandSequence(const std::string &handSeqKey, yarp::os::Bottle &sequence)
Return a hand sequence.
virtual bool execQueuedAction()
virtual bool reachPosition(const yarp::sig::Vector &x, const double execTime=ACTIONPRIM_DISABLE_EXECTIME)
Immediately update the current reaching target (without affecting the actions queue) or initiate a ne...
std::mutex mtx_motionStartEvent
double latchTimerReachLog
virtual bool stopControl()
Stop any ongoing arm/hand movements.
virtual bool setDefaultExecTime(const double execTime)
Set the default arm movement execution time.
virtual bool cmdArm(const Action &action)
virtual bool getTrackingMode() const
Get the current controller mode.
virtual bool checkActionOnGoing(bool &f, const bool sync=false)
Check whether an action is still ongoing.
ActionPrimitives()
Default Constructor.
std::map< std::string, std::deque< HandWayPoint > > handSeqMap
yarp::sig::Vector enableTorsoSw
yarp::sig::Vector curGraspDetectionThres
virtual bool configHandSeq(yarp::os::Property &opt)
virtual double getDefaultExecTime() const
Get the current default arm movement execution time.
yarp::dev::IPositionControl * posCtrl
virtual bool configGraspModel(yarp::os::Property &opt)
virtual bool open(yarp::os::Property &opt)
Configure the object.
virtual bool getGraspModel(perception::Model *&model) const
Return the model used internally to detect external contacts.
virtual bool reachPose(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const double execTime=ACTIONPRIM_DISABLE_EXECTIME)
Immediately update the current reaching target (without affecting the actions queue) or initiate a ne...
virtual void printMessage(const int logtype, const char *format,...) const
yarp::sig::Vector curHandTols
yarp::dev::PolyDriver polyCart
virtual bool getActionsLockStatus() const
Return the actions lock status.
yarp::dev::IEncoders * encCtrl
std::mutex mtx_motionDoneEvent
virtual void enableTorsoDof()
virtual bool addHandSeqWP(const std::string &handSeqKey, const yarp::sig::Vector &poss, const yarp::sig::Vector &vels, const yarp::sig::Vector &tols, const yarp::sig::Vector &thres, const double tmo)
Define an hand WayPoint (WP) to be added at the bottom of the hand motion sequence pointed by the key...
std::set< int > fingersMovingJntsSet
virtual bool clearActionsQueue()
Empty the actions queue.
virtual bool getCartesianIF(yarp::dev::ICartesianControl *&ctrl) const
Return the cartesian interface used internally to control the limb.
virtual bool _pushAction(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const std::string &handSeqKey, const double execTime, ActionPrimitivesCallback *clb, const bool oEnabled)
yarp::sig::Vector curHandFinalPoss
virtual bool pushAction(const yarp::sig::Vector &x, const yarp::sig::Vector &o, const std::string &handSeqKey, const double execTime=ACTIONPRIM_DISABLE_EXECTIME, ActionPrimitivesCallback *clb=NULL)
Insert a combination of arm and hand primitive actions in the actions queue.
virtual bool disableReachingTimeout()
Disable timeout while reaching.
std::deque< std::string > getHandSeqList()
Return the list of available hand sequence keys.
virtual bool enableArmWaving(const yarp::sig::Vector &restPos)
Enable the waving mode that keeps on moving the arm around a predefined position.
virtual bool syncCheckReinstate()
Reinstate the blocking feature for future calls with sync switch on.
std::condition_variable cv_motionStartEvent
yarp::os::PeriodicThread * actionWP
virtual bool checkActionsDone(bool &f, const bool sync=false)
Check whether all the actions in queue are accomplished.
virtual bool isHandSeqEnded()
virtual bool handleTorsoDOF(yarp::os::Property &opt, const std::string &key)
virtual bool pushWaitState(const double tmo, ActionPrimitivesCallback *clb=NULL)
Insert a wait state in the actions queue.
yarp::dev::ICartesianControl * cartCtrl
ActionPrimitivesLayer2 * action
liftAndGraspCallback(ActionPrimitivesLayer2 *_action)
virtual void exec()
Defines the callback body to be called at the action end.
virtual void exec()
Defines the callback body to be called at the action end.
ActionPrimitivesLayer2 * action
touchCallback(ActionPrimitivesLayer2 *_action)
An abstract class that provides basic methods for interfacing with the data acquisition.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
Struct for defining way points used for movements in the operational space.
ActionPrimitivesCallback * callback
Action callback that is executed when the waypoint is reached.
yarp::sig::Vector o
The 4x1 Vector specifying the orientation of the waypoint in axis-angle representation.
double granularity
The time granularity [s] used by the trajectory generator [s].
ActionPrimitivesWayPoint()
Default Constructor.
double trajTime
The arm execution time [s] accounting for the controller's responsivity.
yarp::sig::Vector x
The 3x1 Vector specifyng the position of the waypoint [m].
bool oEnabled
If this flag is set to true then orientation will be taken into account.
double duration
The time duration [s] to achieve the waypoint.
yarp::os::PeriodicThread * wayPointsThr
ActionPrimitivesCallback * clb