3 #include <hrpModel/Sensor.h> 18 rs->angle.length(m_robot->numJoints()); \ 19 m_robot->readJointAngles(rs->angle.get_buffer()); \ 21 rs->command.length(m_robot->numJoints()); \ 22 m_robot->readJointCommands(rs->command.get_buffer()); \ 24 rs->torque.length(m_robot->numJoints()); \ 25 if (!m_robot->readJointTorques(rs->torque.get_buffer())){ \ 26 for (unsigned int i=0; i<rs->torque.length(); i++){ \ 27 rs->torque[i] = 0.0; \ 31 rs->servoState.length(m_robot->numJoints()); \ 33 for(unsigned int i=0; i < rs->servoState.length(); ++i){ \ 34 size_t len = m_robot->lengthOfExtraServoState(i)+1; \ 35 rs->servoState[i].length(len); \ 37 v = m_robot->readCalibState(i); \ 38 status |= v<< OpenHRP::RobotHardwareService::CALIB_STATE_SHIFT; \ 39 v = m_robot->readPowerState(i); \ 40 status |= v<< OpenHRP::RobotHardwareService::POWER_STATE_SHIFT; \ 41 v = m_robot->readServoState(i); \ 42 status |= v<< OpenHRP::RobotHardwareService::SERVO_STATE_SHIFT; \ 43 v = m_robot->readServoAlarm(i); \ 44 status |= v<< OpenHRP::RobotHardwareService::SERVO_ALARM_SHIFT; \ 45 v = m_robot->readDriverTemperature(i); \ 46 status |= v<< OpenHRP::RobotHardwareService::DRIVER_TEMP_SHIFT; \ 47 rs->servoState[i][0] = status; \ 48 m_robot->readExtraServoState(i, (int *)(rs->servoState[i].get_buffer()+1)); \ 51 rs->rateGyro.length(m_robot->numSensors(Sensor::RATE_GYRO)); \ 52 for (unsigned int i=0; i<rs->rateGyro.length(); i++){ \ 53 rs->rateGyro[i].length(3); \ 54 m_robot->readGyroSensor(i, rs->rateGyro[i].get_buffer()); \ 57 rs->accel.length(m_robot->numSensors(Sensor::ACCELERATION)); \ 58 for (unsigned int i=0; i<rs->accel.length(); i++){ \ 59 rs->accel[i].length(3); \ 60 m_robot->readAccelerometer(i, rs->accel[i].get_buffer()); \ 63 rs->force.length(m_robot->numSensors(Sensor::FORCE)); \ 64 for (unsigned int i=0; i<rs->force.length(); i++){ \ 65 rs->force[i].length(6); \ 66 m_robot->readForceSensor(i, rs->force[i].get_buffer()); \ 69 m_robot->readPowerStatus(rs->voltage, rs->current); 73 rs =
new OpenHRP::RobotHardwareService::RobotState();
80 rs =
new OpenHRP::RobotHardwareService::RobotState2();
84 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 2 85 rs->batteries.length(
m_robot->numBatteries());
86 for(
unsigned int i=0;
i<rs->batteries.length();
i++){
88 rs->batteries[
i].voltage,
89 rs->batteries[
i].current,
90 rs->batteries[
i].soc);
92 rs->temperature.length(
m_robot->numThermometers());
93 for (
unsigned int i=0;
i<rs->temperature.length();
i++){
94 m_robot->readThermometer(
i, rs->temperature[
i]);
101 return m_robot->power(jname, ss==OpenHRP::RobotHardwareService::SWITCH_ON);
106 return m_robot->servo(jname, ss==OpenHRP::RobotHardwareService::SWITCH_ON);
111 m_robot->startInertiaSensorCalibration();
116 m_robot->removeForceSensorOffset();
121 m_robot->initializeJointAngle(name, option);
126 m_robot->setServoGainPercentage(jname, percentage);
131 m_robot->setServoTorqueGainPercentage(jname, percentage);
136 m_robot->setServoErrorLimit(jname, limit);
141 std::vector<std::string> joints;
142 joints.resize(jnames.length());
143 for (
unsigned int i=0;
i<jnames.length();
i++){
144 joints[
i] = jnames[
i];
146 return m_robot->addJointGroup(gname, joints);
151 din = new ::OpenHRP::RobotHardwareService::OctSequence();
153 return m_robot->readDigitalInput((
char *)(din->get_buffer()));
158 return m_robot->lengthDigitalInput();
163 return m_robot->writeDigitalOutput((
const char *)(dout.get_buffer()));
168 return m_robot->writeDigitalOutputWithMask((
const char *)(dout.get_buffer()), (
const char *)(mask.get_buffer()));
173 return m_robot->lengthDigitalOutput();
178 dout = new ::OpenHRP::RobotHardwareService::OctSequence();
180 return m_robot->readDigitalOutput((
char *)(dout->get_buffer()));
185 m_robot->setJointInertia(name, mn);
190 m_robot->setJointInertias(mns.get_buffer());
196 m_robot->enableDisturbanceObserver();
201 m_robot->disableDisturbanceObserver();
206 m_robot->setDisturbanceObserverGain(gain);
213 case OpenHRP::RobotHardwareService::FREE:
216 case OpenHRP::RobotHardwareService::POSITION:
219 case OpenHRP::RobotHardwareService::TORQUE:
222 case OpenHRP::RobotHardwareService::VELOCITY:
225 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4 226 case OpenHRP::RobotHardwareService::POSITION_TORQUE:
227 mode = JCM_POSITION_TORQUE;
233 m_robot->setJointControlMode(jname, mode);
CORBA::Long lengthDigitalInput()
virtual ~RobotHardwareService_impl()
RobotHardwareService_impl()
void getStatus(OpenHRP::RobotHardwareService::RobotState_out rs)
CORBA::Boolean addJointGroup(const char *gname, const OpenHRP::RobotHardwareService::StrSequence &jnames)
void setJointControlMode(const char *jname, OpenHRP::RobotHardwareService::JointControlMode jcm)
CORBA::Boolean writeDigitalOutput(const ::OpenHRP::RobotHardwareService::OctSequence &dout)
CORBA::Boolean readDigitalOutput(::OpenHRP::RobotHardwareService::OctSequence_out dout)
void setServoTorqueGainPercentage(const char *jname, double limit)
boost::shared_ptr< robot > m_robot
void setDisturbanceObserverGain(::CORBA::Double gain)
void getStatus2(OpenHRP::RobotHardwareService::RobotState2_out rs)
void removeForceSensorOffset()
CORBA::Boolean writeDigitalOutputWithMask(const ::OpenHRP::RobotHardwareService::OctSequence &dout, const ::OpenHRP::RobotHardwareService::OctSequence &mask)
CORBA::Long lengthDigitalOutput()
void disableDisturbanceObserver()
void calibrateInertiaSensor()
CORBA::Boolean setJointInertia(const char *name,::CORBA::Double mn)
CORBA::Boolean readDigitalInput(::OpenHRP::RobotHardwareService::OctSequence_out din)
void setJointInertias(const ::OpenHRP::RobotHardwareService::DblSequence &mns)
void enableDisturbanceObserver()
CORBA::Boolean power(const char *jname, OpenHRP::RobotHardwareService::SwitchStatus ss)
void setServoGainPercentage(const char *jname, double limit)
CORBA::Boolean servo(const char *jname, OpenHRP::RobotHardwareService::SwitchStatus ss)
void initializeJointAngle(const char *name, const char *option)
void setServoErrorLimit(const char *jname, double limit)