-
Notifications
You must be signed in to change notification settings - Fork 4
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 coupled_pendulum tutorial #228
Draft
martinaxgloria
wants to merge
1
commit into
robotology:main
Choose a base branch
from
martinaxgloria:feat/addCoupledPendulum
base: main
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.
+360
−0
Draft
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Run coupled pendulum tutorial in Gazebo | ||
|
||
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. Somewhere here we should document that this model has a runtime dependency on |
||
## Run model in Gazebo with YARP integration | ||
|
||
- 1st terminal: | ||
|
||
~~~bash | ||
yarp server | ||
~~~ | ||
|
||
- 2nd terminal: | ||
- Update the `GZ_SIM_RESOURCE_PATH` environment variable to point to the `tutorial` folder: | ||
|
||
~~~ | ||
export GZ_SIM_RESOURCE_PATH = $GZ_SIM_RESOURCE_PATH:<path-to-tutorial-folder> | ||
~~~ | ||
|
||
- Then, launch Gazebo: | ||
|
||
~~~ | ||
cd <path-to-tutorial-folder>/coupled_pendulum | ||
gz sim coupled_pendulum_world.sdf | ||
~~~ | ||
|
||
The Gazebo GUI will open and the coupled pendulum should be already spawned in the scene. | ||
|
||
- 3rd terminal: | ||
|
||
~~~bash | ||
cd tutorial/coupled_pendulum | ||
yarpmotorgui | ||
~~~ | ||
|
||
The [yarpmotorgui](https://www.yarp.it/latest/group__yarpmotorgui.html) interface will open and it should automatically prompt you to select the `/coupledPendulumGazebo/body` part. | ||
|
||
Click Ok. | ||
|
||
Finally start the simulation in Gazebo (click on the Play button on the bottom left). |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE robot PUBLIC "-//YARP//DTD yarprobotinterface 3.0//EN" "http://www.yarp.it/DTD/yarprobotinterfaceV3.0.dtd"> | ||
|
||
<robot name="coupled_pendulum" portprefix="coupled_pendulum" build="0" xmlns:xi="http://www.w3.org/2001/XInclude"> | ||
<devices> | ||
<device name="coupled_pendulum_nws_yarp" type="controlBoard_nws_yarp"> | ||
<!-- See https://www.yarp.it/latest/classControlBoard__nws__yarp.html for parameter documentation --> | ||
<param name="name"> /coupledPendulumGazebo/body </param> | ||
<param name="period"> 0.01 </param> | ||
<action phase="startup" level="5" type="attach"> | ||
<!-- This is the same name that we passed with the yarpDeviceName to the gazebo_controlboard plugin --> | ||
<param name="device"> controlboard_plugin_device </param> | ||
</action> | ||
<action phase="shutdown" level="5" type="detach" /> | ||
</device> | ||
</devices> | ||
</robot> |
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,52 @@ | ||
disableImplicitNetworkWrapper | ||
yarpDeviceName controlboard_plugin_device | ||
jointNames (fixed_base upper_joint lower_joint) | ||
|
||
[COUPLING] | ||
device couplingICubEye | ||
actuatedAxesNames (fixed_base upper_joint lower_joint) | ||
actuatedAxesPosMin (0.0 -200.0 -200.0) | ||
actuatedAxesPosMax (0.0 200.0 200.0) | ||
|
||
#PIDs: | ||
[POSITION_CONTROL] | ||
controlUnits metric_units | ||
controlLaw joint_pid_gazebo_v1 | ||
kp (0.0 3000.0 3000.0) | ||
kd (0.0 2.0 2.0) | ||
ki (0.0 0.1 0.1) | ||
maxInt (0.0 9999 9999) | ||
maxOutput (0.0 9999 9999) | ||
shift (0.0 0.0 0.0) | ||
ko (0.0 0.0 0.0) | ||
stictionUp (0.0 0.0 0.0) | ||
stictionDwn (0.0 0.0 0.0) | ||
|
||
[VELOCITY_CONTROL] | ||
controlUnits metric_units | ||
controlLaw joint_pid_gazebo_v1 | ||
velocityControlImplementationType integrator_and_position_pid | ||
kp (0.0 500.0 500.0) | ||
kd (0.0 2.0 2.0) | ||
ki (0.0 0.1 0.1) | ||
maxInt (0.0 9999 9999) | ||
maxOutput (0.0 9999 9999) | ||
shift (0.0 0.0 0.0) | ||
ko (0.0 0.0 0.0) | ||
stictionUp (0.0 0.0 0.0) | ||
stictionDwn (0.0 0.0 0.0) | ||
|
||
[LIMITS] | ||
jntPosMax (0.0 200.0 200.0) | ||
jntPosMin (0.0 -200.0 -200.0) | ||
jntVelMax (0.0 100.0 100.0) | ||
|
||
[TRAJECTORY_GENERATION] | ||
# Uncomment one of the following lines to select the trajectory generation method | ||
#trajectory_type constant_speed | ||
#trajectory_type trapezoidal_speed | ||
trajectory_type minimum_jerk | ||
|
||
# Uncomment the following lines to override the default trajectory generation parameters | ||
#refSpeed 10.0 | ||
#refAcceleration 10.0 |
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,72 @@ | ||
<?xml version="1.0"?> | ||
|
||
<sdf version="1.7"> | ||
<world name="tutorial_controlboard"> | ||
<physics name="1ms" type="ignored"> | ||
<max_step_size>0.001</max_step_size> | ||
<real_time_factor>1.0</real_time_factor> | ||
</physics> | ||
<plugin | ||
filename="gz-sim-physics-system" | ||
name="gz::sim::systems::Physics"> | ||
</plugin> | ||
<plugin | ||
filename="gz-sim-user-commands-system" | ||
name="gz::sim::systems::UserCommands"> | ||
</plugin> | ||
<plugin | ||
filename="gz-sim-sensors-system" | ||
name="gz::sim::systems::Sensors"> | ||
</plugin> | ||
<plugin | ||
filename="gz-sim-scene-broadcaster-system" | ||
name="gz::sim::systems::SceneBroadcaster"> | ||
</plugin> | ||
|
||
<light type="directional" name="sun"> | ||
<cast_shadows>true</cast_shadows> | ||
<pose>0 0 10 0 0 0</pose> | ||
<diffuse>0.8 0.8 0.8 1</diffuse> | ||
<specular>0.2 0.2 0.2 1</specular> | ||
<attenuation> | ||
<range>1000</range> | ||
<constant>0.9</constant> | ||
<linear>0.01</linear> | ||
<quadratic>0.001</quadratic> | ||
</attenuation> | ||
<direction>-0.5 0.1 -0.9</direction> | ||
</light> | ||
|
||
<model name="ground_plane"> | ||
<static>true</static> | ||
<link name="link"> | ||
<collision name="collision"> | ||
<geometry> | ||
<plane> | ||
<normal>0 0 1</normal> | ||
<size>100 100</size> | ||
</plane> | ||
</geometry> | ||
</collision> | ||
<visual name="visual"> | ||
<geometry> | ||
<plane> | ||
<normal>0 0 1</normal> | ||
<size>100 100</size> | ||
</plane> | ||
</geometry> | ||
<material> | ||
<ambient>0.8 0.8 0.8 1</ambient> | ||
<diffuse>0.8 0.8 0.8 1</diffuse> | ||
<specular>0.8 0.8 0.8 1</specular> | ||
</material> | ||
</visual> | ||
</link> | ||
</model> | ||
|
||
<include> | ||
<uri>model://coupled_pendulum/model.sdf</uri> | ||
</include> | ||
|
||
</world> | ||
</sdf> |
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,174 @@ | ||
<?xml version="1.0"?> | ||
|
||
<sdf version="1.7"> | ||
|
||
<model name="coupled_pendulum"> | ||
<!-- <pose>0 0 0.2 0 0 0</pose> --> | ||
<joint name="fixed_base" type="revolute"> | ||
<parent>world</parent> | ||
<child>base_link</child> | ||
<axis> | ||
<xyz>1 0 0</xyz> | ||
<limit> | ||
<lower>-5</lower> | ||
<upper>5</upper> | ||
<effort>100</effort> | ||
<velocity>100</velocity> | ||
</limit> | ||
<dynamics> | ||
<damping>0.0</damping> | ||
<spring_reference>0</spring_reference> | ||
<spring_stiffness>0.0</spring_stiffness> | ||
</dynamics> | ||
</axis> | ||
</joint> | ||
<link name='base_link'> | ||
<inertial> | ||
<pose>0 0 0 0 0 0</pose> | ||
<mass>100</mass> | ||
<inertia> | ||
<ixx>1</ixx> | ||
<ixy>0</ixy> | ||
<ixz>0</ixz> | ||
<iyy>1</iyy> | ||
<iyz>0</iyz> | ||
<izz>1</izz> | ||
</inertia> | ||
</inertial> | ||
<collision name='base_link_fixed_joint_lump__base_collision'> | ||
<pose>0 0 1 0 0 0</pose> | ||
<geometry> | ||
<box> | ||
<size>0.15 0.15 2.15</size> | ||
</box> | ||
</geometry> | ||
</collision> | ||
<visual name='base_link_fixed_joint_lump__base_visual'> | ||
<pose>0 0 1 0 0 0</pose> | ||
<geometry> | ||
<box> | ||
<size>0.15 0.15 2.15</size> | ||
</box> | ||
</geometry> | ||
</visual> | ||
</link> | ||
<joint name='upper_joint' type='revolute'> | ||
<pose relative_to='base_link'>0.15 0 2 -1.5708 0 0</pose> | ||
<parent>base_link</parent> | ||
<child>upper_link</child> | ||
<axis> | ||
<xyz>1 0 0</xyz> | ||
<limit> | ||
<lower>-5</lower> | ||
<upper>5</upper> | ||
<effort>100</effort> | ||
<velocity>100</velocity> | ||
</limit> | ||
<dynamics> | ||
<damping>0.0</damping> | ||
<spring_reference>0</spring_reference> | ||
<spring_stiffness>0.0</spring_stiffness> | ||
</dynamics> | ||
</axis> | ||
</joint> | ||
<link name='upper_link'> | ||
<pose relative_to='upper_joint'>0 0 0 0 0 0</pose> | ||
<self_collide>0</self_collide> | ||
<inertial> | ||
<pose>0 0 0.5 0 0 0</pose> | ||
<mass>1</mass> | ||
<inertia> | ||
<ixx>1.0</ixx> | ||
<ixy>0</ixy> | ||
<ixz>0</ixz> | ||
<iyy>1.0</iyy> | ||
<iyz>0</iyz> | ||
<izz>1.0</izz> | ||
</inertia> | ||
</inertial> | ||
<collision name='upper_link_collision'> | ||
<pose>0 0 0.5 0 0 0</pose> | ||
<geometry> | ||
<box> | ||
<size>0.15 0.15 1.0</size> | ||
</box> | ||
</geometry> | ||
</collision> | ||
<visual name='upper_link_visual'> | ||
<pose>0 0 0.5 0 0 0</pose> | ||
<geometry> | ||
<box> | ||
<size>0.15 0.15 1.0</size> | ||
</box> | ||
</geometry> | ||
</visual> | ||
</link> | ||
|
||
<joint name='lower_joint' type='revolute'> | ||
<pose relative_to='base_link'>-0.15 0 2 -1.5708 0 0</pose> | ||
<parent>base_link</parent> | ||
<child>lower_link</child> | ||
<axis> | ||
<xyz>1 0 0</xyz> | ||
<limit> | ||
<lower>-5</lower> | ||
<upper>5</upper> | ||
<effort>100</effort> | ||
<velocity>100</velocity> | ||
</limit> | ||
<dynamics> | ||
<damping>0.0</damping> | ||
<spring_reference>0</spring_reference> | ||
<spring_stiffness>0.0</spring_stiffness> | ||
</dynamics> | ||
</axis> | ||
</joint> | ||
<link name='lower_link'> | ||
<pose relative_to='lower_joint'>0 0 0 0 0 0</pose> | ||
<self_collide>0</self_collide> | ||
<inertial> | ||
<pose>0.0 0 0.5 0 0 0</pose> | ||
<mass>1</mass> | ||
<inertia> | ||
<ixx>1.0</ixx> | ||
<ixy>0</ixy> | ||
<ixz>0</ixz> | ||
<iyy>1.0</iyy> | ||
<iyz>0</iyz> | ||
<izz>1.0</izz> | ||
</inertia> | ||
</inertial> | ||
<collision name='lower_link_collision'> | ||
<pose>0.0 0 0.5 0 0 0</pose> | ||
<geometry> | ||
<box> | ||
<size>0.15 0.15 1.0</size> | ||
</box> | ||
</geometry> | ||
</collision> | ||
<visual name='lower_link_visual'> | ||
<pose>0.0 0 0.5 0 0 0</pose> | ||
<geometry> | ||
<box> | ||
<size>0.15 0.15 1.0</size> | ||
</box> | ||
</geometry> | ||
</visual> | ||
</link> | ||
|
||
<!-- Launch the other YARP devices, in this case a controlBoard_nws_yarp to expose the | ||
controlboard functionalities via YARP ports --> | ||
<plugin name="gzyarp::ControlBoard" filename="gz-sim-yarp-controlboard-system"> | ||
<yarpConfigurationFile> | ||
model://coupled_pendulum/conf/gazebo_controlboard.ini | ||
</yarpConfigurationFile> | ||
<initialConfiguration>0.0</initialConfiguration> | ||
</plugin> | ||
<plugin name="gzyarp::RobotInterface" filename="gz-sim-yarp-robotinterface-system"> | ||
<yarpRobotInterfaceConfigurationFile> | ||
model://coupled_pendulum/conf/coupled_pendulum_nws.xml | ||
</yarpRobotInterfaceConfigurationFile> | ||
</plugin> | ||
</model> | ||
|
||
</sdf> |
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,6 @@ | ||
robot coupledPendulumGazebo | ||
parts (body) | ||
|
||
|
||
|
||
//DO NOT REMOVE THIS LINE |
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.
Why we added this?
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.
My bad, I said to @martinaxgloria to add find_package but actually since it is a run-time and not compile-time dependency this is not needed