Skip to content

Commit

Permalink
カメラサンプル用のcolor_objects_worldを作成 (#70)
Browse files Browse the repository at this point in the history
* RGBカメラのモデルを搭載したラズパイマウスを表示

* 空のワールドに赤青緑黄の箱を配置

* cubeのmodelファイルを作成

* launchファイルにworld_name引数を追加

* world_name引数を正常に使用できるように修正

* color_objects.launch.pyからemptyworld.launch.pyを実行するように変更

* cubeのmodelのauthorを変更
  • Loading branch information
YusukeKato authored Oct 25, 2023
1 parent 4249b47 commit 1f14c7f
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 4 deletions.
1 change: 1 addition & 0 deletions raspimouse_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ install(DIRECTORY
worlds
gui
config
models
DESTINATION share/${PROJECT_NAME}/
)

Expand Down
48 changes: 48 additions & 0 deletions raspimouse_gazebo/launch/raspimouse_with_color_objects.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# The MIT License (MIT)
#
# Copyright 2023 RT Corporation <support@rt-net.jp>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch_ros.actions import SetParameter
from launch.launch_description_sources import PythonLaunchDescriptionSource


def generate_launch_description():
world_file = os.path.join(
get_package_share_directory('raspimouse_gazebo'),
'worlds',
'color_objects_world.sdf')
world_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
get_package_share_directory('raspimouse_gazebo'),
'/launch/raspimouse_with_emptyworld.launch.py']),
launch_arguments={
'world_name': world_file
}.items()
)

return LaunchDescription([
SetParameter(name='use_sim_time', value=True),
world_launch
])
19 changes: 15 additions & 4 deletions raspimouse_gazebo/launch/raspimouse_with_emptyworld.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,24 @@ def generate_launch_description():
'lidar_frame',
default_value='laser',
description='Set lidar link name.')
declare_arg_use_rgb_camera = DeclareLaunchArgument(
'use_rgb_camera',
default_value='false',
description='Set "true" to mount rgb camera.')
declare_arg_world_name = DeclareLaunchArgument(
'world_name',
default_value=get_package_share_directory('raspimouse_gazebo')+'/worlds/empty_world.sdf',
description='Set world name.')

env = {'IGN_GAZEBO_SYSTEM_PLUGIN_PATH': os.environ['LD_LIBRARY_PATH'],
'IGN_GAZEBO_RESOURCE_PATH': os.path.dirname(
get_package_share_directory('raspimouse_description'))}
world_file = os.path.join(
get_package_share_directory('raspimouse_gazebo'), 'worlds', 'empty_world.sdf')
get_package_share_directory('raspimouse_description')) + ':' +
os.path.join(get_package_share_directory('raspimouse_gazebo'), 'models'),
}
gui_config = os.path.join(
get_package_share_directory('raspimouse_gazebo'), 'gui', 'gui.config')
ign_gazebo = ExecuteProcess(
cmd=['ign gazebo -r', world_file, '--gui-config', gui_config],
cmd=['ign gazebo -r', LaunchConfiguration('world_name'), '--gui-config', gui_config],
output='screen',
additional_env=env,
shell=True
Expand All @@ -70,6 +78,7 @@ def generate_launch_description():
description_loader.lidar = LaunchConfiguration('lidar')
description_loader.lidar_frame = LaunchConfiguration('lidar_frame')
description_loader.use_gazebo = 'true'
description_loader.use_rgb_camera = LaunchConfiguration('use_rgb_camera')
description_loader.gz_control_config_package = 'raspimouse_gazebo'
description_loader.gz_control_config_file_path = 'config/raspimouse_controllers.yaml'

Expand Down Expand Up @@ -127,6 +136,8 @@ def generate_launch_description():
SetParameter(name='use_sim_time', value=True),
declare_arg_lidar,
declare_arg_lidar_frame,
declare_arg_use_rgb_camera,
declare_arg_world_name,
ign_gazebo,
ignition_spawn_entity,
robot_state_publisher,
Expand Down
16 changes: 16 additions & 0 deletions raspimouse_gazebo/models/cube_10cm_blue/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>

<model>
<name>Blue Cube 10cm</name>
<version>1.0</version>
<sdf version="1.6">model.sdf</sdf>

<author>
<name>YusukeKato</name>
<email>yusuke.kato@rt-net.jp</email>
</author>

<description>
Cube
</description>
</model>
38 changes: 38 additions & 0 deletions raspimouse_gazebo/models/cube_10cm_blue/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="cube_10cm_blue">
<link name="cube_blue_link">
<inertial>
<inertia>
<ixx>1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1</iyy>
<iyz>0</iyz>
<izz>1</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="cube_blue_collision">
<geometry>
<box>
<size>0.1 0.1 0.1</size>
</box>
</geometry>
</collision>
<visual name="cube_blue_visual">
<material>
<ambient>0 0 1 1</ambient>
<diffuse>0 0 1 1</diffuse>
<specular>0 0 0 0</specular>
<emissive>0 0 0 1</emissive>
</material>
<geometry>
<box>
<size>0.1 0.1 0.1</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>
16 changes: 16 additions & 0 deletions raspimouse_gazebo/models/cube_15cm_yellow/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>

<model>
<name>Yellow Cube 15cm</name>
<version>1.0</version>
<sdf version="1.6">model.sdf</sdf>

<author>
<name>YusukeKato</name>
<email>yusuke.kato@rt-net.jp</email>
</author>

<description>
Cube
</description>
</model>
38 changes: 38 additions & 0 deletions raspimouse_gazebo/models/cube_15cm_yellow/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="cube_15cm_yellow">
<link name="cube_yellow_link">
<inertial>
<inertia>
<ixx>1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1</iyy>
<iyz>0</iyz>
<izz>1</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="cube_yellow_collision">
<geometry>
<box>
<size>0.15 0.15 0.15</size>
</box>
</geometry>
</collision>
<visual name="cube_yellow_visual">
<material>
<ambient>1 1 0 1</ambient>
<diffuse>1 1 0 1</diffuse>
<specular>0 0 0 0</specular>
<emissive>0 0 0 1</emissive>
</material>
<geometry>
<box>
<size>0.15 0.15 0.15</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>
16 changes: 16 additions & 0 deletions raspimouse_gazebo/models/cube_5cm_red/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>

<model>
<name>Red Cube 5cm</name>
<version>1.0</version>
<sdf version="1.6">model.sdf</sdf>

<author>
<name>YusukeKato</name>
<email>yusuke.kato@rt-net.jp</email>
</author>

<description>
Cube
</description>
</model>
38 changes: 38 additions & 0 deletions raspimouse_gazebo/models/cube_5cm_red/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="cube_5cm_red">
<link name="cube_red_link">
<inertial>
<inertia>
<ixx>1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1</iyy>
<iyz>0</iyz>
<izz>1</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="cube_red_collision">
<geometry>
<box>
<size>0.05 0.05 0.05</size>
</box>
</geometry>
</collision>
<visual name="cube_red_visual">
<material>
<ambient>1 0 0 1</ambient>
<diffuse>1 0 0 1</diffuse>
<specular>0 0 0 0</specular>
<emissive>0 0 0 1</emissive>
</material>
<geometry>
<box>
<size>0.05 0.05 0.05</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>
14 changes: 14 additions & 0 deletions raspimouse_gazebo/models/cube_7.5cm_green/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<model>
<name>Green Cube 7.5cm</name>
<version>1.0</version>
<sdf version="1.6">model.sdf</sdf>

<author>
<name>YusukeKato</name>
<email>yusuke.kato@rt-net.jp</email>
</author>

<description>
Cube
</description>
</model>
38 changes: 38 additions & 0 deletions raspimouse_gazebo/models/cube_7.5cm_green/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="cube_7.5cm_green">
<link name="cube_green_link">
<inertial>
<inertia>
<ixx>1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1</iyy>
<iyz>0</iyz>
<izz>1</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="cube_green_collision">
<geometry>
<box>
<size>0.075 0.075 0.075</size>
</box>
</geometry>
</collision>
<visual name="cube_green_visual">
<material>
<ambient>0 1 0 1</ambient>
<diffuse>0 1 0 1</diffuse>
<specular>0 0 0 0</specular>
<emissive>0 0 0 1</emissive>
</material>
<geometry>
<box>
<size>0.075 0.075 0.075</size>
</box>
</geometry>
</visual>
</link>
</model>
</sdf>
62 changes: 62 additions & 0 deletions raspimouse_gazebo/worlds/color_objects_world.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" ?>
<sdf version="1.6">
<world name="default">
<physics name="1ms" type="ignored">
<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">
</plugin>
<plugin
filename="ignition-gazebo-user-commands-system"
name="ignition::gazebo::systems::UserCommands">
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
</plugin>

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

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

<model name="red_cube">
<include>
<uri>model://cube_5cm_red</uri>
</include>
<pose>0.3 0 0.025 0 0 0</pose>
</model>

<model name="green_cube">
<include>
<uri>model://cube_7.5cm_green</uri>
</include>
<pose>0 0.5 0.0375 0 0 0</pose>
</model>

<model name="blue_cube">
<include>
<uri>model://cube_10cm_blue</uri>
</include>
<pose>0 -0.5 0.05 0 0 0</pose>
</model>

<model name="yellow_cube">
<include>
<uri>model://cube_15cm_yellow</uri>
</include>
<pose>-0.5 0 0.075 0 0 0</pose>
</model>

</world>
</sdf>

0 comments on commit 1f14c7f

Please sign in to comment.