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: LSM9DS1_Library_cal Motordriver
main.cpp@0:67dc92eb6d5f, 2016-11-18 (annotated)
- Committer:
- apcastelein
- Date:
- Fri Nov 18 19:04:35 2016 +0000
- Revision:
- 0:67dc92eb6d5f
- Child:
- 1:849b06ea572d
Created outline for code in project
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| apcastelein | 0:67dc92eb6d5f | 1 | #include "mbed.h" |
| apcastelein | 0:67dc92eb6d5f | 2 | |
| apcastelein | 0:67dc92eb6d5f | 3 | // Sends a request to the server and waits for a path response |
| apcastelein | 0:67dc92eb6d5f | 4 | char* getPathFromServer(){ |
| apcastelein | 0:67dc92eb6d5f | 5 | //use wifi module here |
| apcastelein | 0:67dc92eb6d5f | 6 | //https://developer.mbed.org/users/electromotivated/notebook/wifi-pid-redbot-robot-webserver/ |
| apcastelein | 0:67dc92eb6d5f | 7 | char* path = ""; |
| apcastelein | 0:67dc92eb6d5f | 8 | return path; |
| apcastelein | 0:67dc92eb6d5f | 9 | } |
| apcastelein | 0:67dc92eb6d5f | 10 | |
| apcastelein | 0:67dc92eb6d5f | 11 | //technologies for navigation may include |
| apcastelein | 0:67dc92eb6d5f | 12 | // - Line following https://www.sparkfun.com/products/11769 |
| apcastelein | 0:67dc92eb6d5f | 13 | // - IMU https://developer.mbed.org/cookbook/Stinger-Robot-Library |
| apcastelein | 0:67dc92eb6d5f | 14 | // - color sensor (indicates when end of movement is reached) |
| apcastelein | 0:67dc92eb6d5f | 15 | void moveForward(){} |
| apcastelein | 0:67dc92eb6d5f | 16 | void rotateLeft(){} |
| apcastelein | 0:67dc92eb6d5f | 17 | void rotateRight(){} |
| apcastelein | 0:67dc92eb6d5f | 18 | |
| apcastelein | 0:67dc92eb6d5f | 19 | //arem technology is yet to be determined, will probably involve adjusting a motor |
| apcastelein | 0:67dc92eb6d5f | 20 | void armUp(){} |
| apcastelein | 0:67dc92eb6d5f | 21 | void armDown(){} |
| apcastelein | 0:67dc92eb6d5f | 22 | |
| apcastelein | 0:67dc92eb6d5f | 23 | // Loops through path commands and executes each one sequentially |
| apcastelein | 0:67dc92eb6d5f | 24 | void executePath(char* path){ |
| apcastelein | 0:67dc92eb6d5f | 25 | int index = 0; |
| apcastelein | 0:67dc92eb6d5f | 26 | while(path[index] != '\0'){ |
| apcastelein | 0:67dc92eb6d5f | 27 | switch(path[index]){ |
| apcastelein | 0:67dc92eb6d5f | 28 | case 'F': moveForward(); break; |
| apcastelein | 0:67dc92eb6d5f | 29 | case 'L': rotateLeft(); break; |
| apcastelein | 0:67dc92eb6d5f | 30 | case 'R': rotateRight(); break; |
| apcastelein | 0:67dc92eb6d5f | 31 | case 'U': armUp(); break; |
| apcastelein | 0:67dc92eb6d5f | 32 | case 'U': armDown(); break; |
| apcastelein | 0:67dc92eb6d5f | 33 | } |
| apcastelein | 0:67dc92eb6d5f | 34 | } |
| apcastelein | 0:67dc92eb6d5f | 35 | } |
| apcastelein | 0:67dc92eb6d5f | 36 | |
| apcastelein | 0:67dc92eb6d5f | 37 | int main() { |
| apcastelein | 0:67dc92eb6d5f | 38 | while(true){ |
| apcastelein | 0:67dc92eb6d5f | 39 | char* path = getPathFromServer(); |
| apcastelein | 0:67dc92eb6d5f | 40 | executePath(path); |
| apcastelein | 0:67dc92eb6d5f | 41 | } |
| apcastelein | 0:67dc92eb6d5f | 42 | } |
