141#include <yarp/os/LogStream.h> 
  142#include <yarp/os/Searchable.h> 
  143#include <yarp/os/Property.h> 
  144#include <yarp/os/Value.h> 
  145#include <yarp/os/Bottle.h> 
  146#include <yarp/os/Network.h> 
  147#include <yarp/os/ResourceFinder.h> 
  148#include <yarp/os/RFModule.h> 
  149#include <yarp/sig/Vector.h> 
  150#include <yarp/sig/Matrix.h> 
  151#include <yarp/math/Math.h> 
  156using namespace yarp::os;
 
  157using namespace yarp::sig;
 
  158using namespace yarp::math;
 
  189    if (options.check(
"LIC_num")) {
 
  190      auto LIC_num = options.find(
"LIC_num").asInt32();
 
  192        for (
auto i = 0; i < LIC_num; i++) {
 
  195          Bottle& group = options.findGroup(tag.str());
 
  196          if (group.isNull()) {
 
  197            yError() << 
"Unable to find group \"" << tag.str() << 
"\"";
 
  200          Bottle* row = group.find(
"C").asList();
 
  201          if (row == 
nullptr) {
 
  202            yError() << 
"Unable to find option \"C\" for group \"" << tag.str() << 
"\"";
 
  206            yError() << 
"Option \"C\" of group \"" << tag.str() << 
"\" has wrong size";
 
  210          for (
auto i = 0; i < row->size(); i++) {
 
  217        yInfo() << 
"Detected generic linear inequalities constraints";
 
 
  231      for (
auto i = 0U; i < 
chain->
getN(); i++) {
 
 
 
  248  shared_ptr<iKinLimb> limb{
nullptr};
 
  249  shared_ptr<GenericLinIneqConstr> cns{
nullptr};
 
  250  shared_ptr<PartDescriptor> desc{
nullptr};
 
  255    if (!options.check(
"robot")) {
 
  256      yError() << 
"\"robot\" option is missing!";
 
  260    if (!options.check(
"NumberOfDrivers")) {
 
  261      yError() << 
"\"NumberOfDrivers\" option is missing!";
 
  265    string robot = options.find(
"robot").asString();
 
  266    yInfo() << 
"Configuring solver for " << robot << 
" ...";
 
  268    Property linksOptions;
 
  270    limb = shared_ptr<iKinLimb>(
new iKinLimb(linksOptions));
 
  271    if (!limb->isValid()) {
 
  272      yError() << 
"invalid links parameters!";
 
  278    desc->lmb = limb.get();
 
  279    desc->chn = limb->asChain();
 
  280    desc->cns = cns.get();
 
  282    bool failure = 
false;
 
  283    desc->num = options.find(
"NumberOfDrivers").asInt32();
 
  284    for (
int cnt = 0; cnt < desc->num; cnt++) {
 
  286      str << 
"driver_" << cnt;
 
  287      Bottle& driver = options.findGroup(str.str());
 
  288      if (driver.isNull()) {
 
  289        yError() << 
"\"" << str.str() << 
"\" option is missing!";
 
  294      if (!driver.check(
"Key")) {
 
  295        yError() << 
"\"Key\" option is missing!";
 
  300      if (!driver.check(
"JointsOrder")) {
 
  301        yError() << 
"\"JointsOrder\" option is missing!";
 
  306      string part = driver.find(
"Key").asString();
 
  307      bool directOrder = (driver.find(
"JointsOrder").asString() == 
"direct");
 
  310      optPart.put(
"device", 
"remote_controlboard");
 
  311      optPart.put(
"remote", 
"/" + robot + 
"/" + part);
 
  312      optPart.put(
"local", 
"/" + 
slvName + 
"/" + part);
 
  313      optPart.put(
"robot", robot);
 
  314      optPart.put(
"part", part);
 
  315      desc->prp.push_back(optPart);
 
  316      desc->rvs.push_back(!directOrder);
 
  319    return (failure ? 
nullptr : desc.get());
 
 
 
  332  shared_ptr<CartesianSolver> 
slv{
nullptr};
 
  337    string part, slvName;
 
  338    if (rf.check(
"part")) {
 
  339      part = rf.find(
"part").asString();
 
  341      yError() << 
"part option is not specified";
 
  345    Bottle& group = rf.findGroup(part);
 
  346    if (group.isNull()) {
 
  347      yError() << 
"unable to locate " << part << 
" definition";
 
  351    if (group.check(
"name")) {
 
  352      slvName = group.find(
"name").asString();
 
  354      yError() << 
"name option is missing";
 
  358    if (group.check(
"CustomKinFile")) {
 
  359      yInfo() << 
"Custom Cartesian Solver detected!";
 
  361      ResourceFinder rf_kin;
 
  362      rf_kin.setDefaultContext(rf.getContext());
 
  363      rf_kin.configure(0, 
nullptr);
 
  367    } 
else if ((part == 
"left_arm") || (part == 
"right_arm")) {
 
  369    } 
else if ((part == 
"left_leg") || (part == 
"right_leg")) {
 
  372      yError() << part << 
" is invalid";
 
  376    return slv->open(group);
 
 
  395    if (
slv->isClosed()) {
 
  399    if (
slv->getTimeoutFlag()) {
 
  400      slv->getTimeoutFlag() = 
false;
 
 
 
  410int main(
int argc, 
char* argv[]) {
 
  412  if (!
yarp.checkNetwork()) {
 
  413    yError() << 
"YARP server not available!";
 
  418  rf.setDefaultContext(
"cartesianSolver");
 
  419  rf.setDefaultConfigFile(
"cartesianSolver.ini");
 
  420  rf.configure(argc, argv);
 
  423  return mod.runModule(rf);
 
 
PartDescriptor * getPartDesc(Searchable &options)
 
CustomCartesianSolver(const string &name)
 
void clone(const iKinLinIneqConstr *obj) override
 
void update(void *) override
Updates internal state.
 
GenericLinIneqConstr(iKinChain *chain_, Searchable &options)
 
shared_ptr< CartesianSolver > slv
 
bool configure(ResourceFinder &rf)
 
Abstract class defining the core of on-line solvers.
 
Derived class which implements the on-line solver for the chain torso+arm.
 
Derived class which implements the on-line solver for the leg chain.
 
A Base class for defining a Serial Link Chain.
 
bool isLinkBlocked(const unsigned int i)
Queries whether the ith Link is blocked.
 
yarp::sig::Vector getAng()
Returns the current free joint angles values.
 
unsigned int getN() const
Returns the number of Links belonging to the Chain.
 
A class for defining generic Limb.
 
Class for defining Linear Inequality Constraints of the form lB <= C*q <= uB for the nonlinear proble...
 
yarp::sig::Matrix & getC()
Returns a reference to the constraints matrix C.
 
yarp::sig::Vector & getlB()
Returns a reference to the lower bounds vector lB.
 
virtual void clone(const iKinLinIneqConstr *obj)
 
yarp::sig::Vector & getuB()
Returns a reference to the upper bounds vector uB.
 
void setActive(bool _active)
Sets the state of inequality constraints evaluation.
 
static string pathToCustomKinFile
 
Copyright (C) 2008 RobotCub Consortium.