Skip to content

Commit

Permalink
[Twin Hammer] [controller]
Browse files Browse the repository at this point in the history
low-pass filter for gimbal roll angle
  • Loading branch information
Kaneko committed Jan 16, 2025
1 parent 8a47dba commit d96de65
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions robots/twin_hammer/config/control/TwinHammerControl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ controller:
gimbal_roll_delta_angle: 0.1
gimbal_pitch_delta_angle: 0.1
gravity_acc: 3.0
delay_param: 0.5

xy:
p_gain: 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace aerial_robot_control
double gimbal_roll_delta_angle_;
double gimbal_pitch_delta_angle_;
double gravity_acc_;
double filtered_gimbal_1_roll_;
double filtered_gimbal_2_roll_;
double delay_param_;

boost::shared_ptr<nlopt::opt> nl_solver_;
std::vector<double> opt_x_;
Expand Down
14 changes: 12 additions & 2 deletions robots/twin_hammer/src/control/twin_hammer_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void TwinHammerController::initialize(ros::NodeHandle nh, ros::NodeHandle nhp,

haptics_force_ = Eigen::Vector3d::Zero();
haptics_torque_ = Eigen::Vector3d::Zero();
filtered_gimbal_1_roll_ = 0.0;
filtered_gimbal_2_roll_ = 0.0;

rosParamInit();
}
Expand All @@ -42,7 +44,7 @@ void TwinHammerController::rosParamInit()
getParam<double>(control_nh, "gimbal_roll_delta_angle", gimbal_roll_delta_angle_, 0.1);
getParam<double>(control_nh, "gimbal_pitch_delta_angle", gimbal_pitch_delta_angle_, 0.1);
getParam<double>(control_nh, "gravity_acc", gravity_acc_, 1.0);

getParam<double>(control_nh, "delay_param", delay_param_, 1.0);
}

void TwinHammerController::HapticsSwitchCallback(std_msgs::Int8 msg)
Expand Down Expand Up @@ -185,7 +187,15 @@ void TwinHammerController::controlCore()
if(gimbal_i_pitch < prev_gimbal_angles_.at(2*i+1) - gimbal_pitch_delta_angle_){
gimbal_i_pitch = prev_gimbal_angles_.at(2*i+1) - gimbal_pitch_delta_angle_;
}
target_gimbal_angles_.at(2*i) = gimbal_i_roll;
if(i==0){
filtered_gimbal_1_roll_ = (1-delay_param_) * filtered_gimbal_1_roll_ + delay_param_ * gimbal_i_roll;
target_gimbal_angles_.at(0) = filtered_gimbal_1_roll_;
}
if(i==1){
filtered_gimbal_2_roll_ = (1-delay_param_) * filtered_gimbal_2_roll_ + delay_param_ * gimbal_i_roll;
target_gimbal_angles_.at(2) = filtered_gimbal_2_roll_;
}
// target_gimbal_angles_.at(2*i) = gimbal_i_roll;
target_gimbal_angles_.at(2*i+1) = gimbal_i_pitch;
// std::cout << "gimbal" << i << "roll is " << gimbal_i_roll << std::endl;
// std::cout << "gimbal" << i << "pitch is " << gimbal_i_pitch << std::endl;
Expand Down

0 comments on commit d96de65

Please sign in to comment.