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 ros_lib_kinetic
ros_functions.cpp@0:3a767f41cf04, 2018-01-31 (annotated)
- Committer:
- group-UVic-Assistive-Technolog
- Date:
- Wed Jan 31 05:24:12 2018 +0000
- Revision:
- 0:3a767f41cf04
- Child:
- 2:0537a8007a39
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 1 | |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 2 | #include <ros_functions.h> |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 3 | #include <definitions.h> |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 4 | #include <ros.h> |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 5 | #include <std_msgs/Empty.h> |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 6 | #include <std_msgs/Float32MultiArray.h> |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 7 | #include <prototypes.h> |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 8 | |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 9 | |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 10 | void module_commandCB(const std_msgs::Float32MultiArray& command_data){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 11 | |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 12 | rosInput.yaw = command_data.data[ROSYAW]; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 13 | rosInput.pitch = command_data.data[ROSPITCH]; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 14 | rosInput.roll = command_data.data[ROSROLL]; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 15 | rosInput.height = command_data.data[ROSHEIGHT]; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 16 | rosInput.mode = command_data.data[ROSMODE]; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 17 | |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 18 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 19 | |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 20 | void rosCheck(){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 21 | if (rosFlag){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 22 | rosFlag = 0; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 23 | if(rosInput.mode == 0){ //Transport Mode |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 24 | control.yaw = YAWZERO; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 25 | control.pitch = PITCHZERO; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 26 | control.roll = ROLLZERO; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 27 | control.gimbalRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 28 | if(control.height != LIFTHEIGHTMIN){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 29 | control.height = LIFTHEIGHTMIN; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 30 | control.liftRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 31 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 32 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 33 | else if(rosInput.mode == 1){ //Photo Mode |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 34 | switch(rosInput.height){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 35 | case(1): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 36 | control.height = control.height + 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 37 | control.liftRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 38 | if(control.height > LIFTHEIGHTMAX){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 39 | control.height = LIFTHEIGHTMAX;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 40 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 41 | case(2): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 42 | control.height = control.height - 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 43 | control.liftRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 44 | if(control.height < LIFTHEIGHTMIN){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 45 | control.height = LIFTHEIGHTMIN;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 46 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 47 | case(0): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 48 | control.height = currentPosition; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 49 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 50 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 51 | switch(rosInput.yaw){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 52 | case(1): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 53 | control.yaw = control.yaw + 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 54 | control.gimbalRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 55 | if(control.yaw > YAWMAX){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 56 | control.yaw = YAWMAX;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 57 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 58 | case(2): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 59 | control.yaw = control.yaw - 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 60 | control.gimbalRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 61 | if(control.yaw < YAWMIN){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 62 | control.yaw = YAWMIN;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 63 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 64 | case(0): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 65 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 66 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 67 | switch(rosInput.pitch){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 68 | case(1): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 69 | control.pitch = control.pitch + 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 70 | control.gimbalRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 71 | if(control.pitch > PITCHMAX){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 72 | control.pitch = PITCHMAX;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 73 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 74 | case(2): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 75 | control.pitch = control.pitch - 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 76 | control.gimbalRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 77 | if(control.pitch < PITCHMIN){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 78 | control.pitch = PITCHMIN;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 79 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 80 | case(0): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 81 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 82 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 83 | switch(rosInput.roll){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 84 | case(1): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 85 | control.roll = control.roll + 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 86 | control.gimbalRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 87 | if(control.roll > ROLLMAX){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 88 | control.roll = ROLLMAX;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 89 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 90 | case(2): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 91 | control.roll = control.roll - 50; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 92 | control.gimbalRun = TRUE; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 93 | if(control.roll < ROLLMIN){ |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 94 | control.roll = ROLLMIN;} |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 95 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 96 | case(0): |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 97 | break; |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 98 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 99 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 100 | } |
| group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 101 | } |