-
Notifications
You must be signed in to change notification settings - Fork 93
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
PID effort control of joints (+mimic) #122
Open
livanov93
wants to merge
25
commits into
ros-controls:humble
Choose a base branch
from
livanov93:pid-with-force-output
base: humble
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
bb54c12
Introduce PID for position control.
livanov93 0104d7a
Add generate parameter library.
livanov93 c018f7c
Refresh params every loop step.
livanov93 cb75106
Reorganize calcs.
livanov93 6d5eda3
Add pid params via hardware parameters.
livanov93 87496ff
Add pid sim params into demos urdfs.
livanov93 c11b195
Testing clamping.
livanov93 c3bd601
Change pid params. Cascade control. Comment mimic stuff for now.
livanov93 29e9943
Debug output.
livanov93 25187ea
Adapt pid params for examples.
livanov93 01e6f68
Move all control to force - based output.
livanov93 ea36469
Introduce MimicJointSystem plugin.
livanov93 65b7388
Add mimic joint vel pid only support.
livanov93 1a89e06
Round commanded force.
livanov93 9bbb874
Remove suffix for state interfaces as it confuses robot_state_publish…
livanov93 e40142c
Add cascade control parameter. Code refactoring.
livanov93 6c671e4
Identation, alphabetizing, usage description comment, empty destructo…
livanov93 3b47f98
Merge branch 'humble' into pid-with-force-output
livanov93 1831835
Fix error.
livanov93 e8ac35e
Namespace fix.
livanov93 64f6b67
Adapt pid values for simple position example.
livanov93 6c5ecef
Suggestions and fixes for humble CI. write method return value handling.
livanov93 a100537
Satisfy ament tools.
livanov93 496dde5
Fix linters by bypassing for specific lines.
livanov93 460d47c
Remove suggestion comment.
livanov93 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
104 changes: 104 additions & 0 deletions
104
ign_ros2_control/include/ign_ros2_control/MimicJointSystem.hh
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright 2023 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//---------------------------------------------------------------------- | ||
/*!\file | ||
* | ||
* \author Lovro Ivanov [email protected] | ||
* \date 2023-03-15 | ||
* | ||
*/ | ||
//---------------------------------------------------------------------- | ||
|
||
#ifndef IGN_ROS2_CONTROL__MIMICJOINTSYSTEM_HH_ | ||
#define IGN_ROS2_CONTROL__MIMICJOINTSYSTEM_HH_ | ||
|
||
//! [header] | ||
#include <memory> | ||
|
||
#include <ignition/gazebo/System.hh> | ||
|
||
// This is an example to go in your urdf | ||
//! <plugin filename="mimic-joint-system" name="ign_ros2_control::MimicJointSystem"> | ||
livanov93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//! <joint_name>joint_name</joint_name> | ||
//! <mimic_joint_name>mimic_joint_name</mimic_joint_name> | ||
//! <multiplier>1.0</multiplier> | ||
//! <offset>0.0</offset> | ||
//! <joint_index>0</joint_index> | ||
//! <mimic_joint_index>0</mimic_joint_index> | ||
//! <p_gain>100.0</p_gain> | ||
//! <i_gain>0.1</i_gain> | ||
//! <d_gain>0.0</d_gain> | ||
//! <i_max>5.0</i_max> | ||
//! <i_min>-5.0</i_min> | ||
//! <cmd_max>500.0</cmd_max> | ||
//! <cmd_min>-500.0</cmd_min> | ||
//! <cmd_offset>0.0</cmd_offset> | ||
//! <dead_zone>0.001</dead_zone> | ||
//! <use_velocity_commands>false</use_velocity_commands> | ||
//! </plugin> | ||
|
||
namespace ign_ros2_control | ||
{ | ||
|
||
// Forward declaration | ||
class MimicJointSystemPrivate; // NOLINT | ||
|
||
class MimicJointSystem: // NOLINT | ||
// This class is a system. | ||
public ignition::gazebo::System, // NOLINT | ||
public ignition::gazebo::ISystemConfigure, // NOLINT | ||
// This class also implements the ISystemPreUpdate, ISystemUpdate, | ||
// and ISystemPostUpdate interfaces. | ||
public ignition::gazebo::ISystemPreUpdate, // NOLINT | ||
public ignition::gazebo::ISystemUpdate, // NOLINT | ||
public ignition::gazebo::ISystemPostUpdate // NOLINT | ||
{ | ||
public: | ||
MimicJointSystem(); | ||
|
||
// Documentation inherited | ||
|
||
public: | ||
void Configure( | ||
const ignition::gazebo::Entity & _entity, | ||
const std::shared_ptr < const sdf::Element > & _sdf, | ||
ignition::gazebo::EntityComponentManager & _ecm, | ||
ignition::gazebo::EventManager & _eventMgr) override; | ||
|
||
public: | ||
void PreUpdate( | ||
const ignition::gazebo::UpdateInfo & _info, | ||
ignition::gazebo::EntityComponentManager & _ecgm) override; | ||
|
||
public: | ||
void Update( | ||
const ignition::gazebo::UpdateInfo & _info, | ||
ignition::gazebo::EntityComponentManager & _ecm) override; | ||
|
||
public: | ||
void PostUpdate( | ||
const ignition::gazebo::UpdateInfo & _info, | ||
const ignition::gazebo::EntityComponentManager & _ecm) override; | ||
|
||
private: | ||
/// \brief Private data pointer | ||
|
||
private: | ||
std::unique_ptr < MimicJointSystemPrivate > dataPtr; | ||
}; | ||
} // namespace ign_ros2_control | ||
//! [header] | ||
|
||
#endif // IGN_ROS2_CONTROL__MIMICJOINTSYSTEM_HH_ |
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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -22,9 +22,13 @@ | |||||||
#include <vector> | ||||||||
|
||||||||
#include "ign_ros2_control/ign_system_interface.hpp" | ||||||||
|
||||||||
#include "rclcpp/executors/single_threaded_executor.hpp" | ||||||||
#include "rclcpp_lifecycle/state.hpp" | ||||||||
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp" | ||||||||
|
||||||||
#include "ign_ros2_control_parameters.hpp" | ||||||||
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.
Suggested change
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. TODO still (nitpick) |
||||||||
|
||||||||
namespace ign_ros2_control | ||||||||
{ | ||||||||
using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; | ||||||||
|
@@ -88,6 +92,15 @@ class IgnitionSystem : public IgnitionSystemInterface | |||||||
|
||||||||
/// \brief Private data class | ||||||||
std::unique_ptr<IgnitionSystemPrivate> dataPtr; | ||||||||
|
||||||||
// Parameters from ROS for ign_ros2_control | ||||||||
std::shared_ptr<ParamListener> param_listener_; | ||||||||
Params params_; | ||||||||
|
||||||||
rclcpp::Node::SharedPtr param_node_; | ||||||||
std::thread spin_thread_; | ||||||||
std::atomic<bool> stop_spin_ = false; | ||||||||
rclcpp::executors::SingleThreadedExecutor::SharedPtr exec_; | ||||||||
}; | ||||||||
|
||||||||
} // namespace ign_ros2_control | ||||||||
|
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
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.
duplicated code in the
if
andelse