Skip to content

Commit

Permalink
Change leg length when legged_balance chassis gyro.
Browse files Browse the repository at this point in the history
  • Loading branch information
YoujianWu committed Nov 1, 2024
1 parent ac4de85 commit b70a509
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/rm_manual/legged_wheel_balance_manual.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LeggedWheelBalanceManual : public BalanceManual
rm_common::LegCommandSender* legCommandSender_{};

private:
bool stretch_ = false, stretching_ = false;
bool stretch_ = false, stretching_ = false, is_increasing_length_ = false;
InputEvent ctrl_shift_event_, ctrl_g_event_;
ros::Subscriber unstick_sub_;
void unstickCallback(const std_msgs::BoolConstPtr& msg);
Expand Down
26 changes: 25 additions & 1 deletion src/legged_wheel_balance_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ LeggedWheelBalanceManual::LeggedWheelBalanceManual(ros::NodeHandle& nh, ros::Nod
void LeggedWheelBalanceManual::sendCommand(const ros::Time& time)
{
BalanceManual::sendCommand(time);
if (is_gyro_)
{
double current_length = legCommandSender_->getLgeLength();
if (is_increasing_length_)
{
if (current_length < 0.3)
{
double delta = current_length + 0.002;
legCommandSender_->setLgeLength(delta > 0.3 ? 0.3 : delta);
}
else
is_increasing_length_ = false;
}
else
{
if (current_length > 0.18)
{
double delta = current_length - 0.002;
legCommandSender_->setLgeLength(delta < 0.18 ? 0.18 : delta);
}
else
is_increasing_length_ = true;
}
}
legCommandSender_->sendCommand(time);
}

Expand Down Expand Up @@ -135,7 +159,7 @@ void LeggedWheelBalanceManual::unstickCallback(const std_msgs::BoolConstPtr& msg
}
else if (stretching_ && !two_leg_unstick)
{
legCommandSender_->setLgeLength(0.2);
legCommandSender_->setLgeLength(0.18);
stretching_ = false;
}
}
Expand Down

0 comments on commit b70a509

Please sign in to comment.