iCub-main
Loading...
Searching...
No Matches
iKinIpOpt.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3 * Copyright (C) 2006-2010 RobotCub Consortium
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD-3-Clause license. See the accompanying LICENSE file for
8 * details.
9*/
10
25#ifndef __IKINIPOPT_H__
26#define __IKINIPOPT_H__
27
28#include <iCub/iKin/iKinInv.h>
29
30
31namespace iCub
32{
33
34namespace iKin
35{
36
43{
44private:
45 // Copy constructor: not implemented.
47 // Assignment operator: not implemented.
49
50public:
52
58 virtual void exec(const yarp::sig::Vector &xd, const yarp::sig::Vector &q) = 0;
59};
60
61
69{
70protected:
71 yarp::sig::Matrix C;
72 yarp::sig::Vector uB;
73 yarp::sig::Vector lB;
74
77 bool active;
78
79 virtual void clone(const iKinLinIneqConstr *obj);
80
81public:
86
96 iKinLinIneqConstr(const double _lowerBoundInf, const double _upperBoundInf);
97
104
111 virtual iKinLinIneqConstr &operator=(const iKinLinIneqConstr &obj);
112
117 yarp::sig::Matrix &getC() { return C; }
118
123 yarp::sig::Vector &getuB() { return uB; }
124
129 yarp::sig::Vector &getlB() { return lB; }
130
135 double &getLowerBoundInf() { return lowerBoundInf; }
136
141 double &getUpperBoundInf() { return upperBoundInf; }
142
147 bool isActive() { return active; }
148
153 void setActive(bool _active) { active=_active; }
154
161 virtual void update(void*) { }
162};
163
164
171{
172protected:
173 double shou_m, shou_n;
174 double elb_m, elb_n;
175
178
179 void clone(const iKinLinIneqConstr *obj);
180
181public:
187
188 void update(void*);
189};
190
191
198{
199private:
200 // Default constructor: not implemented.
201 iKinIpOptMin();
202 // Copy constructor: not implemented.
204 // Assignment operator: not implemented.
205 iKinIpOptMin &operator=(const iKinIpOptMin&);
206
207protected:
208 void *App;
209
212
215
216 unsigned int ctrlPose;
217
219 double x_scaling;
220 double g_scaling;
223 std::string posePriority;
224
225public:
247 iKinIpOptMin(iKinChain &c, const unsigned int _ctrlPose,
248 const double tol, const double constr_tol,
249 const int max_iter=IKINCTRL_DISABLED,
250 const unsigned int verbose=0, bool useHessian=true);
251
259 void set_ctrlPose(const unsigned int _ctrlPose);
260
265 unsigned int get_ctrlPose() const { return ctrlPose; }
266
273 bool set_posePriority(const std::string &priority);
274
279 std::string get_posePriority() const { return posePriority; }
280
287 void attachLIC(iKinLinIneqConstr &lic) { pLIC=&lic; }
288
296
303 void specify2ndTaskEndEff(const unsigned int n);
304
310
316 void setMaxIter(const int max_iter);
317
322 int getMaxIter() const;
323
329 void setMaxCpuTime(const double max_cpu_time);
330
335 double getMaxCpuTime() const;
336
341 void setTol(const double tol);
342
347 double getTol() const;
348
353 void setConstrTol(const double constr_tol);
354
359 double getConstrTol() const;
360
368 void setVerbosity(const unsigned int verbose);
369
376 void setHessianOpt(const bool useHessian);
377
386 void setUserScaling(const bool useUserScaling, const double _obj_scaling,
387 const double _x_scaling, const double _g_scaling);
388
397 void setDerivativeTest(const bool enableTest, const bool enable2ndDer=false);
398
404 void getBoundsInf(double &lower, double &upper);
405
411 void setBoundsInf(const double lower, const double upper);
412
451 virtual yarp::sig::Vector solve(const yarp::sig::Vector &q0, yarp::sig::Vector &xd,
452 double weight2ndTask, yarp::sig::Vector &xd_2nd, yarp::sig::Vector &w_2nd,
453 double weight3rdTask, yarp::sig::Vector &qd_3rd, yarp::sig::Vector &w_3rd,
454 int *exit_code=NULL, bool *exhalt=NULL, iKinIterateCallback *iterate=NULL);
455
470 virtual yarp::sig::Vector solve(const yarp::sig::Vector &q0, yarp::sig::Vector &xd,
471 double weight2ndTask, yarp::sig::Vector &xd_2nd, yarp::sig::Vector &w_2nd);
472
479 virtual yarp::sig::Vector solve(const yarp::sig::Vector &q0, yarp::sig::Vector &xd);
480
484 virtual ~iKinIpOptMin();
485};
486
487}
488
489}
490
491#endif
492
493
Class for dealing with additional iCub arm's constraints.
Definition iKinIpOpt.h:171
void update(void *)
Updates internal state.
void clone(const iKinLinIneqConstr *obj)
Definition iKinIpOpt.cpp:80
A class for defining the iCub Arm.
Definition iKinFwd.h:1193
A Base class for defining a Serial Link Chain.
Definition iKinFwd.h:354
Class for inverting chain's kinematics based on IpOpt lib.
Definition iKinIpOpt.h:198
void attachLIC(iKinLinIneqConstr &lic)
Attach a iKinLinIneqConstr object in order to impose constraints of the form lB <= C*q <= uB.
Definition iKinIpOpt.h:287
void setTol(const double tol)
Sets cost function tolerance.
double getConstrTol() const
Retrieves constraints tolerance.
iKinLinIneqConstr & getLIC()
Returns a reference to the attached Linear Inequality Constraints object.
Definition iKinIpOpt.h:295
double getMaxCpuTime() const
Retrieves the current value of Maximum CPU seconds.
std::string get_posePriority() const
Returns the Pose priority settings.
Definition iKinIpOpt.h:279
void setConstrTol(const double constr_tol)
Sets constraints tolerance.
iKinLinIneqConstr * pLIC
Definition iKinIpOpt.h:214
void setHessianOpt(const bool useHessian)
Selects whether to rely on exact Hessian computation or enable Quasi-Newton approximation (Hessian is...
void setUserScaling(const bool useUserScaling, const double _obj_scaling, const double _x_scaling, const double _g_scaling)
Enables/disables user scaling factors.
bool set_posePriority(const std::string &priority)
Sets the Pose priority for weighting more either position or orientation while reaching in full pose.
unsigned int get_ctrlPose() const
Returns the state of Pose control settings.
Definition iKinIpOpt.h:265
virtual ~iKinIpOptMin()
Default destructor.
int getMaxIter() const
Retrieves the current value of Maximum Iteration.
double getTol() const
Retrieves cost function tolerance.
void setMaxIter(const int max_iter)
Sets Maximum Iteration.
void getBoundsInf(double &lower, double &upper)
Returns the lower and upper bounds to represent -inf and +inf.
iKinLinIneqConstr noLIC
Definition iKinIpOpt.h:213
void setDerivativeTest(const bool enableTest, const bool enable2ndDer=false)
Enable\disable derivative test at each call to solve method (disabled at start-up by default).
iKinChain & get2ndTaskChain()
Retrieves the 2nd task's chain.
void setBoundsInf(const double lower, const double upper)
Sets the lower and upper bounds to represent -inf and +inf.
void set_ctrlPose(const unsigned int _ctrlPose)
Sets the state of Pose control settings.
void specify2ndTaskEndEff(const unsigned int n)
Selects the End-Effector of the 2nd task by giving the ordinal number n of last joint pointing at it.
virtual yarp::sig::Vector solve(const yarp::sig::Vector &q0, yarp::sig::Vector &xd, double weight2ndTask, yarp::sig::Vector &xd_2nd, yarp::sig::Vector &w_2nd, double weight3rdTask, yarp::sig::Vector &qd_3rd, yarp::sig::Vector &w_3rd, int *exit_code=NULL, bool *exhalt=NULL, iKinIterateCallback *iterate=NULL)
Executes the IpOpt algorithm trying to converge on target.
void setVerbosity(const unsigned int verbose)
Sets Verbosity.
void setMaxCpuTime(const double max_cpu_time)
Sets Maximum CPU seconds.
Class for defining iteration callback.
Definition iKinIpOpt.h:43
virtual void exec(const yarp::sig::Vector &xd, const yarp::sig::Vector &q)=0
Defines the callback body to be called at each iteration.
Class for defining Linear Inequality Constraints of the form lB <= C*q <= uB for the nonlinear proble...
Definition iKinIpOpt.h:69
virtual iKinLinIneqConstr & operator=(const iKinLinIneqConstr &obj)
Copies a LinIneqConstr object into the current one.
Definition iKinIpOpt.cpp:71
yarp::sig::Matrix & getC()
Returns a reference to the constraints matrix C.
Definition iKinIpOpt.h:117
double & getUpperBoundInf()
Returns a reference to the internal representation of +inf.
Definition iKinIpOpt.h:141
bool isActive()
Returns the state of inequality constraints evaluation.
Definition iKinIpOpt.h:147
yarp::sig::Vector & getlB()
Returns a reference to the lower bounds vector lB.
Definition iKinIpOpt.h:129
virtual void update(void *)
Updates internal state.
Definition iKinIpOpt.h:161
virtual void clone(const iKinLinIneqConstr *obj)
Definition iKinIpOpt.cpp:51
yarp::sig::Vector & getuB()
Returns a reference to the upper bounds vector uB.
Definition iKinIpOpt.h:123
double & getLowerBoundInf()
Returns a reference to the internal representation of -inf.
Definition iKinIpOpt.h:135
void setActive(bool _active)
Sets the state of inequality constraints evaluation.
Definition iKinIpOpt.h:153
iKinLinIneqConstr()
Default Constructor.
Definition iKinIpOpt.cpp:32
int n
#define IKINCTRL_DISABLED
Definition iKinInv.h:50
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.