9 static std::vector<std::vector<double> >
forces;
10 static std::vector<std::vector<double> >
gyros;
23 #define CHECK_JOINT_ID(id) if ((id) < 0 || (id) >= number_of_joints()) return E_ID 24 #define CHECK_FORCE_SENSOR_ID(id) if ((id) < 0 || (id) >= number_of_force_sensors()) return E_ID 25 #define CHECK_ACCELEROMETER_ID(id) if ((id) < 0 || (id) >= number_of_accelerometers()) return E_ID 26 #define CHECK_GYRO_SENSOR_ID(id) if ((id) < 0 || (id) >= number_of_gyro_sensors()) return E_ID 27 #define CHECK_ATTITUDE_SENSOR_ID(id) if ((id) < 0 || (id) >= number_of_attitude_sensors()) return E_ID 29 #if (defined __APPLE__) 30 #include <mach/mach_time.h> 31 int clock_gettime(clockid_t clk_id,
struct timespec *tp)
33 if (clk_id != CLOCK_MONOTONIC)
return -1;
36 clk = mach_absolute_time();
38 static mach_timebase_info_data_t
info = {0,0};
39 if (info.denom == 0) mach_timebase_info(&info);
41 uint64_t elapsednano = clk * (info.numer / info.denom);
43 tp->tv_sec = elapsednano * 1e-9;
44 tp->tv_nsec = elapsednano - (tp->tv_sec * 1e9);
48 #define TIMER_ABSTIME 0 49 int clock_nanosleep(clockid_t clk_id,
int flags,
struct timespec *tp,
50 struct timespec *remain)
52 if (clk_id != CLOCK_MONOTONIC ||
flags != TIMER_ABSTIME)
return -1;
54 static mach_timebase_info_data_t
info = {0,0};
55 if (info.denom == 0) mach_timebase_info(&info);
57 uint64_t clk = (tp->tv_sec*1e9 + tp->tv_nsec)/(info.numer/info.denom);
77 return (
int)
gyros.size();
95 for (
int i=0;
i<num;
i++){
105 for (
unsigned int i=0;
i<
forces.size();
i++){
108 for (
int j=0;
j<6;
j++){
120 for (
unsigned int i=0;
i<
gyros.size();
i++){
123 for (
int j=0;
j<3;
j++){
138 for (
int j=0;
j<3;
j++){
151 for (
int j=0;
j<3;
j++){
298 for (
int i=0;
i<6;
i++){
299 forces[
i] = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*2
308 for (
int i=0;
i<3;
i++){
309 rates[
i] = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*0.01
317 for (
int i=0;
i<3;
i++){
318 double randv = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*0.01;
319 accels[
i] = (
i == 2 ? (9.8+randv) : randv)
403 std::cout <<
"dummy IOB is opened" << std::endl;
409 clock_gettime(CLOCK_MONOTONIC, &
g_ts);
415 std::cout <<
"dummy IOB is closed" << std::endl;
434 for (
int i=0;
i<3;
i++){
442 for (
int i=0;
i<3;
i++){
450 for (
int i=0;
i<3;
i++){
458 for (
int i=0;
i<3;
i++){
466 for (
int i=0;
i<6;
i++){
474 for (
int i=0;
i<6;
i++){
489 *s = v%2==0 ?
ON :
OFF;
565 *voltage = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*1+48;
566 *current = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*0.5+1;
570 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 2 571 int number_of_batteries()
576 int read_battery(
int id,
double *voltage,
double *current,
double *soc)
578 *voltage = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*1+48;
579 *current = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*0.5+1;
580 *soc = ((double)random()-RAND_MAX/2)/(RAND_MAX/2)*0.5+50;
584 int number_of_thermometers()
590 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3 591 int write_command_acceleration(
int id,
double acc)
596 int write_command_accelerations(
const double *accs)
601 int write_joint_inertia(
int id,
double mn)
606 int write_joint_inertias(
const double *mns)
611 int read_pd_controller_torques(
double *torques)
616 int write_disturbance_observer(
int com)
621 int write_disturbance_observer_gain(
double gain)
627 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4 628 int read_torque_pgain(
int id,
double *gain)
633 int write_torque_pgain(
int id,
double gain)
638 int read_torque_dgain(
int id,
double *gain)
643 int write_torque_dgain(
int id,
double gain)
658 while (ts->tv_nsec > 1e9){
666 double dts = ts1->tv_sec - ts2->tv_sec;
667 double dtn = ts1->tv_nsec - ts2->tv_nsec;
673 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &
g_ts, 0);
676 clock_gettime(CLOCK_MONOTONIC, &now);
int write_dgain(int id, double gain)
write D gain[Nm/(rad/s)]
int read_servo_state(int id, int *s)
read servo status
int read_attitude_sensor(int id, double *att)
read output of attitude sensor
int read_llimit_angle(int id, double *angle)
static std::vector< std::vector< double > > attitude_sensors
int write_power_command(int id, int com)
turn on/off power supply for motor driver
int read_command_angle(int id, double *angle)
read command angle[rad]
int set_number_of_gyro_sensors(int num)
set the number of gyro sensors
int read_dgain(int id, double *gain)
read D gain[Nm/(rad/s)]
int read_calib_state(int id, int *s)
read callibration state of joint
int set_number_of_attitude_sensors(int num)
static std::vector< std::vector< double > > gyro_offset
static std::vector< std::vector< double > > forces
unsigned int sleep(unsigned int seconds)
int read_command_torques(double *torques)
read array of command torques[Nm]
int read_currents(double *currents)
int read_extra_servo_state(int id, int *state)
read extra servo states
int write_dio(unsigned short buf)
int write_digital_output_with_mask(const char *doutput, const char *mask)
write_digital_output, non-applicable bits are nop
static std::vector< std::vector< double > > force_offset
int read_gyro_sensor_offset(int id, double *offset)
read offset values for gyro sensor output
int read_control_mode(int id, joint_control_mode *s)
read joint control mode
int write_angle_offset(int id, double angle)
write offset value for joint[rad]
int close_iob(void)
close connection with joint servo process
int read_force_sensor(int id, double *forces)
read output of force sensor
abstract interface for the robot hardware
int read_torque_limit(int id, double *limit)
int number_of_accelerometers()
get the number of accelerometers
int read_power(double *voltage, double *current)
read status of power source
int read_angle_offset(int id, double *angle)
read offset value for joint[rad]
static std::vector< std::vector< double > > gyros
static std::vector< std::vector< double > > accelerometers
int number_of_gyro_sensors()
get the number of gyro sensors
int read_actual_angle(int id, double *angle)
read current joint angle[rad]
int open_iob(void)
open connection with joint servo process
int write_command_torque(int id, double torque)
write command torque[Nm]
int write_control_mode(int id, joint_control_mode s)
write joint control mode
int length_digital_input()
get_digital_input_length
int write_gyro_sensor_offset(int id, double *offset)
write offset values for gyro sensor output
size_t length_of_extra_servo_state(int id)
get length of extra servo states
int length_digital_output()
get_digital_output_length
#define CHECK_JOINT_ID(id)
int read_encoder_pulse(int id, double *ec)
int read_force_offset(int id, double *offsets)
read offset values for force sensor output
#define CHECK_GYRO_SENSOR_ID(id)
int read_ulimit_angle(int id, double *angle)
int read_power_state(int id, int *s)
read power status of motor driver
int read_command_angles(double *angles)
read array of command angles[rad]
int write_pgain(int id, double gain)
write P gain[Nm/rad]
int set_number_of_accelerometers(int num)
set the number of accelerometers
void timespec_add_ns(timespec *ts, long ns)
int write_attitude_sensor_offset(int id, double *offset)
def j(str, encoding="cp932")
int read_torque_const(int id, double *tc)
unsigned long long read_iob_frame()
int write_digital_output(const char *doutput)
write_digital_output, non-applicable bits are nop
int read_actual_velocities(double *vels)
read actual angular velocities[rad/s]
int read_gyro_sensor(int id, double *rates)
read output of gyro sensor
int read_lock_owner(pid_t *pid)
read id of the process whic is locking access to iob
int number_of_force_sensors()
get the number of force sensors
int wait_for_iob_signal()
wait until iob signal is issued
int number_of_joints()
get the number of joints
int read_driver_temperature(int id, unsigned char *v)
read temperature of motor driver[Celsius]
int set_signal_period(long period_ns)
set the period of signals issued by wait_for_iob_signal()
int unlock_iob()
unlock access to iob
int read_power_command(int id, int *com)
turn on/off power supply for motor driver
int read_temperature(int id, double *v)
read thermometer
static std::vector< int > servo
int read_accelerometer(int id, double *accels)
read output of accelerometer
int write_force_offset(int id, double *offsets)
write offset values for force sensor output
int write_command_velocity(int id, double vel)
write command angular velocity[rad/s]
long get_signal_period()
get the period of signals issued by wait_for_iob_signal()
int read_actual_velocity(int id, double *vel)
read actual angular velocity[rad/s]
int joint_calibration(int id, double angle)
int number_of_attitude_sensors()
get the number of attitude sensors
int read_current(int id, double *mcurrent)
int read_servo_alarm(int id, int *a)
read servo alarms
int read_command_velocities(double *vels)
read command angular velocities[rad/s]
int read_digital_output(char *doutput)
read_digital_output, non-applicable bits are nop
int read_command_torque(int id, double *torque)
read command torque[Nm]
int read_command_velocity(int id, double *vel)
read command angular velocity[rad/s]
static std::vector< int > power
int read_limit_angle(int id, double *angle)
int read_digital_input(char *dinput)
read_digital_input, non-applicable bits are nop
int initializeJointAngle(const char *name, const char *option)
initialize joint angle
int set_number_of_joints(int num)
set the number of joints
int lock_iob()
lock access to iob
static std::vector< double > command
int write_servo(int id, int com)
turn on/off joint servo
int read_accelerometer_offset(int id, double *offset)
read offset values for accelerometer output
int read_touch_sensors(unsigned short *onoff)
int set_number_of_force_sensors(int num)
set the number of force sensors
int read_gear_ratio(int id, double *gr)
double timespec_compare(timespec *ts1, timespec *ts2)
int write_command_velocities(const double *vels)
write command angular velocities[rad/s]
int read_current_limit(int id, double *v)
int read_gauges(double *gauges)
static std::vector< std::vector< double > > accel_offset
int write_command_angle(int id, double angle)
write command angle[rad]
int read_actual_angles(double *angles)
read array of current joint angles[rad]
int write_command_torques(const double *torques)
write array of command torques[Nm]
int write_command_angles(const double *angles)
write array of command angles[rad]
int read_actual_torques(double *torques)
read array of current joint torques[Nm]
int read_pgain(int id, double *gain)
read P gain[Nm/rad]
int write_accelerometer_offset(int id, double *offset)
write offset values for accelerometer output