Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Control/drivecontrol.cpp
- Revision:
- 27:b980fce784ea
- Parent:
- 26:191ec0e78774
- Child:
- 28:600932142201
--- a/Control/drivecontrol.cpp Sun May 21 08:10:29 2017 +0000 +++ b/Control/drivecontrol.cpp Fri May 26 05:45:02 2017 +0000 @@ -17,8 +17,8 @@ // Sensor offsets //float FRONT_SENSOR_THRES = 7.0f, SENSOR_ERROR_OFFSET = 0.0f; float FRONT_SENSOR_THRES = 2.2f, SENSOR_ERROR_OFFSET = 0.0f; -float LEFT_WALL_THRES = 0.50f, RIGHT_WALL_THRES = 0.30f; -float RIGHT_SIDE_WALL_THRES = 0.20f, LEFT_SIDE_WALL_THRES = 0.20f; +float LEFT_WALL_THRES = 0.3643f, RIGHT_WALL_THRES = 0.1932f; +float RIGHT_SIDE_WALL_THRES = 0.32f, LEFT_SIDE_WALL_THRES = 0.28f; // Motor speed offsets float left_speed, right_speed, motor_speed; @@ -121,7 +121,6 @@ } } } - // Currently only have the x, y position fields for // each cell. DriveControl::DriveControl (int start_x, int start_y) { @@ -140,11 +139,6 @@ return 1; } -int DriveControl::get_next_state(int state) { - // Simply drives the mouse for testing - //return DRIVE; -} - void DriveControl::print_serial_ports(){ pc.printf("LEFT Encoder Reading %d\n\r", leftEncoder.getEncoderDistance(1)); pc.printf("RIGHT Encoder Reading %d\n\r", rightEncoder.getEncoderDistance(0)); @@ -214,9 +208,9 @@ } bool DriveControl::has_front_wall() { - bool right_front_wall = (rightFrontIR.readIR() * 1000) > FRONT_SENSOR_THRES; + bool right_front_wall = (rightFrontIR.readIR() * 500) > FRONT_SENSOR_THRES; bool left_front_wall = (leftFrontIR.readIR() * 10) > FRONT_SENSOR_THRES; - return right_front_wall && left_front_wall; + return right_front_wall || left_front_wall; } bool DriveControl::has_left_wall() { @@ -227,11 +221,6 @@ return rightIR.readIR() > RIGHT_SIDE_WALL_THRES; } -void DriveControl::reverse() { - leftMotor->speed(-5); - rightMotor->speed(-5); -} - void DriveControl::clear_pid() { pid_controller::clear_pid(); }