Exemple #1
0
bool wholeBodyDynamicsSettings::Editor::read(yarp::os::ConnectionReader& connection) {
  if (!isValid()) return false;
  yarp::os::idl::WireReader reader(connection);
  reader.expectAccept();
  if (!reader.readListHeader()) return false;
  int len = reader.getLength();
  if (len==0) {
    yarp::os::idl::WireWriter writer(reader);
    if (writer.isNull()) return true;
    if (!writer.writeListHeader(1)) return false;
    writer.writeString("send: 'help' or 'patch (param1 val1) (param2 val2)'");
    return true;
  }
  yarp::os::ConstString tag;
  if (!reader.readString(tag)) return false;
  if (tag=="help") {
    yarp::os::idl::WireWriter writer(reader);
    if (writer.isNull()) return true;
    if (!writer.writeListHeader(2)) return false;
    if (!writer.writeTag("many",1, 0)) return false;
    if (reader.getLength()>0) {
      yarp::os::ConstString field;
      if (!reader.readString(field)) return false;
      if (field=="kinematicSource") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("KinematicSourceType kinematicSource")) return false;
      }
      if (field=="fixedFrameName") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("std::string fixedFrameName")) return false;
        if (!writer.writeString("Specify the source of the kinematic information for one link, see KinematicSourceType information for more info.")) return false;
      }
      if (field=="fixedFrameGravity") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("Gravity fixedFrameGravity")) return false;
        if (!writer.writeString("If kinematicSource is FIXED_LINK, specify the frame of the robot that we know to be fixed (i.e. not moving with respect to an inertial frame)")) return false;
      }
      if (field=="imuFrameName") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("std::string imuFrameName")) return false;
        if (!writer.writeString("If kinematicSource is FIXED_LINK, specify the gravity vector (in m/s^2) in the fixedFrame")) return false;
      }
      if (field=="imuFilterCutoffInHz") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("double imuFilterCutoffInHz")) return false;
        if (!writer.writeString("If kinematicSource is IMU, specify the frame name of the imu")) return false;
      }
      if (field=="forceTorqueFilterCutoffInHz") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("double forceTorqueFilterCutoffInHz")) return false;
        if (!writer.writeString("Cutoff frequency (in Hz) of the first order filter of the IMU")) return false;
      }
      if (field=="jointVelFilterCutoffInHz") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("double jointVelFilterCutoffInHz")) return false;
        if (!writer.writeString("Cutoff frequency(in Hz) of the first order filter of the F/T sensors")) return false;
      }
      if (field=="jointAccFilterCutoffInHz") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("double jointAccFilterCutoffInHz")) return false;
        if (!writer.writeString("Cutoff frequency(in Hz) of the first order filter of the joint velocities")) return false;
      }
      if (field=="useJointVelocity") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("bool useJointVelocity")) return false;
        if (!writer.writeString("Cutoff frequency(in Hz) of the first order filter of the joint accelerations")) return false;
      }
      if (field=="useJointAcceleration") {
        if (!writer.writeListHeader(2)) return false;
        if (!writer.writeString("bool useJointAcceleration")) return false;
        if (!writer.writeString("Use the joint velocity measurement if this is true, assume they are zero otherwise.")) return false;
      }
    }
    if (!writer.writeListHeader(11)) return false;
    writer.writeString("*** Available fields:");
    writer.writeString("kinematicSource");
    writer.writeString("fixedFrameName");
    writer.writeString("fixedFrameGravity");
    writer.writeString("imuFrameName");
    writer.writeString("imuFilterCutoffInHz");
    writer.writeString("forceTorqueFilterCutoffInHz");
    writer.writeString("jointVelFilterCutoffInHz");
    writer.writeString("jointAccFilterCutoffInHz");
    writer.writeString("useJointVelocity");
    writer.writeString("useJointAcceleration");
    return true;
  }
  bool nested = true;
  bool have_act = false;
  if (tag!="patch") {
    if ((len-1)%2 != 0) return false;
    len = 1 + ((len-1)/2);
    nested = false;
    have_act = true;
  }
  for (int i=1; i<len; i++) {
    if (nested && !reader.readListHeader(3)) return false;
    yarp::os::ConstString act;
    yarp::os::ConstString key;
    if (have_act) {
      act = tag;
    } else {
      if (!reader.readString(act)) return false;
    }
    if (!reader.readString(key)) return false;
    // inefficient code follows, bug paulfitz to improve it
    if (key == "kinematicSource") {
      will_set_kinematicSource();
      if (!obj->nested_read_kinematicSource(reader)) return false;
      did_set_kinematicSource();
    } else if (key == "fixedFrameName") {
      will_set_fixedFrameName();
      if (!obj->nested_read_fixedFrameName(reader)) return false;
      did_set_fixedFrameName();
    } else if (key == "fixedFrameGravity") {
      will_set_fixedFrameGravity();
      if (!obj->nested_read_fixedFrameGravity(reader)) return false;
      did_set_fixedFrameGravity();
    } else if (key == "imuFrameName") {
      will_set_imuFrameName();
      if (!obj->nested_read_imuFrameName(reader)) return false;
      did_set_imuFrameName();
    } else if (key == "imuFilterCutoffInHz") {
      will_set_imuFilterCutoffInHz();
      if (!obj->nested_read_imuFilterCutoffInHz(reader)) return false;
      did_set_imuFilterCutoffInHz();
    } else if (key == "forceTorqueFilterCutoffInHz") {
      will_set_forceTorqueFilterCutoffInHz();
      if (!obj->nested_read_forceTorqueFilterCutoffInHz(reader)) return false;
      did_set_forceTorqueFilterCutoffInHz();
    } else if (key == "jointVelFilterCutoffInHz") {
      will_set_jointVelFilterCutoffInHz();
      if (!obj->nested_read_jointVelFilterCutoffInHz(reader)) return false;
      did_set_jointVelFilterCutoffInHz();
    } else if (key == "jointAccFilterCutoffInHz") {
      will_set_jointAccFilterCutoffInHz();
      if (!obj->nested_read_jointAccFilterCutoffInHz(reader)) return false;
      did_set_jointAccFilterCutoffInHz();
    } else if (key == "useJointVelocity") {
      will_set_useJointVelocity();
      if (!obj->nested_read_useJointVelocity(reader)) return false;
      did_set_useJointVelocity();
    } else if (key == "useJointAcceleration") {
      will_set_useJointAcceleration();
      if (!obj->nested_read_useJointAcceleration(reader)) return false;
      did_set_useJointAcceleration();
    } else {
      // would be useful to have a fallback here
    }
  }
  reader.accept();
  yarp::os::idl::WireWriter writer(reader);
  if (writer.isNull()) return true;
  writer.writeListHeader(1);
  writer.writeVocab(VOCAB2('o','k'));
  return true;
}
bool ContactPoint::Editor::read(yarp::os::ConnectionReader& connection) {
  if (!isValid()) return false;
  yarp::os::idl::WireReader reader(connection);
  reader.expectAccept();
  if (!reader.readListHeader()) return false;
  int len = reader.getLength();
  if (len==0) {
    yarp::os::idl::WireWriter writer(reader);
    if (writer.isNull()) return true;
    if (!writer.writeListHeader(1)) return false;
    writer.writeString("send: 'help' or 'patch (param1 val1) (param2 val2)'");
    return true;
  }
  yarp::os::ConstString tag;
  if (!reader.readString(tag)) return false;
  if (tag=="help") {
    yarp::os::idl::WireWriter writer(reader);
    if (writer.isNull()) return true;
    if (!writer.writeListHeader(2)) return false;
    if (!writer.writeTag("many",1, 0)) return false;
    if (reader.getLength()>0) {
      yarp::os::ConstString field;
      if (!reader.readString(field)) return false;
      if (field=="x") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("double x")) return false;
      }
      if (field=="y") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("double y")) return false;
      }
      if (field=="z") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("double z")) return false;
      }
    }
    if (!writer.writeListHeader(4)) return false;
    writer.writeString("*** Available fields:");
    writer.writeString("x");
    writer.writeString("y");
    writer.writeString("z");
    return true;
  }
  bool nested = true;
  bool have_act = false;
  if (tag!="patch") {
    if ((len-1)%2 != 0) return false;
    len = 1 + ((len-1)/2);
    nested = false;
    have_act = true;
  }
  for (int i=1; i<len; i++) {
    if (nested && !reader.readListHeader(3)) return false;
    yarp::os::ConstString act;
    yarp::os::ConstString key;
    if (have_act) {
      act = tag;
    } else {
      if (!reader.readString(act)) return false;
    }
    if (!reader.readString(key)) return false;
    // inefficient code follows, bug paulfitz to improve it
    if (key == "x") {
      will_set_x();
      if (!obj->nested_read_x(reader)) return false;
      did_set_x();
    } else if (key == "y") {
      will_set_y();
      if (!obj->nested_read_y(reader)) return false;
      did_set_y();
    } else if (key == "z") {
      will_set_z();
      if (!obj->nested_read_z(reader)) return false;
      did_set_z();
    } else {
      // would be useful to have a fallback here
    }
  }
  reader.accept();
  yarp::os::idl::WireWriter writer(reader);
  if (writer.isNull()) return true;
  writer.writeListHeader(1);
  writer.writeVocab(VOCAB2('o','k'));
  return true;
}
Exemple #3
0
bool SensorStreamingData::Editor::read(yarp::os::ConnectionReader& connection) {
  if (!isValid()) return false;
  yarp::os::idl::WireReader reader(connection);
  reader.expectAccept();
  if (!reader.readListHeader()) return false;
  int len = reader.getLength();
  if (len==0) {
    yarp::os::idl::WireWriter writer(reader);
    if (writer.isNull()) return true;
    if (!writer.writeListHeader(1)) return false;
    writer.writeString("send: 'help' or 'patch (param1 val1) (param2 val2)'");
    return true;
  }
  std::string tag;
  if (!reader.readString(tag)) return false;
  if (tag=="help") {
    yarp::os::idl::WireWriter writer(reader);
    if (writer.isNull()) return true;
    if (!writer.writeListHeader(2)) return false;
    if (!writer.writeTag("many",1, 0)) return false;
    if (reader.getLength()>0) {
      std::string field;
      if (!reader.readString(field)) return false;
      if (field=="ThreeAxisGyroscopes") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements ThreeAxisGyroscopes")) return false;
      }
      if (field=="ThreeAxisLinearAccelerometers") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements ThreeAxisLinearAccelerometers")) return false;
      }
      if (field=="ThreeAxisMagnetometers") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements ThreeAxisMagnetometers")) return false;
      }
      if (field=="OrientationSensors") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements OrientationSensors")) return false;
      }
      if (field=="TemperatureSensors") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements TemperatureSensors")) return false;
      }
      if (field=="SixAxisForceTorqueSensors") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements SixAxisForceTorqueSensors")) return false;
      }
      if (field=="ContactLoadCellArrays") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements ContactLoadCellArrays")) return false;
      }
      if (field=="EncoderArrays") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements EncoderArrays")) return false;
      }
      if (field=="SkinPatches") {
        if (!writer.writeListHeader(1)) return false;
        if (!writer.writeString("SensorMeasurements SkinPatches")) return false;
      }
    }
    if (!writer.writeListHeader(10)) return false;
    writer.writeString("*** Available fields:");
    writer.writeString("ThreeAxisGyroscopes");
    writer.writeString("ThreeAxisLinearAccelerometers");
    writer.writeString("ThreeAxisMagnetometers");
    writer.writeString("OrientationSensors");
    writer.writeString("TemperatureSensors");
    writer.writeString("SixAxisForceTorqueSensors");
    writer.writeString("ContactLoadCellArrays");
    writer.writeString("EncoderArrays");
    writer.writeString("SkinPatches");
    return true;
  }
  bool nested = true;
  bool have_act = false;
  if (tag!="patch") {
    if ((len-1)%2 != 0) return false;
    len = 1 + ((len-1)/2);
    nested = false;
    have_act = true;
  }
  for (int i=1; i<len; i++) {
    if (nested && !reader.readListHeader(3)) return false;
    std::string act;
    std::string key;
    if (have_act) {
      act = tag;
    } else {
      if (!reader.readString(act)) return false;
    }
    if (!reader.readString(key)) return false;
    // inefficient code follows, bug paulfitz to improve it
    if (key == "ThreeAxisGyroscopes") {
      will_set_ThreeAxisGyroscopes();
      if (!obj->nested_read_ThreeAxisGyroscopes(reader)) return false;
      did_set_ThreeAxisGyroscopes();
    } else if (key == "ThreeAxisLinearAccelerometers") {
      will_set_ThreeAxisLinearAccelerometers();
      if (!obj->nested_read_ThreeAxisLinearAccelerometers(reader)) return false;
      did_set_ThreeAxisLinearAccelerometers();
    } else if (key == "ThreeAxisMagnetometers") {
      will_set_ThreeAxisMagnetometers();
      if (!obj->nested_read_ThreeAxisMagnetometers(reader)) return false;
      did_set_ThreeAxisMagnetometers();
    } else if (key == "OrientationSensors") {
      will_set_OrientationSensors();
      if (!obj->nested_read_OrientationSensors(reader)) return false;
      did_set_OrientationSensors();
    } else if (key == "TemperatureSensors") {
      will_set_TemperatureSensors();
      if (!obj->nested_read_TemperatureSensors(reader)) return false;
      did_set_TemperatureSensors();
    } else if (key == "SixAxisForceTorqueSensors") {
      will_set_SixAxisForceTorqueSensors();
      if (!obj->nested_read_SixAxisForceTorqueSensors(reader)) return false;
      did_set_SixAxisForceTorqueSensors();
    } else if (key == "ContactLoadCellArrays") {
      will_set_ContactLoadCellArrays();
      if (!obj->nested_read_ContactLoadCellArrays(reader)) return false;
      did_set_ContactLoadCellArrays();
    } else if (key == "EncoderArrays") {
      will_set_EncoderArrays();
      if (!obj->nested_read_EncoderArrays(reader)) return false;
      did_set_EncoderArrays();
    } else if (key == "SkinPatches") {
      will_set_SkinPatches();
      if (!obj->nested_read_SkinPatches(reader)) return false;
      did_set_SkinPatches();
    } else {
      // would be useful to have a fallback here
    }
  }
  reader.accept();
  yarp::os::idl::WireWriter writer(reader);
  if (writer.isNull()) return true;
  writer.writeListHeader(1);
  writer.writeVocab(VOCAB2('o','k'));
  return true;
}