Skip to content

Commit

Permalink
[Beetle][controller] add feedfoward internal wrench term.
Browse files Browse the repository at this point in the history
  • Loading branch information
sugihara-16 committed Dec 19, 2023
1 parent 806192b commit 52227d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions robots/beetle/include/beetle/control/beetle_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace aerial_robot_control
ros::Publisher whole_external_wrench_pub_;
ros::Publisher internal_wrench_pub_;
ros::Publisher wrench_comp_pid_pub_;
map<string, ros::Subscriber> ff_inter_wrench_subs_;

aerial_robot_msgs::PoseControlPid wrench_pid_msg_;

Expand All @@ -53,6 +54,7 @@ namespace aerial_robot_control
std::map<int, Eigen::VectorXd> est_wrench_list_;
std::map<int, Eigen::VectorXd> inter_wrench_list_;
std::map<int, Eigen::VectorXd> wrench_comp_list_;
std::map<int, Eigen::VectorXd> ff_inter_wrench_list_;

double comp_term_update_freq_;
double prev_comp_update_time_;
Expand All @@ -71,6 +73,7 @@ namespace aerial_robot_control
void estExternalWrenchCallback(const beetle::TaggedWrench & msg);

protected:
virtual void ffInterWrenchCallback(const beetle::TaggedWrench & msg);
void rosParamInit() override;
void externalWrenchEstimate() override;
void reset() override;
Expand Down
21 changes: 19 additions & 2 deletions robots/beetle/src/control/beetle_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ namespace aerial_robot_control
est_wrench_list_.insert(make_pair(i+1, wrench));
inter_wrench_list_.insert(make_pair(i+1, wrench));
wrench_comp_list_.insert(make_pair(i+1, wrench));
ff_inter_wrench_list_.insert(make_pair(i+1, wrench));
ff_inter_wrench_subs_.insert(make_pair(module_name, nh_.subscribe( module_name + string("/ff_inter_wrench"), 1, &BeetleController::ffInterWrenchCallback, this)));
}
pid_controllers_.push_back(PID("f_x", wrench_comp_p_gain_, wrench_comp_i_gain_, wrench_comp_d_gain_));
pid_controllers_.push_back(PID("f_y", wrench_comp_p_gain_, wrench_comp_i_gain_, wrench_comp_d_gain_));
Expand Down Expand Up @@ -298,7 +300,7 @@ namespace aerial_robot_control
Eigen::VectorXd wrench_comp_sum_left = Eigen::VectorXd::Zero(6);
for(int i = leader_id-1; i > 0; i--){
if(assembly_flag[i]){
wrench_comp_sum_left += inter_wrench_list_[i];
wrench_comp_sum_left += ff_inter_wrench_list_[i] + inter_wrench_list_[i];
// wrench_comp_list_[i] += wrench_comp_gain_ * wrench_comp_sum_left;
wrench_comp_list_[i] = wrench_comp_sum_left;
right_module_id = i;
Expand All @@ -312,7 +314,7 @@ namespace aerial_robot_control
Eigen::VectorXd wrench_comp_sum_right = Eigen::VectorXd::Zero(6);
for(int i = leader_id+1; i <= max_modules_num; i++){
if(assembly_flag[i]){
wrench_comp_sum_right -= inter_wrench_list_[left_module_id];
wrench_comp_sum_right -= -ff_inter_wrench_list_[left_module_id] + inter_wrench_list_[left_module_id];
// wrench_comp_list_[i] += wrench_comp_gain_ * wrench_comp_sum_right;
wrench_comp_list_[i] = wrench_comp_sum_right;
left_module_id = i;
Expand Down Expand Up @@ -437,6 +439,21 @@ namespace aerial_robot_control
est_wrench_list_[id] = wrench;
}

void BeetleController::ffInterWrenchCallback(const beetle::TaggedWrench & msg)
{
int id = msg.index;
geometry_msgs::Wrench wrench_msg = msg.wrench.wrench;
double time_stamp = msg.wrench.header.stamp.toSec();
Eigen::VectorXd wrench = Eigen::VectorXd::Zero(6);
wrench(0) = wrench_msg.force.x;
wrench(1) = wrench_msg.force.y;
wrench(2) = wrench_msg.force.z;
wrench(3) = wrench_msg.torque.x;
wrench(4) = wrench_msg.torque.y;
wrench(5) = wrench_msg.torque.z;
ff_inter_wrench_list_[id] = wrench;
}

} //namespace aerial_robot_controller

/* plugin registration */
Expand Down

0 comments on commit 52227d7

Please sign in to comment.