Skip to content

Commit

Permalink
[navigation] check the difference in height between arming and takeof…
Browse files Browse the repository at this point in the history
…f to takeoff
  • Loading branch information
sugikazu75 committed Jan 20, 2025
1 parent e867fdc commit f4e551b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ namespace aerial_robot_navigation
ros::Time force_landing_start_time_;

double takeoff_xy_pos_tolerance_;
double takeoff_z_pos_tolerance_;
double hover_convergent_start_time_;
double hover_convergent_duration_;
double land_check_start_time_;
Expand Down Expand Up @@ -366,6 +367,7 @@ namespace aerial_robot_navigation
{
if(getNaviState() == TAKEOFF_STATE) return;

/* check xy position error in initial state */
double pos_x_error = getTargetPos().x() - estimator_->getPos(Frame::COG, estimate_mode_).x();
double pos_y_error = getTargetPos().y() - estimator_->getPos(Frame::COG, estimate_mode_).y();
double pos_xy_error_dist = std::sqrt(pos_x_error * pos_x_error + pos_y_error * pos_y_error);
Expand All @@ -375,6 +377,13 @@ namespace aerial_robot_navigation
setNaviState(STOP_STATE);
}

/* check difference in height between arming and takeoff */
if(fabs(init_height_ - estimator_->getPos(Frame::COG, estimate_mode_).z()) > takeoff_z_pos_tolerance_)
{
ROS_ERROR_STREAM("difference between init height and current height: " << fabs(init_height_ - estimator_->getPos(Frame::COG, estimate_mode_).z()) << " is larger than threshold " << takeoff_z_pos_tolerance_ << ". switch back to ARM_OFF_STATE");
setNaviState(STOP_STATE);
}

if(getNaviState() == ARM_ON_STATE)
{
setNaviState(TAKEOFF_STATE);
Expand Down
1 change: 1 addition & 0 deletions aerial_robot_control/src/flight_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ void BaseNavigator::rosParamInit()
}

getParam<double>(nh, "takeoff_xy_pos_tolerance", takeoff_xy_pos_tolerance_, 0.3);
getParam<double>(nh, "takeoff_z_pos_tolerance", takeoff_z_pos_tolerance_, 0.3);
getParam<double>(nh, "hover_convergent_duration", hover_convergent_duration_, 1.0);
getParam<double>(nh, "land_check_duration", land_check_duration_, 0.5);
if (land_check_duration_ < 0.5) {
Expand Down

0 comments on commit f4e551b

Please sign in to comment.