ryan lin
/
wheeldriveassistance
wheelchair code for driver assitance
Fork of wheelchairalexa by
Diff: wheelchair.cpp
- Revision:
- 12:0e5a0571b497
- Parent:
- 11:75f0f13ff6c1
--- a/wheelchair.cpp Thu Aug 16 16:42:45 2018 +0000 +++ b/wheelchair.cpp Fri Aug 17 03:10:39 2018 +0000 @@ -21,25 +21,6 @@ ti = time; } -/* -* joystick has analog out of 200-700, scale values between 1.3 and 3.3 -*/ -void Wheelchair::move(float x_coor, float y_coor) -{ - - float scaled_x = ((x_coor * 1.6f) + 1.7f)/3.3f; - float scaled_y = (3.3f - (y_coor * 1.6f))/3.3f; - - // lowPass(scaled_x); - //lowPass(scaled_y); - - x->write(scaled_x); - y->write(scaled_y); - - //out->printf("yaw %f\n", imu->yaw()); - -} - void Wheelchair::forward() { x->write(high); @@ -86,3 +67,31 @@ return; } +/* +* joystick has analog out of 200-700, scale values between 1.3 and 3.3 +*/ +void Wheelchair::move(float x_coor, float y_coor, bool leftbound, bool rightbound, bool straightbound) +{ + + + float scaled_x = ((x_coor * 1.6f) + 1.7f)/3.3f; + float scaled_y = (3.3f - (y_coor * 1.6f))/3.3f; + + if(leftbound && (scaled_x > 2.5) ) { + Wheelchair::stop(); + } + + else if(rightbound && (scaled_x < 2.5) ) { + Wheelchair::stop(); + } + + else if(straightbound && (scaled_y > 2.5) ) { + Wheelchair::stop(); + } + + else { + x->write(scaled_x); + y->write(scaled_y); + } +} +