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/Safety.cpp
- Revision:
- 130:0d6c072b23ca
- Parent:
- 125:d0b2057272d0
- Child:
- 136:b35f2d9b7402
--- a/source/Safety.cpp Mon May 15 13:03:16 2017 +0000
+++ b/source/Safety.cpp Mon May 15 13:52:59 2017 +0000
@@ -3,9 +3,15 @@
#include "mbed.h"
#include "Safety.h"
-void safety(){
-
+int safety(int state){
+ if(getDistanceIR(2) < 0.05f && state != 50) { //state 50: grabbing state
+ stop_move();
+ stop_turn();
+ printf("Stopped moving to prevent colission!\r\n");
+ return 11;
}
+ return state;
+}
int emergency_shutdown(){
stop_move();
