예제 #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool dynContact::read(ConnectionReader& connection){
    // auto-convert text mode interaction
    connection.convertTextMode();

    // represent a dynContact as a list of 4 elements that are:
    // - a list of 3 int, i.e. contactId, bodyPart, linkNumber
    // - a list of 3 double, i.e. the CoP
    // - a list of 3 double, i.e. the force
    // - a list of 3 double, i.e. the moment
    if(connection.expectInt()!= BOTTLE_TAG_LIST || connection.expectInt()!=4)
        return false;
    // - a list of 3 int, i.e. contactId, bodyPart, linkNumber
    if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_INT || connection.expectInt()!=3)
        return false;
    contactId   = connection.expectInt();
    bodyPart    = (BodyPart)connection.expectInt();
    linkNumber  = connection.expectInt();
    // - a list of 3 double, i.e. the CoP
    if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3)
        return false;
    for(int i=0;i<3;i++) CoP[i] = connection.expectDouble();
    // - a list of 3 double, i.e. the force
    if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3)
        return false;
    for(int i=0;i<3;i++) F[i] = connection.expectDouble();
    setForce(F);
    // - a list of 3 double, i.e. the moment
    if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3)
        return false;
    for(int i=0;i<3;i++) Mu[i] = connection.expectDouble();
     
    return !connection.isError();
}
예제 #2
0
파일: WireReader.cpp 프로젝트: apaikan/yarp
WireReader::WireReader(ConnectionReader& reader) : reader(reader)
{
    reader.convertTextMode();
    state = &baseState;
    flush_if_needed = false;
    get_mode = false;
    support_get_mode = false;
    expecting = false;
}
예제 #3
0
파일: Stamp.cpp 프로젝트: paulfitz/yarp
bool Stamp::read(ConnectionReader& connection) {
    connection.convertTextMode();
    int header = connection.expectInt();
    if (header!=BOTTLE_TAG_LIST) { return false; }
    int len = connection.expectInt();
    if (len!=2) { return false; }
    int code;
    code = connection.expectInt();
    if (code!=BOTTLE_TAG_INT) { return false; }
    sequenceNumber = connection.expectInt();
    code = connection.expectInt();
    if (code!=BOTTLE_TAG_DOUBLE) { return false; }
    timeStamp = connection.expectDouble();
    if (connection.isError()) {
        sequenceNumber = -1;
        timeStamp = 0;
        return false;
    }
    return true;
}