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@136:b35f2d9b7402, 2017-05-16 (annotated)
- Committer:
- aeschsim
- Date:
- Tue May 16 16:18:29 2017 +0000
- Revision:
- 136:b35f2d9b7402
- Parent:
- 130:0d6c072b23ca
changed and added some safety functions
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 | 136:b35f2d9b7402 | 6 | bool safety() |
| aeschsim | 136:b35f2d9b7402 | 7 | { |
| aeschsim | 136:b35f2d9b7402 | 8 | float dist_ir = getDistanceIR(2); |
| aeschsim | 136:b35f2d9b7402 | 9 | if(getDistanceIR(2) < 0.1f) { //state 50: grabbing state |
| aeschsim | 130:0d6c072b23ca | 10 | stop_move(); |
| aeschsim | 130:0d6c072b23ca | 11 | stop_turn(); |
| aeschsim | 130:0d6c072b23ca | 12 | printf("Stopped moving to prevent colission!\r\n"); |
| aeschsim | 136:b35f2d9b7402 | 13 | return 1; |
| cittecla | 38:3526c36e4c73 | 14 | } |
| aeschsim | 136:b35f2d9b7402 | 15 | return 0; |
| aeschsim | 130:0d6c072b23ca | 16 | } |
| aeschsim | 136:b35f2d9b7402 | 17 | |
| aeschsim | 136:b35f2d9b7402 | 18 | int emergency_shutdown() |
| aeschsim | 136:b35f2d9b7402 | 19 | { |
| cittecla | 125:d0b2057272d0 | 20 | stop_move(); |
| cittecla | 125:d0b2057272d0 | 21 | stop_turn(); |
| cittecla | 125:d0b2057272d0 | 22 | disable_servos(); |
| cittecla | 125:d0b2057272d0 | 23 | disable_motors(); |
| cittecla | 38:3526c36e4c73 | 24 | return 0; |
| aeschsim | 136:b35f2d9b7402 | 25 | } |
| aeschsim | 136:b35f2d9b7402 | 26 | |
| aeschsim | 136:b35f2d9b7402 | 27 | int colision_detected() |
| aeschsim | 136:b35f2d9b7402 | 28 | { |
| aeschsim | 136:b35f2d9b7402 | 29 | |
| cittecla | 38:3526c36e4c73 | 30 | return 0; |
| aeschsim | 136:b35f2d9b7402 | 31 | } |
| aeschsim | 136:b35f2d9b7402 | 32 | |
| aeschsim | 136:b35f2d9b7402 | 33 | int current_to_high() |
| aeschsim | 136:b35f2d9b7402 | 34 | { |
| aeschsim | 136:b35f2d9b7402 | 35 | |
| cittecla | 38:3526c36e4c73 | 36 | return 0; |
| aeschsim | 136:b35f2d9b7402 | 37 | } |
| aeschsim | 136:b35f2d9b7402 | 38 | |
| aeschsim | 136:b35f2d9b7402 | 39 | int overheating() |
| aeschsim | 136:b35f2d9b7402 | 40 | { |
| aeschsim | 136:b35f2d9b7402 | 41 | |
| cittecla | 38:3526c36e4c73 | 42 | return 0; |
| aeschsim | 136:b35f2d9b7402 | 43 | } |
