-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add hold_joints
parameter
#251
Merged
ahcorde
merged 5 commits into
ros-controls:master
from
christophfroehlich:hold_joints_parameter
Jan 1, 2024
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5b7b7f1
Add option for not holding joints if not claimed
christophfroehlich 8f76ed8
move variable to GazeboSystemPrivate
christophfroehlich 87fcab1
Update documentation
christophfroehlich 962ee62
Fix typo
christophfroehlich 45a601a
Add rclcpp exceptions
christophfroehlich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,9 @@ class gazebo_ros2_control::GazeboSystemPrivate | |
|
||
/// \brief mapping of mimicked joints to index of joint they mimic | ||
std::vector<MimicJoint> mimic_joints_; | ||
|
||
// Should hold the joints if no control_mode is active | ||
bool hold_joints_ = true; | ||
}; | ||
|
||
namespace gazebo_ros2_control | ||
|
@@ -128,6 +131,18 @@ bool GazeboSystem::initSim( | |
return false; | ||
} | ||
|
||
try { | ||
this->dataPtr->hold_joints_ = this->nh_->get_parameter("hold_joints").as_bool(); | ||
} catch (const std::exception & e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include exception |
||
RCLCPP_WARN( | ||
this->nh_->get_logger(), | ||
"Parameter 'hold_joints' not found, with error %s", e.what()); | ||
RCLCPP_WARN_STREAM( | ||
this->nh_->get_logger(), "Using default value: " << this->dataPtr->hold_joints_); | ||
} | ||
RCLCPP_DEBUG_STREAM( | ||
this->nh_->get_logger(), "hold_joints (system): " << this->dataPtr->hold_joints_ << std::endl); | ||
|
||
registerJoints(hardware_info, parent_model); | ||
registerSensors(hardware_info, parent_model); | ||
|
||
|
@@ -601,7 +616,7 @@ hardware_interface::return_type GazeboSystem::write( | |
this->dataPtr->sim_joints_[j]->SetVelocity(0, this->dataPtr->joint_velocity_cmd_[j]); | ||
} else if (this->dataPtr->joint_control_methods_[j] & EFFORT) { // NOLINT | ||
this->dataPtr->sim_joints_[j]->SetForce(0, this->dataPtr->joint_effort_cmd_[j]); | ||
} else if (this->dataPtr->is_joint_actuated_[j]) { | ||
} else if (this->dataPtr->is_joint_actuated_[j] && this->dataPtr->hold_joints_) { | ||
// Fallback case is a velocity command of zero (only for actuated joints) | ||
this->dataPtr->sim_joints_[j]->SetVelocity(0, 0.0); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include exception