Tobis Programm forked to not destroy your golden files
Fork of Robocode by
Diff: source/movement.cpp
- Revision:
- 29:e7d0208bf2af
- Parent:
- 27:df11ab63cda4
- Child:
- 31:51f52ffa4b51
--- a/source/movement.cpp Tue Mar 07 11:05:20 2017 +0000 +++ b/source/movement.cpp Tue Mar 07 16:24:52 2017 +0000 @@ -51,7 +51,9 @@ void move_forward_slow(float correction_value) { pwmL.write(power_value_slow); - pwmR.write(1-power_value_slow*correction_value); + pwmR.write(correction_value); + printf("Left: %f || Right: %f value:%f \r\n",pwmL.read(), pwmR.read(), correction_value); + } void move_forward_medium(float correction_value) @@ -84,12 +86,15 @@ void sync_movement(bool speed, bool direction) { + if(counterLeft.read() > 30000 || -counterRight > 30000){ + + } printf("Left: %d || Right: %d\r\n",counterLeft.read(), -counterRight.read()); if(counterLeft.read() > -counterRight.read()) { - PID_correction_value += 0.0001f; + PID_correction_value += 0.001f; } else { if(counterLeft.read() < -counterRight.read()) { - PID_correction_value -= 0.0001f; + PID_correction_value -= 0.001f; } else { // even } @@ -106,18 +111,19 @@ // direction 0 = backward, direction 1 = forward // speed 0 = slow, speed 1 = medium - if(direction && speed) { + /*if(direction && speed) { move_forward_medium(PID_correction_value); - } + }*/ if(direction && !speed) { - move_forward_slow(PID_correction_value); - } + float value = 1.0f-power_value_slow*PID_correction_value; + move_forward_slow(value); + }/* if(!direction && speed) { move_backward_medium(PID_correction_value); } if(!direction && !speed) { move_backward_slow(PID_correction_value); - } + }*/ } void terminate_movement()