Skip to content
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

[Control] enable to compensate gravity term for altitude control #584

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace aerial_robot_control
double landing_err_z_;
double safe_landing_height_;
double force_landing_descending_rate_;
bool compensate_gravity_;

tf::Vector3 pos_, target_pos_;
tf::Vector3 vel_, target_vel_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ namespace aerial_robot_control

/* z */
loadParam(z_nh);
getParam<bool>(z_nh, "compensate_gravity", compensate_gravity_, false);
pid_controllers_.push_back(PID("z", p_gain, i_gain, d_gain, limit_sum, limit_p, limit_i, limit_d, limit_err_p, limit_err_i, limit_err_d));
pid_reconf_servers_.push_back(boost::make_shared<PidControlDynamicConfig>(z_nh));
pid_reconf_servers_.back()->setCallback(boost::bind(&PoseLinearController::cfgPidCallback, this, _1, _2, std::vector<int>(1, Z)));
Expand Down Expand Up @@ -253,9 +254,9 @@ namespace aerial_robot_control
target_acc_.setZ(0);
}

pid_controllers_.at(Z).update(err_z, du_z, err_v_z, target_acc_.z());
double gravity_term = compensate_gravity_?robot_model_->getGravity3d().z():0;

if(pid_controllers_.at(Z).getErrI() < 0) pid_controllers_.at(Z).setErrI(0);
pid_controllers_.at(Z).update(err_z, du_z, err_v_z, target_acc_.z() + gravity_term);

if(navigator_->getForceLandingFlag())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ void UnderActuatedLQIController::controlCore()
// feed-forward term for z
Eigen::MatrixXd q_mat_inv = getQInv();
double ff_acc_z = navigator_->getTargetAcc().z();
if(compensate_gravity_) ff_acc_z += robot_model_->getGravity3d().z();
Eigen::VectorXd ff_term = q_mat_inv.col(0) * ff_acc_z;
target_thrust_z_term += ff_term;

Expand Down
1 change: 1 addition & 0 deletions robots/mini_quadrotor/config/FlightControl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ controller:
limit_d: 20 # m / s^2
landing_err_z: -0.2
force_landing_descending_rate: -0.6
compensate_gravity: true

yaw:
limit_sum: 6.0 # N for clamping thrust force
Expand Down
Loading