avoid multiple switch event
This commit is contained in:
parent
e0020b4bfe
commit
0ed329a44d
|
@ -31,6 +31,7 @@ namespace ocs2::legged_robot {
|
|||
std::shared_ptr<GaitSchedule> gait_schedule_ptr_;
|
||||
|
||||
ModeSequenceTemplate target_gait_;
|
||||
int last_command_ = 0;
|
||||
bool gait_updated_{false};
|
||||
bool verbose_{false};
|
||||
std::vector<ModeSequenceTemplate> gait_list_;
|
||||
|
|
|
@ -42,6 +42,8 @@ namespace ocs2::legged_robot {
|
|||
|
||||
void GaitManager::getTargetGait() {
|
||||
if (ctrl_component_.control_inputs_.command == 0) return;
|
||||
if (ctrl_component_.control_inputs_.command == last_command_) return;
|
||||
last_command_ = ctrl_component_.control_inputs_.command;
|
||||
target_gait_ = gait_list_[ctrl_component_.control_inputs_.command - 1];
|
||||
RCLCPP_INFO(rclcpp::get_logger("GaitManager"), "Switch to gait: %s",
|
||||
gait_name_list_[ctrl_component_.control_inputs_.command - 1].c_str());
|
||||
|
|
Loading…
Reference in New Issue