6 #include "hrpsys/idl/RobotHardwareService.hh" 8 int main(
int argc,
char *argv[])
11 std::cerr <<
"Usage: " << argv[0] <<
" [basename of rstate2 log] [dof] [no. of extra servo states] [no. of force sensors] [no. of 3 axes gyro] [no. of 3 axes accelerometers] [no. of batteries] [no. of thermometers]" << std::endl;
16 std::ifstream
ifs((basename+
".rstate2").c_str());
18 std::cerr <<
"failed to open " << argv[1] <<
".rstate2" << std::endl;
21 int dof = atoi(argv[2]);
22 int nextrass = atoi(argv[3]);
23 int nfsensor = atoi(argv[4]);
24 int ngyro = atoi(argv[5]);
25 int naccel = atoi(argv[6]);
26 int nbattery = atoi(argv[7]);
27 int ntemp = atoi(argv[8]);
29 std::ofstream ofsq((basename+
".q").c_str());
30 std::ofstream ofsqref((basename+
".qRef").c_str());
31 std::ofstream ofstau((basename+
".tau").c_str());
32 std::ofstream ofsss((basename+
".sstate").c_str());
33 std::ofstream ofsfsensor((basename+
".fsensor").c_str());
34 std::ofstream ofsgyro((basename+
".gyro").c_str());
35 std::ofstream ofsaccel((basename+
".accel").c_str());
36 std::ofstream ofsbat((basename+
".bat").c_str());
37 std::ofstream ofstemp((basename+
".temp").c_str());
39 ofsq.setf(std::ios::fixed, std::ios::floatfield);
40 ofsqref.setf(std::ios::fixed, std::ios::floatfield);
41 ofstau.setf(std::ios::fixed, std::ios::floatfield);
42 ofsss.setf(std::ios::fixed, std::ios::floatfield);
43 ofsfsensor.setf(std::ios::fixed, std::ios::floatfield);
44 ofsgyro.setf(std::ios::fixed, std::ios::floatfield);
45 ofsaccel.setf(std::ios::fixed, std::ios::floatfield);
46 ofsbat.setf(std::ios::fixed, std::ios::floatfield);
47 ofstemp.setf(std::ios::fixed, std::ios::floatfield);
57 for (
int i=0;
i<dof;
i++){
58 ifs >> v; ofsq << v <<
" ";
62 ofsqref << time <<
" ";
63 for (
int i=0;
i<dof;
i++){
64 ifs >> v; ofsqref << v <<
" ";
68 ofstau << time <<
" ";
69 for (
int i=0;
i<dof;
i++){
70 ifs >> v; ofstau << v <<
" ";
75 for (
int i=0;
i<dof;
i++){
77 ofsss << ((ss&OpenHRP::RobotHardwareService::CALIB_STATE_MASK) >> OpenHRP::RobotHardwareService::CALIB_STATE_SHIFT) <<
" ";
78 ofsss << ((ss&OpenHRP::RobotHardwareService::SERVO_STATE_MASK) >> OpenHRP::RobotHardwareService::SERVO_STATE_SHIFT) <<
" ";
79 ofsss << ((ss&OpenHRP::RobotHardwareService::POWER_STATE_MASK) >> OpenHRP::RobotHardwareService::POWER_STATE_SHIFT) <<
" ";
80 ofsss << ((ss&OpenHRP::RobotHardwareService::SERVO_ALARM_MASK) >> OpenHRP::RobotHardwareService::SERVO_ALARM_SHIFT) <<
" ";
81 ofsss << ((ss&OpenHRP::RobotHardwareService::DRIVER_TEMP_MASK) >> OpenHRP::RobotHardwareService::DRIVER_TEMP_SHIFT) <<
" ";
82 for (
int j=0;
j<nextrass;
j++){
89 ofsfsensor << time <<
" ";
90 for (
int i=0;
i<6*nfsensor;
i++){
91 ifs >> v; ofsfsensor << v <<
" ";
93 ofsfsensor << std::endl;
95 ofsgyro << time <<
" ";
96 for (
int i=0;
i<3*ngyro;
i++){
97 ifs >> v; ofsgyro << v <<
" ";
101 ofsaccel << time <<
" ";
102 for (
int i=0;
i<3*naccel;
i++){
103 ifs >> v; ofsaccel << v <<
" ";
105 ofsaccel << std::endl;
107 ofsbat << time <<
" ";
108 for (
int i=0;
i<3*nbattery+2;
i++){
111 v = std::numeric_limits<double>::quiet_NaN();
113 v = atof(str.c_str());
119 ofstemp << time <<
" ";
120 for (
int i=0;
i<ntemp;
i++){
121 ifs >> v; ofstemp << v <<
" ";
123 ofstemp << std::endl;
std::string basename(const std::string name)
def j(str, encoding="cp932")
int main(int argc, char *argv[])