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
source/Safety.cpp@130:0d6c072b23ca, 2017-05-15 (annotated)
- Committer:
- aeschsim
- Date:
- Mon May 15 13:52:59 2017 +0000
- Revision:
- 130:0d6c072b23ca
- Parent:
- 125:d0b2057272d0
- Child:
- 136:b35f2d9b7402
add safety();
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| cittecla | 38:3526c36e4c73 | 1 | #pragma once |
| cittecla | 38:3526c36e4c73 | 2 | |
| cittecla | 38:3526c36e4c73 | 3 | #include "mbed.h" |
| cittecla | 38:3526c36e4c73 | 4 | #include "Safety.h" |
| cittecla | 38:3526c36e4c73 | 5 | |
| aeschsim | 130:0d6c072b23ca | 6 | int safety(int state){ |
| aeschsim | 130:0d6c072b23ca | 7 | if(getDistanceIR(2) < 0.05f && state != 50) { //state 50: grabbing state |
| aeschsim | 130:0d6c072b23ca | 8 | stop_move(); |
| aeschsim | 130:0d6c072b23ca | 9 | stop_turn(); |
| aeschsim | 130:0d6c072b23ca | 10 | printf("Stopped moving to prevent colission!\r\n"); |
| aeschsim | 130:0d6c072b23ca | 11 | return 11; |
| cittecla | 38:3526c36e4c73 | 12 | } |
| aeschsim | 130:0d6c072b23ca | 13 | return state; |
| aeschsim | 130:0d6c072b23ca | 14 | } |
| cittecla | 38:3526c36e4c73 | 15 | |
| cittecla | 38:3526c36e4c73 | 16 | int emergency_shutdown(){ |
| cittecla | 125:d0b2057272d0 | 17 | stop_move(); |
| cittecla | 125:d0b2057272d0 | 18 | stop_turn(); |
| cittecla | 125:d0b2057272d0 | 19 | disable_servos(); |
| cittecla | 125:d0b2057272d0 | 20 | disable_motors(); |
| cittecla | 38:3526c36e4c73 | 21 | return 0; |
| cittecla | 38:3526c36e4c73 | 22 | } |
| cittecla | 38:3526c36e4c73 | 23 | |
| cittecla | 38:3526c36e4c73 | 24 | int colision_detected(){ |
| cittecla | 38:3526c36e4c73 | 25 | |
| cittecla | 38:3526c36e4c73 | 26 | return 0; |
| cittecla | 38:3526c36e4c73 | 27 | } |
| cittecla | 38:3526c36e4c73 | 28 | |
| cittecla | 38:3526c36e4c73 | 29 | int current_to_high(){ |
| cittecla | 38:3526c36e4c73 | 30 | |
| cittecla | 38:3526c36e4c73 | 31 | return 0; |
| cittecla | 38:3526c36e4c73 | 32 | } |
| cittecla | 38:3526c36e4c73 | 33 | |
| cittecla | 38:3526c36e4c73 | 34 | int overheating(){ |
| cittecla | 38:3526c36e4c73 | 35 | |
| cittecla | 38:3526c36e4c73 | 36 | return 0; |
| cittecla | 38:3526c36e4c73 | 37 | } |
| cittecla | 38:3526c36e4c73 | 38 |
