-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev traj fixes #11399
Dev traj fixes #11399
Changes from all commits
253af3a
f80473e
fe8cccf
eef87f6
d52eee5
af85561
8657521
849b8a8
3405776
40b8ae1
e19f763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,7 @@ void PositionControl::_positionController() | |
// Constrain horizontal velocity by prioritizing the velocity component along the | ||
// the desired position setpoint over the feed-forward term. | ||
const Vector2f vel_sp_xy = ControlMath::constrainXY(Vector2f(vel_sp_position), | ||
Vector2f(_vel_sp - vel_sp_position), _constraints.speed_xy); | ||
Vector2f(_vel_sp - vel_sp_position), MPC_XY_VEL_MAX.get()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
_vel_sp(0) = vel_sp_xy(0); | ||
_vel_sp(1) = vel_sp_xy(1); | ||
// Constrain velocity in z-direction. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -686,6 +686,8 @@ MulticopterPositionControl::run() | |
} | ||
} | ||
|
||
publish_trajectory_sp(setpoint); | ||
|
||
/* desired waypoints for obstacle avoidance: | ||
* point_0 contains the current position with the desired velocity | ||
* point_1 contains _pos_sp_triplet.current if valid | ||
|
@@ -758,7 +760,6 @@ MulticopterPositionControl::run() | |
// Generate desired thrust and yaw. | ||
_control.generateThrustYawSetpoint(_dt); | ||
|
||
publish_trajectory_sp(setpoint); | ||
|
||
// Fill local position, velocity and thrust setpoint. | ||
// This message contains setpoints where each type of setpoint is either the input to the PositionController | ||
|
@@ -1045,18 +1046,15 @@ MulticopterPositionControl::check_for_smooth_takeoff(const float &z_sp, const fl | |
0.2f; | ||
|
||
// takeoff was initiated through velocity setpoint | ||
_smooth_velocity_takeoff = PX4_ISFINITE(vz_sp) && vz_sp < math::min(-_tko_speed.get(), -0.6f); | ||
_smooth_velocity_takeoff = PX4_ISFINITE(vz_sp) && vz_sp < -0.1f; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the drone starting to take off already with the smallest possible upwards setpoint and can hence lead to accidental early takeoffs with not enough thrust to really leave the ground and scraping the ground with hover thrust or even tip overs. |
||
|
||
if ((PX4_ISFINITE(z_sp) && z_sp < _states.position(2) - min_altitude) || _smooth_velocity_takeoff) { | ||
// There is a position setpoint above current position or velocity setpoint larger than | ||
// takeoff speed. Enable smooth takeoff. | ||
_in_smooth_takeoff = true; | ||
_takeoff_speed = -0.5f; | ||
_takeoff_speed = 0.f; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This breaks the smooth takeoff by not starting below hover thrust anymore and as a result the drone will always directly jump into hover. |
||
_takeoff_reference_z = _states.position(2); | ||
|
||
} else { | ||
// Default | ||
_in_smooth_takeoff = false; | ||
} | ||
} | ||
} | ||
|
@@ -1076,19 +1074,24 @@ MulticopterPositionControl::update_smooth_takeoff(const float &z_sp, const float | |
} | ||
|
||
// Ramp up takeoff speed. | ||
_takeoff_speed += desired_tko_speed * _dt / _takeoff_ramp_time.get(); | ||
_takeoff_speed = math::min(_takeoff_speed, desired_tko_speed); | ||
if (_takeoff_ramp_time.get() > _dt) { | ||
_takeoff_speed += desired_tko_speed * _dt / _takeoff_ramp_time.get(); | ||
|
||
} else { | ||
// No ramp, directly go to desired takeoff speed | ||
_takeoff_speed = desired_tko_speed; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not skip the entire smooth takeoff logic when there's anyway no ramp? |
||
} | ||
|
||
_takeoff_speed = math::min(_takeoff_speed, _tko_speed.get()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prevents the smooth velocity ramp to ramp up correctly. As soon as the desired takeoff setpoint is above the takeoff speed parameter it will get limited and not reach the goal anymore until the desired velocity setpoint comes down again. |
||
|
||
// Smooth takeoff is achieved once desired altitude/velocity setpoint is reached. | ||
if (!_smooth_velocity_takeoff) { | ||
_in_smooth_takeoff = _states.position(2) - 0.2f > math::max(z_sp, _takeoff_reference_z - MPC_LAND_ALT2.get()); | ||
|
||
} else { | ||
_in_smooth_takeoff = _takeoff_speed < -vz_sp; | ||
} else { | ||
// Make sure to stay in smooth takeoff if takeoff has not been detected yet by the land detector | ||
_in_smooth_takeoff = (_takeoff_speed < -vz_sp) || _vehicle_land_detected.landed; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't make sense to stay in smooth takeoff when the desired velocity setpoint after the initial step was already reached. It doesn't matter if the vehicle is still on the ground or not. This will result in a downwards step of the velocity as soon as the ramp is over because the takeoff was detected by the land detector. I'm assuming you inserted this because you lowered the threshold to start the takeoff to a value so low ( |
||
} | ||
|
||
} else { | ||
_in_smooth_takeoff = false; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So _jerk_min is not used anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Several people reported that the logic felt weird so I decided to remove it until I find a better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, would be nice if we had a good way of dealing with this.