![](/media/cache/profiles/e5815151957be36ad2085b7a1a02c5cc.jpg.50x50_q85.jpg)
Controlor for Humanoid. Walking trajectory generator, sensor reflection etc.
Dependencies: Adafruit-PWM-Servo-Driver MPU6050 RS300 mbed
readMotion/readMotion.cpp@23:0927e605af4b, 2013-11-22 (annotated)
- Committer:
- syundo0730
- Date:
- Fri Nov 22 00:30:42 2013 +0000
- Revision:
- 23:0927e605af4b
- Parent:
- 20:abb7852df747
first commit
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 | } |