Skip to content

Commit c11c69f

Browse files
committed
Don't assume zeroed XY position when landing
1 parent ed0d614 commit c11c69f

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

include/iarc7_motion/LandPlanner.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class LandPlanner
6868

6969
LandState state_;
7070

71+
double requested_x_;
72+
double requested_y_;
7173
double requested_height_;
7274
double cushion_height_;
7375

param/low_level_motion_sim.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The PID constants are applied to positional errors in the map frame
2-
position_p_x: 0.0
3-
position_p_y: 0.0
2+
position_p_x: 1.0
3+
position_p_y: 1.0
44
position_p_z: 5.0
55

66
# PID values are positive for forward acting PID loops and negative for

src/LandPlanner.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ LandPlanner::LandPlanner(
2323
landing_detected_message_received_(false),
2424
transform_wrapper_(),
2525
state_(LandState::DONE),
26+
requested_x_(0.0),
27+
requested_y_(0.0),
2628
requested_height_(0.0),
2729
cushion_height_(0.0),
2830
actual_descend_rate_(0.0),
@@ -44,7 +46,7 @@ LandPlanner::LandPlanner(
4446
"startup_timeout")),
4547
update_timeout_(ros_utils::ParamUtils::getParam<double>(
4648
private_nh,
47-
"update_timeout")),
49+
"update_timeout")),
4850
uav_arm_client_(nh.serviceClient<iarc7_msgs::Arm>("uav_arm"))
4951
{
5052
landing_detected_subscriber_ = nh.subscribe("landing_detected",
@@ -83,10 +85,12 @@ bool LandPlanner::prepareForTakeover(const ros::Time& time)
8385
return false;
8486
}
8587

86-
requested_height_ = transform.transform.translation.z;
88+
requested_x_ = transform.transform.translation.x;
89+
requested_y_ = transform.transform.translation.y;
90+
requested_height_ = transform.transform.translation.z;
8791

8892
// height determined by the ratio of landing accelerations
89-
cushion_height_ = std::min(0.5 * (std::pow(descend_rate_,2)/cushion_acceleration_),
93+
cushion_height_ = std::min(0.5 * (std::pow(descend_rate_,2)/cushion_acceleration_),
9094
requested_height_ * ( 1 - ( 1 / ( 1 - descend_acceleration_/cushion_acceleration_))));
9195
actual_descend_rate_ = 0.0;
9296

@@ -133,7 +137,7 @@ bool LandPlanner::getTargetMotionPoint(const ros::Time& time,
133137
+ (cushion_acceleration_
134138
* (time - last_update_time_).toSec()));
135139
}
136-
140+
137141
requested_height_ = std::max(0.0, requested_height_
138142
+ (actual_descend_rate_
139143
* (time - last_update_time_).toSec()));
@@ -169,6 +173,8 @@ bool LandPlanner::getTargetMotionPoint(const ros::Time& time,
169173
// Fill in the uav_command's information
170174
motion_point.header.stamp = time;
171175

176+
motion_point.motion_point.pose.position.x = requested_x_;
177+
motion_point.motion_point.pose.position.y = requested_y_;
172178
motion_point.motion_point.pose.position.z = requested_height_;
173179
motion_point.motion_point.twist.linear.z = actual_descend_rate_;
174180

0 commit comments

Comments
 (0)