Ejemplo n.º 1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Status iCub::skinForceControl::bottleToVector(const Bottle& b, Vector& v) throw()
{
    Status res;
    for(int i=0; i<b.size(); i++)
    {
        const Value &x = b.get(i);
        if(x.isDouble())
            v.push_back(x.asDouble());
        else if(x.isInt())
            v.push_back(x.asInt());
        else if(x.isList())
            if(x.asList()->size()!=0)
                bottleToVector(*(x.asList()), v);
        else
            res.addErrMsg("Error converting bottle to vector: "+string(x.asString().c_str())+" is not a number.");
    }
    return res;
}