@@ -663,7 +663,6 @@ bool MpcController::activate(const ControlOutput &last_control_output) {
663663 rampup_duration_ = std::abs (throttle_difference) / _rampup_speed_;
664664
665665 RCLCPP_INFO (node_->get_logger (), " [%s]: activating rampup with initial throttle: %.4f, target: %.4f" , name_.c_str (), throttle_last_controller.value (), hover_throttle);
666-
667666 }
668667
669668 first_iteration_ = true ;
@@ -1670,24 +1669,26 @@ void MpcController::MPC(const mrs_msgs::msg::UavState &uav_state, const mrs_msgs
16701669
16711670 if (rampup_active_) {
16721671
1673- double rampup_dt = (clock_->now () - rampup_last_time_).seconds ();
1672+ // deactivate the rampup when the times up
1673+ if (std::abs ((clock_->now () - rampup_start_time_).seconds ()) >= rampup_duration_) {
16741674
1675- rampup_throttle_ += double (rampup_direction_) * _rampup_speed_ * rampup_dt ;
1675+ rampup_active_ = false ;
16761676
1677- rampup_last_time_ = clock_-> now ( );
1677+ RCLCPP_INFO (node_-> get_logger (), " [%s]: rampup finished " , name_. c_str () );
16781678
1679- throttle = rampup_throttle_;
1679+ } else {
16801680
1681- RCLCPP_INFO_THROTTLE (node_-> get_logger (), *clock_, 100 , " [%s]: ramping up throttle, %.4f " , name_. c_str (), throttle );
1681+ double rampup_dt = (clock_-> now () - rampup_last_time_). seconds ( );
16821682
1683- // deactivate the rampup when the times up
1684- if (std::abs ((clock_->now () - rampup_start_time_).seconds ()) >= rampup_duration_) {
1683+ rampup_throttle_ += double (rampup_direction_) * _rampup_speed_ * rampup_dt;
16851684
1686- rampup_active_ = false ;
1685+ rampup_last_time_ = clock_-> now () ;
16871686
1688- RCLCPP_INFO (node_->get_logger (), " [%s]: rampup finished " , name_.c_str ());
1687+ RCLCPP_INFO_THROTTLE (node_->get_logger (), *clock_, 100 , " [%s]: ramping up throttle, %.4f " , name_.c_str (), throttle );
16891688 }
16901689
1690+ throttle = rampup_throttle_;
1691+
16911692 } else {
16921693
16931694 if (desired_thrust_force >= 0 ) {
0 commit comments