iCub-main
Loading...
Searching...
No Matches
ClientCartesianController.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 RobotCub Consortium, European Commission FP6 Project IST-004370
3 * Author: Ugo Pattacini
4 * email: ugo.pattacini@iit.it
5 * website: www.robotcub.org
6 * Permission is granted to copy, distribute, and/or modify this program
7 * under the terms of the GNU General Public License, version 2 or any
8 * later version published by the Free Software Foundation.
9 *
10 * A copy of the license can be found at
11 * http://www.robotcub.org/icub/license/gpl.txt
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 * Public License for more details
17*/
18
19#ifndef __CLIENTCARTESIANCONTROLLER_H__
20#define __CLIENTCARTESIANCONTROLLER_H__
21
22#include <string>
23#include <set>
24#include <map>
25
26#include <yarp/os/all.h>
27#include <yarp/dev/all.h>
28#include <yarp/sig/all.h>
29
30#include <iCub/iKin/iKinHlp.h>
31
32
33// forward declaration
35
36
37/************************************************************************/
38class CartesianEventHandler : public yarp::os::BufferedPort<yarp::os::Bottle>
39{
40protected:
42 void onRead(yarp::os::Bottle &event);
43
44public:
47};
48
49
63class ClientCartesianController : public yarp::dev::DeviceDriver,
64 public yarp::dev::ICartesianControl,
66{
67protected:
69 bool closed;
70
71 double timeout;
73
74 yarp::sig::Vector pose;
75 yarp::os::Stamp poseStamp;
76
77 yarp::os::BufferedPort<yarp::sig::Vector> portState;
78 yarp::os::BufferedPort<yarp::os::Bottle> portCmd;
79 yarp::os::RpcClient portRpc;
80
81 std::set<int> contextIdList;
82 std::map<std::string,yarp::dev::CartesianEvent*> eventsMap;
85
86 void init();
87 bool deleteContexts();
88 void eventHandling(yarp::os::Bottle &event);
89 bool getInfoHelper(yarp::os::Bottle &info);
90
91public:
93 ClientCartesianController(yarp::os::Searchable &config);
94
95 bool open(yarp::os::Searchable &config);
96 bool close();
97
98 bool setTrackingMode(const bool f);
99 bool getTrackingMode(bool *f);
100 bool setReferenceMode(const bool f);
101 bool getReferenceMode(bool *f);
102 bool setPosePriority(const std::string &p);
103 bool getPosePriority(std::string &p);
104 bool getPose(yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL);
105 bool getPose(const int axis, yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL);
106 bool goToPose(const yarp::sig::Vector &xd, const yarp::sig::Vector &od, const double t=0.0);
107 bool goToPosition(const yarp::sig::Vector &xd, const double t=0.0);
108 bool goToPoseSync(const yarp::sig::Vector &xd, const yarp::sig::Vector &od, const double t=0.0);
109 bool goToPositionSync(const yarp::sig::Vector &xd, const double t=0.0);
110 bool getDesired(yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat,yarp::sig::Vector &qdhat);
111 bool askForPose(const yarp::sig::Vector &xd, const yarp::sig::Vector &od, yarp::sig::Vector &xdhat,
112 yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat);
113 bool askForPose(const yarp::sig::Vector &q0, const yarp::sig::Vector &xd, const yarp::sig::Vector &od,
114 yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat);
115 bool askForPosition(const yarp::sig::Vector &xd, yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat,
116 yarp::sig::Vector &qdhat);
117 bool askForPosition(const yarp::sig::Vector &q0, const yarp::sig::Vector &xd, yarp::sig::Vector &xdhat,
118 yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat);
119 bool getDOF(yarp::sig::Vector &curDof);
120 bool setDOF(const yarp::sig::Vector &newDof, yarp::sig::Vector &curDof);
121 bool getRestPos(yarp::sig::Vector &curRestPos);
122 bool setRestPos(const yarp::sig::Vector &newRestPos, yarp::sig::Vector &curRestPos);
123 bool getRestWeights(yarp::sig::Vector &curRestWeights);
124 bool setRestWeights(const yarp::sig::Vector &newRestWeights, yarp::sig::Vector &curRestWeights);
125 bool getLimits(const int axis, double *min, double *max);
126 bool setLimits(const int axis, const double min, const double max);
127 bool getTrajTime(double *t);
128 bool setTrajTime(const double t);
129 bool getInTargetTol(double *tol);
130 bool setInTargetTol(const double tol);
131 bool getJointsVelocities(yarp::sig::Vector &qdot);
132 bool getTaskVelocities(yarp::sig::Vector &xdot, yarp::sig::Vector &odot);
133 bool setTaskVelocities(const yarp::sig::Vector &xdot, const yarp::sig::Vector &odot);
134 bool attachTipFrame(const yarp::sig::Vector &x, const yarp::sig::Vector &o);
135 bool getTipFrame(yarp::sig::Vector &x, yarp::sig::Vector &o);
136 bool removeTipFrame();
137 bool checkMotionDone(bool *f);
138 bool waitMotionDone(const double period=0.1, const double timeout=0.0);
139 bool stopControl();
140 bool storeContext(int *id);
141 bool restoreContext(const int id);
142 bool deleteContext(const int id);
143 bool getInfo(yarp::os::Bottle &info);
144 bool registerEvent(yarp::dev::CartesianEvent &event);
145 bool unregisterEvent(yarp::dev::CartesianEvent &event);
146 bool tweakSet(const yarp::os::Bottle &options);
147 bool tweakGet(yarp::os::Bottle &options);
148
150};
151
152
153#endif
154
155
void setInterface(ClientCartesianController *interface)
ClientCartesianController * interface
void onRead(yarp::os::Bottle &event)
clientcartesiancontroller : implements the client part of the Cartesian Interface.
bool askForPose(const yarp::sig::Vector &q0, const yarp::sig::Vector &xd, const yarp::sig::Vector &od, yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat)
bool goToPosition(const yarp::sig::Vector &xd, const double t=0.0)
bool getJointsVelocities(yarp::sig::Vector &qdot)
bool getRestPos(yarp::sig::Vector &curRestPos)
bool getRestWeights(yarp::sig::Vector &curRestWeights)
bool tweakGet(yarp::os::Bottle &options)
bool getTipFrame(yarp::sig::Vector &x, yarp::sig::Vector &o)
bool getPose(yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL)
bool open(yarp::os::Searchable &config)
bool askForPosition(const yarp::sig::Vector &q0, const yarp::sig::Vector &xd, yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat)
bool goToPoseSync(const yarp::sig::Vector &xd, const yarp::sig::Vector &od, const double t=0.0)
bool getInfoHelper(yarp::os::Bottle &info)
bool getTaskVelocities(yarp::sig::Vector &xdot, yarp::sig::Vector &odot)
bool setPosePriority(const std::string &p)
bool getInfo(yarp::os::Bottle &info)
yarp::os::BufferedPort< yarp::os::Bottle > portCmd
bool getPose(const int axis, yarp::sig::Vector &x, yarp::sig::Vector &o, yarp::os::Stamp *stamp=NULL)
bool getLimits(const int axis, double *min, double *max)
bool askForPosition(const yarp::sig::Vector &xd, yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat)
bool attachTipFrame(const yarp::sig::Vector &x, const yarp::sig::Vector &o)
bool setRestPos(const yarp::sig::Vector &newRestPos, yarp::sig::Vector &curRestPos)
std::map< std::string, yarp::dev::CartesianEvent * > eventsMap
bool setRestWeights(const yarp::sig::Vector &newRestWeights, yarp::sig::Vector &curRestWeights)
ClientCartesianController(yarp::os::Searchable &config)
void eventHandling(yarp::os::Bottle &event)
bool waitMotionDone(const double period=0.1, const double timeout=0.0)
bool setTaskVelocities(const yarp::sig::Vector &xdot, const yarp::sig::Vector &odot)
yarp::os::BufferedPort< yarp::sig::Vector > portState
bool setDOF(const yarp::sig::Vector &newDof, yarp::sig::Vector &curDof)
bool unregisterEvent(yarp::dev::CartesianEvent &event)
bool getDesired(yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat)
bool registerEvent(yarp::dev::CartesianEvent &event)
bool goToPositionSync(const yarp::sig::Vector &xd, const double t=0.0)
bool setLimits(const int axis, const double min, const double max)
bool goToPose(const yarp::sig::Vector &xd, const yarp::sig::Vector &od, const double t=0.0)
bool getDOF(yarp::sig::Vector &curDof)
bool askForPose(const yarp::sig::Vector &xd, const yarp::sig::Vector &od, yarp::sig::Vector &xdhat, yarp::sig::Vector &odhat, yarp::sig::Vector &qdhat)
bool tweakSet(const yarp::os::Bottle &options)
Helper class providing useful methods to deal with Cartesian Solver options.
Definition iKinHlp.h:48