Skip to content

Commit

Permalink
mc_pos_control: correct sign of acceleration state
Browse files Browse the repository at this point in the history
Non-functional change, just change the sign in the correct place to
avoid further confusion.
  • Loading branch information
MaEtUgR authored and bresch committed Apr 9, 2020
1 parent 74e99fa commit 38093e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Expand Up @@ -145,7 +145,7 @@ void PositionControl::_velocityControl(const float dt)
{
// PID velocity control
Vector3f vel_error = _vel_sp - _vel;
Vector3f acc_sp_velocity = vel_error.emult(_gain_vel_p) + _vel_int + _vel_dot.emult(_gain_vel_d);
Vector3f acc_sp_velocity = vel_error.emult(_gain_vel_p) + _vel_int - _vel_dot.emult(_gain_vel_d);

// For backwards compatibility of the gains to non-acceleration based control, needs to be overcome with configuration conversion
acc_sp_velocity *= CONSTANTS_ONE_G / _hover_thrust;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/mc_pos_control/mc_pos_control_main.cpp
Expand Up @@ -480,8 +480,8 @@ MulticopterPositionControl::set_vehicle_states(const float &vel_sp_z)
if (PX4_ISFINITE(_local_pos.vx) && PX4_ISFINITE(_local_pos.vy) && _local_pos.v_xy_valid) {
_states.velocity(0) = _local_pos.vx;
_states.velocity(1) = _local_pos.vy;
_states.acceleration(0) = _vel_x_deriv.update(-_states.velocity(0));
_states.acceleration(1) = _vel_y_deriv.update(-_states.velocity(1));
_states.acceleration(0) = _vel_x_deriv.update(_states.velocity(0));
_states.acceleration(1) = _vel_y_deriv.update(_states.velocity(1));

} else {
_states.velocity(0) = _states.velocity(1) = NAN;
Expand Down

0 comments on commit 38093e4

Please sign in to comment.