Skip to content

Commit

Permalink
Copter: Minor changes on takeoff cmd - takeoff_init_ms was changed fr…
Browse files Browse the repository at this point in the history
…om a uint16_t to a uint32_t because it was overflowing
  • Loading branch information
czarb committed Nov 8, 2017
1 parent 42d2219 commit 150c392
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ArduCopter/toy_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ void ToyMode::update()
if (copter.motors->armed()) {
throttle_arm_ms = AP_HAL::millis();
takeoff_init = true;
//takeoff_started_ms = now;
takeoff_init_ms = AP_HAL::millis();
copter.set_auto_armed(true);
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "Tmode: takeoff initialised");
}
Expand Down Expand Up @@ -866,12 +866,14 @@ void ToyMode::throttle_adjust(float &throttle_control)
/*
implement delay on auto-takeoff to allow initialisations to complete
*/
const uint16_t takeoff_delay_ms = 3000;
if (takeoff_init) {
// allow 3 seconds delay
if (now - takeoff_init_ms > 3000) {
uint32_t temp = (now - takeoff_init_ms);
if (now - takeoff_init_ms > takeoff_delay_ms) {
takeoff_started_ms = now;
takeoff_init = false;
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "Tmode: takeoff started");
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_INFO, "Tmode: takeoff started: %d, %d, %d ", temp, now, takeoff_init_ms);
}
}

Expand Down
3 changes: 2 additions & 1 deletion ArduCopter/toy_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ class ToyMode

//used for takeoff cmd
int32_t takeoff_started_ms;
uint32_t takeoff_init_ms;
bool takeoff_init = false;
uint16_t takeoff_init_ms;


// time when we were last told we are recording video
uint32_t last_video_ms;
Expand Down

0 comments on commit 150c392

Please sign in to comment.