ESE350 project, Spring 2016, University of Pennsylvania
Dependencies: Adafruit9-DOf Receiver mbed-rtos mbed
Diff: quadcopter.cpp
- Revision:
- 18:a00d6b065c6b
- Parent:
- 17:96d0c72e413e
- Child:
- 20:efa15ed008b4
diff -r 96d0c72e413e -r a00d6b065c6b quadcopter.cpp --- a/quadcopter.cpp Thu Apr 07 22:13:17 2016 +0000 +++ b/quadcopter.cpp Fri Apr 08 23:08:32 2016 +0000 @@ -109,9 +109,9 @@ { //motors motorPwm_;// weired errror, should not be necessary motorPwm_.m1=0; - motorPwm_.m2=0.5 + controlInput_.mx/100; + motorPwm_.m2=0.5 + controlInput_.mx/2.5; motorPwm_.m3=0; - motorPwm_.m4=0.5 - controlInput_.mx/100; + motorPwm_.m4=0.5 - controlInput_.mx/2.5; return motorPwm_; } @@ -119,16 +119,22 @@ void Quadcopter::readRc() { uint8_t zero = 0; uint8_t *rssi = &zero; + uint8_t receive = 0; char rxBuffer[rcLength_]; + receive = rf_receive_rssi(*mrf_, rxBuffer, rssi, rcLength_ + 1); if (receive > 0) { sscanf(rxBuffer, "%lld,%f,%f,%f,%f", &id, &thrust, &yaw, &pitch, &roll); } else { pc_->printf("Receive failure\r\n"); } + desiredState_.phi=roll-0.5; + desiredState_.theta=pitch-0.5; + desiredState_.psi=yaw-0.5; + F_des_=thrust-0.5; }