Skip to content

Commit

Permalink
GazeboのCameraモデル対応したコードのign->gz対応
Browse files Browse the repository at this point in the history
  • Loading branch information
mizonon committed Dec 5, 2024
1 parent f6a5c39 commit bd9e24d
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 62 deletions.
7 changes: 3 additions & 4 deletions crane_plus_description/urdf/crane_plus.gazebo.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
name_link_4
name_link_hand
use_camera
use_ignition
config_package
config_file_path
">
Expand Down Expand Up @@ -76,9 +75,9 @@

<xacro:if value="$(arg use_camera)">
<gazebo>
<plugin filename="ignition-gazebo-sensors-system" name="ignition::gazebo::systems::Sensors">
<render_engine>ogre2</render_engine>
</plugin>
<plugin filename="gz-sim-sensors-system" name="gz::sim::systems::Sensors">
<render_engine>ogre2</render_engine>
</plugin>
</gazebo>

<gazebo reference="camera_color_optical_frame">
Expand Down
1 change: 0 additions & 1 deletion crane_plus_description/urdf/crane_plus.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
name_link_4="${NAME_LINK_4}"
name_link_hand="${NAME_LINK_HAND}"
use_camera="$(arg use_camera)"
use_ignition="$(arg use_ignition)"
config_package="$(arg gz_control_config_package)"
config_file_path="$(arg gz_control_config_file_path)" />

Expand Down
48 changes: 24 additions & 24 deletions crane_plus_gazebo/gui/gui.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<!-- 3D scene -->
<plugin filename="MinimalScene" name="3D View">
<ignition-gui>
<gz-gui>
<title>3D View</title>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
Expand All @@ -44,77 +44,77 @@

<!-- Plugins that add functionality to the scene -->
<plugin filename="EntityContextMenuPlugin" name="Entity context menu">
<ignition-gui>
<gz-gui>
<property key="state" type="string">floating</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>
<plugin filename="GzSceneManager" name="Scene Manager">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>
<plugin filename="InteractiveViewControl" name="Interactive view control">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>
<plugin filename="CameraTracking" name="Camera Tracking">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>
<plugin filename="MarkerManager" name="Marker manager">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>
<plugin filename="SelectEntities" name="Select Entities">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>

<plugin filename="Spawn" name="Spawn Entities">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>

<plugin filename="VisualizationCapabilities" name="Visualization Capabilities">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</gz-gui>
</plugin>

<!-- World control -->
Expand Down Expand Up @@ -166,7 +166,7 @@

<!-- Insert simple shapes -->
<plugin filename="Shapes" name="Shapes">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="x" type="double">0</property>
<property key="y" type="double">0</property>
Expand All @@ -180,7 +180,7 @@

<!-- Insert lights -->
<plugin filename="Lights" name="Lights">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="x" type="double">250</property>
<property key="y" type="double">0</property>
Expand All @@ -194,7 +194,7 @@

<!-- Translate / rotate -->
<plugin filename="TransformControl" name="Transform control">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="x" type="double">0</property>
<property key="y" type="double">50</property>
Expand All @@ -203,7 +203,7 @@
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
<property key="cardBackground" type="string">#777777</property>
</ignition-gui>
</gz-gui>

<!-- disable legacy features used to connect this plugin to GzScene3D -->
<legacy>false</legacy>
Expand All @@ -220,12 +220,12 @@
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
<property key="cardBackground" type="string">#777777</property>
</ignition-gui>
</gz-gui>
</plugin>

<!-- Copy/Paste -->
<plugin filename="CopyPaste" name="CopyPaste">
<ignition-gui>
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="x" type="double">300</property>
<property key="y" type="double">50</property>
Expand All @@ -234,7 +234,7 @@
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
<property key="cardBackground" type="string">#777777</property>
</ignition-gui>
</gz-gui>
</plugin>

<!-- Inspector -->
Expand Down
45 changes: 30 additions & 15 deletions crane_plus_gazebo/launch/crane_plus_with_table.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import os

from ament_index_python.packages import get_package_share_directory
from crane_plus_description.robot_description_loader import RobotDescriptionLoader
from crane_plus_description.robot_description_loader \
import RobotDescriptionLoader
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import ExecuteProcess
Expand All @@ -38,22 +39,27 @@ def generate_launch_description():
declare_world_name = DeclareLaunchArgument(
'world_name',
default_value=os.path.join(
get_package_share_directory('crane_plus_gazebo'), 'worlds', 'table.sdf'),
get_package_share_directory('crane_plus_gazebo'), 'worlds',
'table.sdf'),
description='Set world name.'
)

# PATHを追加で通さないとSTLファイルが読み込まれない
env = {'IGN_GAZEBO_SYSTEM_PLUGIN_PATH': os.environ['LD_LIBRARY_PATH'],
'IGN_GAZEBO_RESOURCE_PATH': os.path.dirname(
env = {'GZ_SIM_SYSTEM_PLUGIN_PATH': os.environ['LD_LIBRARY_PATH'],
'GZ_SIM_RESOURCE_PATH': os.path.dirname(
get_package_share_directory('crane_plus_description')) + ':' +
os.path.join(get_package_share_directory('crane_plus_gazebo'), 'models'),
os.path.join(get_package_share_directory('crane_plus_gazebo'),
'models'),
}

gui_config = os.path.join(
get_package_share_directory('crane_plus_gazebo'), 'gui', 'gui.config')
# -r オプションで起動時にシミュレーションをスタートしないと、コントローラが起動しない
ign_gazebo = ExecuteProcess(
cmd=['ign gazebo -r', LaunchConfiguration('world_name'), '--gui-config', gui_config],
gz_gazebo = ExecuteProcess(
cmd=['gz sim -r',
LaunchConfiguration('world_name'),
'--gui-config',
gui_config],
output='screen',
additional_env=env,
shell=True
Expand All @@ -73,7 +79,9 @@ def generate_launch_description():
description_loader.use_camera = LaunchConfiguration('use_camera')
description_loader.use_gazebo = 'true'
description_loader.gz_control_config_package = 'crane_plus_control'
description_loader.gz_control_config_file_path = 'config/crane_plus_controllers.yaml'
description_loader.gz_control_config_file_path = (
'config/crane_plus_controllers.yaml'
)
description = description_loader.load()

move_group = IncludeLaunchDescription(
Expand All @@ -98,37 +106,44 @@ def generate_launch_description():
)

spawn_joint_state_controller = ExecuteProcess(
cmd=['ros2 run controller_manager spawner joint_state_broadcaster'],
cmd=['ros2 run controller_manager spawner '
'joint_state_broadcaster'],
shell=True,
output='screen',
)

spawn_arm_controller = ExecuteProcess(
cmd=['ros2 run controller_manager spawner crane_plus_arm_controller'],
cmd=['ros2 run controller_manager spawner '
'crane_plus_arm_controller'],
shell=True,
output='screen',
)

spawn_gripper_controller = ExecuteProcess(
cmd=['ros2 run controller_manager spawner crane_plus_gripper_controller'],
cmd=[
'ros2 run controller_manager spawner '
'crane_plus_gripper_controller'
],
shell=True,
output='screen',
)

bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=['/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock',
'image_raw@sensor_msgs/msg/Image[ignition.msgs.Image',
'camera_info@sensor_msgs/msg/CameraInfo[ignition.msgs.CameraInfo'],
arguments=[
'/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock',
'image_raw@sensor_msgs/msg/Image[gz.msgs.Image',
'camera_info@sensor_msgs/msg/CameraInfo[gz.msgs.CameraInfo'
],
output='screen'
)

return LaunchDescription([
SetParameter(name='use_sim_time', value=True),
declare_use_camera,
declare_world_name,
ign_gazebo,
gz_gazebo,
gazebo_spawn_entity,
move_group,
move_group_camera,
Expand Down
18 changes: 9 additions & 9 deletions crane_plus_gazebo/worlds/table_with_aruco_cube.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
<real_time_factor>1.0</real_time_factor>
</physics>
<plugin
filename="ignition-gazebo-physics-system"
name="ignition::gazebo::systems::Physics">
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="ignition-gazebo-user-commands-system"
name="ignition::gazebo::systems::UserCommands">
filename="gz-sim-user-commands-system"
name="gz::sim::systems::UserCommands">
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Sun
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Sun
</uri>
</include>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Ground%20Plane
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Ground%20Plane
</uri>
</include>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Table
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Table
</uri>
<pose>0.29 0 0 0 0 1.5708</pose>
</include>
Expand Down
19 changes: 10 additions & 9 deletions crane_plus_gazebo/worlds/table_with_red_cube.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,35 @@
<max_step_size>0.001</max_step_size>
<real_time_factor>1.0</real_time_factor>
</physics>

<plugin
filename="ignition-gazebo-physics-system"
name="ignition::gazebo::systems::Physics">
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="ignition-gazebo-user-commands-system"
name="ignition::gazebo::systems::UserCommands">
filename="gz-sim-user-commands-system"
name="gz::sim::systems::UserCommands">
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Sun
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Sun
</uri>
</include>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Ground%20Plane
https://fuel.gazebosim.or/1.0/OpenRobotics/models/Ground%20Plane
</uri>
</include>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Table
https://fuel.gazebosim.or/1.0/OpenRobotics/models/Table
</uri>
<pose>0.29 0 0 0 0 1.5708</pose>
</include>
Expand Down

0 comments on commit bd9e24d

Please sign in to comment.