Skip to content

Commit

Permalink
ワールド、launchファイル追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuwamai committed Nov 28, 2024
1 parent feb9241 commit d5fe717
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 11 deletions.
22 changes: 22 additions & 0 deletions crane_plus_examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@ $ ros2 launch crane_plus_examples demo.launch.py port_name:=/dev/ttyUSB0 use_cam
$ ros2 launch crane_plus_gazebo crane_plus_with_table.launch.py
```

#### Webカメラ搭載モデルを使用する場合

Webカメラ搭載モデルの場合は、次のコマンドを実行してください。

```sh
$ ros2 launch crane_plus_gazebo crane_plus_with_table.launch.py use_camera:=true
```

CRANE+ V2の前にArUcoマーカ付きのBoxを置いたシミュレータ環境を使用する場合は次のコマンドを実行します。
[aruco\_detection](#aruco_detection)サンプルを実行する際に使用することを想定しています。

```sh
$ ros2 launch crane_plus_gazebo crane_plus_with_aruco_cube.launch.py use_camera:=true
```

CRANE+ V2の前に赤いBoxを置いたシミュレータ環境を使用する場合は次のコマンドを実行します。
[color\_detection](#color_detection)サンプルを実行する際に使用すること想定しています。

```sh
$ ros2 launch crane_plus_gazebo crane_plus_with_red_cube.launch.py use_camera:=true
```

## サンプルプログラムを実行する

準備ができたらサンプルプログラムを実行します。
Expand Down
18 changes: 18 additions & 0 deletions crane_plus_gazebo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,22 @@ CRANE+ V2 の[Gazebo](https://gazebosim.org/home)
$ ros2 launch crane_plus_gazebo crane_plus_with_table.launch.py
```

カメラ付きモデルを使用する場合は下記コマンドを実行します。

```sh
$ ros2 launch crane_plus_gazebo crane_plus_with_table.launch.py use_camera:=true
```

CRANE+ V2の前にArUcoマーカ付きのBoxを置いたシミュレータ環境を使用する場合は下記コマンドを実行します。

```sh
$ ros2 launch crane_plus_gazebo crane_plus_with_aruco_cube.launch.py
```

CRANE+ V2の前に赤いBoxを置いたシミュレータ環境を使用する場合は下記コマンドを実行します。

```sh
$ ros2 launch crane_plus_gazebo crane_plus_with_red_cube.launch.py
```

![crane_plus_ignition](https://rt-net.github.io/images/crane-plus/crane_plus_ignition.png)
41 changes: 41 additions & 0 deletions crane_plus_gazebo/launch/crane_plus_with_aruco_cube.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2024 RT Corporation
#
# 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.

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('crane_plus_gazebo'),
'worlds',
'table_with_aruco_cube.sdf')
world_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
get_package_share_directory('crane_plus_gazebo'),
'/launch/crane_plus_with_table.launch.py']),
launch_arguments={
'world_name': world_file
}.items()
)

return LaunchDescription([
SetParameter(name='use_sim_time', value=True),
world_launch
])
41 changes: 41 additions & 0 deletions crane_plus_gazebo/launch/crane_plus_with_red_cube.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2024 RT Corporation
#
# 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.

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('crane_plus_gazebo'),
'worlds',
'table_with_red_cube.sdf')
world_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
get_package_share_directory('crane_plus_gazebo'),
'/launch/crane_plus_with_table.launch.py']),
launch_arguments={
'world_name': world_file
}.items()
)

return LaunchDescription([
SetParameter(name='use_sim_time', value=True),
world_launch
])
17 changes: 13 additions & 4 deletions crane_plus_gazebo/launch/crane_plus_with_table.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,25 @@ def generate_launch_description():
description='Use camera.'
)

declare_world_name = DeclareLaunchArgument(
'world_name',
default_value=os.path.join(
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(
get_package_share_directory('crane_plus_description'))}
world_file = os.path.join(
get_package_share_directory('crane_plus_gazebo'), 'worlds', 'table.sdf')
get_package_share_directory('crane_plus_description')) + ':' +
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', 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 Down Expand Up @@ -120,6 +128,7 @@ def generate_launch_description():
return LaunchDescription([
SetParameter(name='use_sim_time', value=True),
declare_use_camera,
declare_world_name,
ign_gazebo,
gazebo_spawn_entity,
move_group,
Expand Down
16 changes: 9 additions & 7 deletions crane_plus_gazebo/worlds/table.sdf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<sdf version="1.6">
<sdf version="1.9">
<world name="default">
<physics name="1ms" type="ignored">
<max_step_size>0.001</max_step_size>
Expand Down Expand Up @@ -37,12 +37,14 @@
<pose>0.29 0 0 0 0 1.5708</pose>
</include>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Wood%20cube%205cm
</uri>
<pose>0 -0.1 1.0 0 0 0</pose>
</include>
<model name="aruco_cube_0">
<include>
<uri>
model://aruco_cube_0
</uri>
</include>
<pose>0 -0.1 1.05 0 0 0</pose>
</model>

</world>
</sdf>
50 changes: 50 additions & 0 deletions crane_plus_gazebo/worlds/table_with_aruco_cube.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" ?>
<sdf version="1.9">
<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.ignitionrobotics.org/1.0/OpenRobotics/models/Sun
</uri>
</include>

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

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

<model name="aruco_cube_0">
<include>
<uri>
model://aruco_cube_0
</uri>
</include>
<pose>0.2 0.05 1.05 0 0 0</pose>
</model>

</world>
</sdf>
50 changes: 50 additions & 0 deletions crane_plus_gazebo/worlds/table_with_red_cube.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" ?>
<sdf version="1.9">
<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.ignitionrobotics.org/1.0/OpenRobotics/models/Sun
</uri>
</include>

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

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

<model name="aruco_cube_0">
<include>
<uri>
model://aruco_cube_0
</uri>
</include>
<pose>0.2 0.05 1.05 3.1415 0 0</pose>
</model>

</world>
</sdf>

0 comments on commit d5fe717

Please sign in to comment.