Skip to content
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 cart-pole demo #289

Merged
merged 1 commit into from
Apr 25, 2024
Merged

Add cart-pole demo #289

merged 1 commit into from
Apr 25, 2024

Conversation

christophfroehlich
Copy link
Contributor

Similar to ros-controls/gazebo_ros2_control#172

The difference to gazebo_ros2_control is that it also works with position command interface of the cart. gz_ros2_control does not directly set the position but implements a position controller with velocity output:

} else if (this->dataPtr->joints_[i].joint_control_method & POSITION) {
// Get error in position
double error;
error = (this->dataPtr->joints_[i].joint_position -
this->dataPtr->joints_[i].joint_position_cmd) * *this->dataPtr->update_rate;
// Calculate target velcity
double target_vel = -this->dataPtr->position_proportional_gain_ * error;
auto vel =
this->dataPtr->ecm->Component<sim::components::JointVelocityCmd>(
this->dataPtr->joints_[i].sim_joint);
if (vel == nullptr) {
this->dataPtr->ecm->CreateComponent(
this->dataPtr->joints_[i].sim_joint,
sim::components::JointVelocityCmd({target_vel}));
} else if (!vel->Data().empty()) {
vel->Data()[0] = target_vel;
}

@ahcorde ahcorde merged commit 27af210 into master Apr 25, 2024
4 of 8 checks passed
@ahcorde ahcorde deleted the add_pendulum_demo branch April 25, 2024 20:42
@ahcorde
Copy link
Collaborator

ahcorde commented Apr 25, 2024

Thank you @christophfroehlich for the examples, do you want to backport this ?

@christophfroehlich
Copy link
Contributor Author

yes please!

@christophfroehlich
Copy link
Contributor Author

@Mergifyio backport humble iron

Copy link
Contributor

mergify bot commented Apr 26, 2024

backport humble iron

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Apr 26, 2024
(cherry picked from commit 27af210)

# Conflicts:
#	ign_ros2_control_demos/launch/pendulum_example_effort.launch.py
#	ign_ros2_control_demos/launch/pendulum_example_position.launch.py
#	ign_ros2_control_demos/urdf/test_pendulum_effort.xacro.urdf
#	ign_ros2_control_demos/urdf/test_pendulum_position.xacro.urdf
mergify bot pushed a commit that referenced this pull request Apr 26, 2024
(cherry picked from commit 27af210)
ahcorde pushed a commit that referenced this pull request Apr 26, 2024
(cherry picked from commit 27af210)

# Conflicts:
#	ign_ros2_control_demos/launch/pendulum_example_effort.launch.py
#	ign_ros2_control_demos/launch/pendulum_example_position.launch.py
#	ign_ros2_control_demos/urdf/test_pendulum_effort.xacro.urdf
#	ign_ros2_control_demos/urdf/test_pendulum_position.xacro.urdf

Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
ahcorde pushed a commit that referenced this pull request Apr 26, 2024
(cherry picked from commit 27af210)

Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants