Controlor for Humanoid. Walking trajectory generator, sensor reflection etc.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
readMotion/readMotion.cpp@20:abb7852df747, 2013-08-19 (annotated)
- Committer:
- syundo0730
- Date:
- Mon Aug 19 08:10:58 2013 +0000
- Revision:
- 20:abb7852df747
- Parent:
- readMotion.cpp@19:c2ec475367aa
delete Motion instance from Control class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
syundo0730 | 19:c2ec475367aa | 1 | #include "readMotion.h" |
syundo0730 | 19:c2ec475367aa | 2 | |
syundo0730 | 19:c2ec475367aa | 3 | using namespace std; |
syundo0730 | 19:c2ec475367aa | 4 | |
syundo0730 | 19:c2ec475367aa | 5 | bool readMotion(string filename, uint16_t* pos, int &servo_size, int &motion_size, int* pose_size) { |
syundo0730 | 19:c2ec475367aa | 6 | fstream file; |
syundo0730 | 19:c2ec475367aa | 7 | string line, tmp; |
syundo0730 | 19:c2ec475367aa | 8 | stringstream sstr; |
syundo0730 | 19:c2ec475367aa | 9 | |
syundo0730 | 19:c2ec475367aa | 10 | file.open(filename.c_str(), ios::in); |
syundo0730 | 19:c2ec475367aa | 11 | if(! file.is_open()) { |
syundo0730 | 19:c2ec475367aa | 12 | return false; |
syundo0730 | 19:c2ec475367aa | 13 | } |
syundo0730 | 19:c2ec475367aa | 14 | |
syundo0730 | 19:c2ec475367aa | 15 | int i = 0, id = 0; |
syundo0730 | 19:c2ec475367aa | 16 | while(getline(file, line)) { |
syundo0730 | 19:c2ec475367aa | 17 | |
syundo0730 | 19:c2ec475367aa | 18 | std::replace(line.begin(), line.end(), ',', ' '); |
syundo0730 | 19:c2ec475367aa | 19 | sstr.clear(); |
syundo0730 | 19:c2ec475367aa | 20 | sstr.str(line); |
syundo0730 | 19:c2ec475367aa | 21 | while (sstr >> tmp) { |
syundo0730 | 19:c2ec475367aa | 22 | if (tmp == "d") { |
syundo0730 | 19:c2ec475367aa | 23 | while (sstr >> pos[i]) ++i; |
syundo0730 | 19:c2ec475367aa | 24 | } else if (tmp == "servo_size") { |
syundo0730 | 19:c2ec475367aa | 25 | sstr >> servo_size; |
syundo0730 | 19:c2ec475367aa | 26 | } else if (tmp == "motion_size") { |
syundo0730 | 19:c2ec475367aa | 27 | sstr >> motion_size; |
syundo0730 | 19:c2ec475367aa | 28 | } else if (tmp == "pose_size") { |
syundo0730 | 19:c2ec475367aa | 29 | sstr >> pose_size[id]; |
syundo0730 | 19:c2ec475367aa | 30 | ++id; |
syundo0730 | 19:c2ec475367aa | 31 | } |
syundo0730 | 19:c2ec475367aa | 32 | } |
syundo0730 | 19:c2ec475367aa | 33 | } |
syundo0730 | 19:c2ec475367aa | 34 | file.close(); |
syundo0730 | 19:c2ec475367aa | 35 | return true; |
syundo0730 | 19:c2ec475367aa | 36 | } |