cansat

Dependencies:   VNH5019

Fork of cansat2 by CanSat2015aizu

Committer:
kityann
Date:
Thu Jul 23 08:16:33 2015 +0000
Revision:
2:0f76226be922
Parent:
0:3f50511c1c1f
Child:
4:8713fff9e20d
2015/07/23

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kityann 2:0f76226be922 1 #include "cansat.h"
kityann 2:0f76226be922 2
kityann 2:0f76226be922 3
kityann 2:0f76226be922 4 //////////////////////////////
kityann 2:0f76226be922 5 // Init //
kityann 2:0f76226be922 6 //////////////////////////////
kityann 2:0f76226be922 7 CanSat::CanSat(VNH5019 agzSheild):_agzSheild(agzSheild){
kityann 2:0f76226be922 8
kityann 2:0f76226be922 9 }
kityann 2:0f76226be922 10
kityann 2:0f76226be922 11
kityann 2:0f76226be922 12
kityann 2:0f76226be922 13 void CanSat::control_Motor(int flag,int speed){
kityann 2:0f76226be922 14
kityann 2:0f76226be922 15 if(flag == 0){
kityann 2:0f76226be922 16 _agzSheild.changeSpeed(1, speed, 1, speed); //straight
kityann 2:0f76226be922 17 motor_command = 'f';
kityann 2:0f76226be922 18 }
kityann 2:0f76226be922 19 if(flag == 1){
kityann 2:0f76226be922 20 _agzSheild.changeSpeed(0, speed, 0, speed);
kityann 2:0f76226be922 21 motor_command = 's';
kityann 2:0f76226be922 22 }
kityann 2:0f76226be922 23 if(flag == 2){
kityann 2:0f76226be922 24 _agzSheild.changeSpeed(1, speed, 2, speed); //Turn Right
kityann 2:0f76226be922 25 motor_command = 'r';
kityann 2:0f76226be922 26 }
kityann 2:0f76226be922 27 if(flag == 3){
kityann 2:0f76226be922 28 _agzSheild.changeSpeed(2, speed, 1, speed); //Turn Right
kityann 2:0f76226be922 29 motor_command = 'l';
kityann 2:0f76226be922 30 }
kityann 2:0f76226be922 31 if(flag == 4){
kityann 2:0f76226be922 32 _agzSheild.changeSpeed(2, speed, 2, speed);
kityann 2:0f76226be922 33 motor_command = 'b';
kityann 2:0f76226be922 34 }
kityann 2:0f76226be922 35 }
kityann 2:0f76226be922 36
kityann 2:0f76226be922 37
kityann 2:0f76226be922 38 //////////////////////////////
kityann 2:0f76226be922 39 // Get //
kityann 2:0f76226be922 40 //////////////////////////////
kityann 2:0f76226be922 41 double CanSat::get_robot_x(){
kityann 2:0f76226be922 42 return robot_x;
kityann 2:0f76226be922 43 }
kityann 2:0f76226be922 44 double CanSat::get_robot_y(){
kityann 2:0f76226be922 45 return robot_y;
kityann 2:0f76226be922 46 }
kityann 2:0f76226be922 47 double CanSat::get_robotKalman_x(){
kityann 2:0f76226be922 48 return robotK_x;
kityann 2:0f76226be922 49 }
kityann 2:0f76226be922 50 double CanSat::get_robotKalman_y(){
kityann 2:0f76226be922 51 return robotK_y;
kityann 2:0f76226be922 52 }
kityann 2:0f76226be922 53 //////////////////////////////
kityann 2:0f76226be922 54 // Set //
kityann 2:0f76226be922 55 //////////////////////////////
kityann 2:0f76226be922 56 void CanSat::set_robot_x(double x){
kityann 2:0f76226be922 57 robot_x = x;
kityann 2:0f76226be922 58 }
kityann 2:0f76226be922 59 void CanSat::set_robot_y(double y){
kityann 2:0f76226be922 60 robot_y = y;
kityann 2:0f76226be922 61 }
kityann 2:0f76226be922 62
kityann 2:0f76226be922 63 void CanSat::set_robotKalman_x(double cur_x){
kityann 2:0f76226be922 64 robotK_x = cur_x;
kityann 2:0f76226be922 65 }
kityann 2:0f76226be922 66 void CanSat::set_robotKalman_y(double cur_y){
kityann 2:0f76226be922 67 robotK_y = cur_y;
kityann 2:0f76226be922 68 }
kityann 2:0f76226be922 69 void CanSat::set_gyro(double x, double y, double z){
kityann 2:0f76226be922 70 CanSat::gyro_x = x;
kityann 2:0f76226be922 71 CanSat::gyro_y = y;
kityann 2:0f76226be922 72 CanSat::gyro_z = z;
kityann 2:0f76226be922 73 }
kityann 2:0f76226be922 74 void CanSat::set_compass(double x, double y, double z){
kityann 2:0f76226be922 75 CanSat::compass_x = x;
kityann 2:0f76226be922 76 CanSat::compass_y = y;
kityann 2:0f76226be922 77 CanSat::compass_z = z;
kityann 2:0f76226be922 78 }
kityann 2:0f76226be922 79 void CanSat::set_pressure(double p){
kityann 2:0f76226be922 80 CanSat::pressure = p;
kityann 2:0f76226be922 81 }
kityann 2:0f76226be922 82 void CanSat::set_temperature(double t){
kityann 2:0f76226be922 83 CanSat::temperature = t;
kityann 2:0f76226be922 84 }
kityann 2:0f76226be922 85 void CanSat::set_humidity(double h){
kityann 2:0f76226be922 86 CanSat::humidity = h;
kityann 2:0f76226be922 87 }
kityann 2:0f76226be922 88 void CanSat::set_acceleration(double x, double y, double z){
kityann 2:0f76226be922 89 CanSat::acceleration_x = x;
kityann 2:0f76226be922 90 CanSat::acceleration_y = y;
kityann 2:0f76226be922 91 CanSat::acceleration_z = z;
kityann 2:0f76226be922 92 }