UVic Assistive Technology Lab / Mbed 2 deprecated DSLR_Camera_Gimbal

Dependencies:   mbed ros_lib_kinetic

Committer:
MikeGray92
Date:
Thu Feb 08 22:55:15 2018 +0000
Revision:
3:527f0b949839
Parent:
2:0537a8007a39
Child:
4:89ebfa37663b
Just addd/removed comments. See last commit notes for changes

Who changed what in which revision?

UserRevisionLine numberNew 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
MikeGray92 3:527f0b949839 9 int h = 0; //variable used to reset the currentPosition value when switching input direction
group-UVic-Assistive-Technolog 0:3a767f41cf04 10
group-UVic-Assistive-Technolog 0:3a767f41cf04 11 void module_commandCB(const std_msgs::Float32MultiArray& command_data){
group-UVic-Assistive-Technolog 0:3a767f41cf04 12
group-UVic-Assistive-Technolog 0:3a767f41cf04 13 rosInput.yaw = command_data.data[ROSYAW];
group-UVic-Assistive-Technolog 0:3a767f41cf04 14 rosInput.pitch = command_data.data[ROSPITCH];
group-UVic-Assistive-Technolog 0:3a767f41cf04 15 rosInput.roll = command_data.data[ROSROLL];
group-UVic-Assistive-Technolog 0:3a767f41cf04 16 rosInput.height = command_data.data[ROSHEIGHT];
group-UVic-Assistive-Technolog 0:3a767f41cf04 17 rosInput.mode = command_data.data[ROSMODE];
group-UVic-Assistive-Technolog 0:3a767f41cf04 18
group-UVic-Assistive-Technolog 0:3a767f41cf04 19 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 20
group-UVic-Assistive-Technolog 0:3a767f41cf04 21 void rosCheck(){
group-UVic-Assistive-Technolog 0:3a767f41cf04 22 if(rosInput.mode == 0){ //Transport Mode
group-UVic-Assistive-Technolog 0:3a767f41cf04 23 control.yaw = YAWZERO;
group-UVic-Assistive-Technolog 0:3a767f41cf04 24 control.pitch = PITCHZERO;
group-UVic-Assistive-Technolog 0:3a767f41cf04 25 control.roll = ROLLZERO;
group-UVic-Assistive-Technolog 0:3a767f41cf04 26 control.gimbalRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 27 if(control.height != LIFTHEIGHTMIN){
group-UVic-Assistive-Technolog 0:3a767f41cf04 28 control.height = LIFTHEIGHTMIN;
group-UVic-Assistive-Technolog 0:3a767f41cf04 29 control.liftRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 30 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 31 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 32 else if(rosInput.mode == 1){ //Photo Mode
MikeGray92 2:0537a8007a39 33 if(h != rosInput.height){
MikeGray92 2:0537a8007a39 34 control.height = currentPosition;
MikeGray92 2:0537a8007a39 35 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 36 switch(rosInput.height){
group-UVic-Assistive-Technolog 0:3a767f41cf04 37 case(1):
MikeGray92 2:0537a8007a39 38 control.height++;
group-UVic-Assistive-Technolog 0:3a767f41cf04 39 control.liftRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 40 if(control.height > LIFTHEIGHTMAX){
group-UVic-Assistive-Technolog 0:3a767f41cf04 41 control.height = LIFTHEIGHTMAX;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 42 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 43 case(2):
MikeGray92 2:0537a8007a39 44 control.height--;
group-UVic-Assistive-Technolog 0:3a767f41cf04 45 control.liftRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 46 if(control.height < LIFTHEIGHTMIN){
group-UVic-Assistive-Technolog 0:3a767f41cf04 47 control.height = LIFTHEIGHTMIN;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 48 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 49 case(0):
group-UVic-Assistive-Technolog 0:3a767f41cf04 50 control.height = currentPosition;
group-UVic-Assistive-Technolog 0:3a767f41cf04 51 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 52 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 53 switch(rosInput.yaw){
group-UVic-Assistive-Technolog 0:3a767f41cf04 54 case(1):
MikeGray92 2:0537a8007a39 55 control.yaw++;
group-UVic-Assistive-Technolog 0:3a767f41cf04 56 control.gimbalRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 57 if(control.yaw > YAWMAX){
group-UVic-Assistive-Technolog 0:3a767f41cf04 58 control.yaw = YAWMAX;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 59 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 60 case(2):
MikeGray92 2:0537a8007a39 61 control.yaw--;
group-UVic-Assistive-Technolog 0:3a767f41cf04 62 control.gimbalRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 63 if(control.yaw < YAWMIN){
group-UVic-Assistive-Technolog 0:3a767f41cf04 64 control.yaw = YAWMIN;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 65 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 66 case(0):
group-UVic-Assistive-Technolog 0:3a767f41cf04 67 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 68 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 69 switch(rosInput.pitch){
group-UVic-Assistive-Technolog 0:3a767f41cf04 70 case(1):
MikeGray92 2:0537a8007a39 71 control.pitch++;
group-UVic-Assistive-Technolog 0:3a767f41cf04 72 control.gimbalRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 73 if(control.pitch > PITCHMAX){
group-UVic-Assistive-Technolog 0:3a767f41cf04 74 control.pitch = PITCHMAX;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 75 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 76 case(2):
MikeGray92 2:0537a8007a39 77 control.pitch--;
group-UVic-Assistive-Technolog 0:3a767f41cf04 78 control.gimbalRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 79 if(control.pitch < PITCHMIN){
group-UVic-Assistive-Technolog 0:3a767f41cf04 80 control.pitch = PITCHMIN;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 81 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 82 case(0):
group-UVic-Assistive-Technolog 0:3a767f41cf04 83 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 84 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 85 switch(rosInput.roll){
group-UVic-Assistive-Technolog 0:3a767f41cf04 86 case(1):
MikeGray92 2:0537a8007a39 87 control.roll++;
group-UVic-Assistive-Technolog 0:3a767f41cf04 88 control.gimbalRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 89 if(control.roll > ROLLMAX){
group-UVic-Assistive-Technolog 0:3a767f41cf04 90 control.roll = ROLLMAX;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 91 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 92 case(2):
MikeGray92 2:0537a8007a39 93 control.roll--;
group-UVic-Assistive-Technolog 0:3a767f41cf04 94 control.gimbalRun = TRUE;
group-UVic-Assistive-Technolog 0:3a767f41cf04 95 if(control.roll < ROLLMIN){
group-UVic-Assistive-Technolog 0:3a767f41cf04 96 control.roll = ROLLMIN;}
group-UVic-Assistive-Technolog 0:3a767f41cf04 97 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 98 case(0):
group-UVic-Assistive-Technolog 0:3a767f41cf04 99 break;
group-UVic-Assistive-Technolog 0:3a767f41cf04 100 }
MikeGray92 2:0537a8007a39 101 h = rosInput.height;
group-UVic-Assistive-Technolog 0:3a767f41cf04 102 }
group-UVic-Assistive-Technolog 0:3a767f41cf04 103 }