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
Fork of Robocode by
Diff: source/Movement.cpp
- Revision:
- 136:b35f2d9b7402
- Parent:
- 135:644346924339
--- a/source/Movement.cpp Tue May 16 15:24:23 2017 +0000
+++ b/source/Movement.cpp Tue May 16 16:18:29 2017 +0000
@@ -505,15 +505,23 @@
}
rad = (rand()%1 + 1.0f) * 0.7f + 0.3f;
rad *= sign;
- dist = (rand()%1 + 1.0f) * 0.5f + 0.5f;
+ dist = (rand()%1 + 1.0f) * 0.5f + 0.2f;
printf("radius %f || distance %f\r\n", rad, dist);
move_for_distance_with_radius(dist, rad);
+ //set sensor servos only once because wait is needed
+ set_servo_position(2, 45);
+ set_servo_position(0, -45);
+ wait(0.5f);
random_state = 1;
break;
case 1:
float dist_ir = getDistanceIR(3);
- printf("Distance ir3 %f\n\r",dist_ir);
- if (dist_ir < 0.1f) {
+ float dist_left = 1.0f;
+ float dist_right = 1.0f;
+ dist_left = getDistanceIR(4);
+ dist_right = getDistanceIR(2);
+ printf("Distance left %f || center %f || right %f\n\r",dist_left, dist_ir, dist_right);
+ if (dist_ir < 0.1f || dist_left < 0.1f || dist_right <0.1f) {
/*move backwards*/
random_state = 2;
}
