Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions description/gazebo/gazebo.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
</ros2_control>

<gazebo>
<plugin filename="libmock_sensor.so" name="mock_sensor::MockSensorSystem">
<plugin filename="mock_sensor" name="mock_sensor::MockSensorSystem">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tester

<update_rate>10</update_rate>
<topic_name>sensors/left_arm</topic_name>
<sensor/>
Expand All @@ -390,7 +390,7 @@
</plugin>
</gazebo>
<gazebo>
<plugin filename="libmock_sensor.so" name="mock_sensor::MockSensorSystem">
<plugin filename="mock_sensor" name="mock_sensor::MockSensorSystem">
<update_rate>10</update_rate>
<topic_name>sensors/right_arm</topic_name>
<sensor/>
Expand Down
18 changes: 14 additions & 4 deletions description/gazebo/inmoov_gazebo_physics.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@
self_collide on adjacent body meshes (avoids jitter), `gazebo_hand_link`
enables it with friction tuned for grasping. -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- Fix entire stand to the world so the robot does not fall (gz-sim may still move root; heavy mass in URDF is fallback). -->
<gazebo reference="base_node">
<static>true</static>
</gazebo>
<!-- Anchor the stand to the world so the robot does not fall over.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment too long

<gazebo reference="..."><static>true</static></gazebo> does not survive
urdf->sdf conversion: sdformat only honours <static> on the model, not on
a link, so the stand stayed dynamic and gravity toppled the robot. A fixed
joint to a `world` link is the conversion-stable way to pin the base, and
leaves every upper-body joint (torso, neck, arms, fingers) free to move.
This file is included only under use_gazebo_sim:=true, so the extra link
never reaches the real/mock-hardware description or its TF tree. -->
<link name="world"/>
<joint name="world_to_base_node" type="fixed">
<parent link="world"/>
<child link="base_node"/>
<origin xyz="0 0 0.02" rpy="0 0 0"/>
</joint>
<gazebo reference="stand_link">
<static>true</static>
</gazebo>
Expand Down
35 changes: 33 additions & 2 deletions launch/gazebo.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@
# frames without an X server — the ros_gz camera bridge stays functional.

import os
import sys
from pathlib import Path

from ament_index_python.packages import get_package_prefix, get_package_share_directory
from launch import LaunchDescription
from launch.actions import (
DeclareLaunchArgument,
ExecuteProcess,
IncludeLaunchDescription,
OpaqueFunction,
SetEnvironmentVariable,
TimerAction,
)
from launch.conditions import UnlessCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import (
LaunchConfiguration,
Expand All @@ -43,6 +46,9 @@
import yaml


_IS_DARWIN = sys.platform == "darwin"


def _gz_ros2_control_plugin_path():
pkg_share = get_package_prefix("inmoov_urdf")
plugin_path = os.path.join(pkg_share, "lib", "mock_sensor")
Expand Down Expand Up @@ -270,6 +276,11 @@ def _camera_compressor(topic: str, compressed_topic: str) -> Node:
# When headless: server-only (-s) with EGL rendering (--headless-rendering)
# so OGRE2 still renders camera sensors without an X display. Otherwise:
# normal GUI launch.
# macOS cannot run the gz server and the Qt GUI in one process: Cocoa needs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment too long

# the GUI on the main thread, so `gz sim` refuses and exits(-1) unless given
# -s or -g (gazebosim/gz-sim#44, enforced in the ruby entry point). Run the
# server with -s here and start `gz sim -g` as a second process below.
gui_server_args = "-s -r " if _IS_DARWIN else "-r "
gz_args = PythonExpression(
[
"'-s -r --headless-rendering ",
Expand All @@ -278,7 +289,8 @@ def _camera_compressor(topic: str, compressed_topic: str) -> Node:
" if '",
LaunchConfiguration("headless"),
"'.lower() in ('true', '1', 'yes') ",
"else '-r ",
"else '",
gui_server_args,
default_world,
"'",
]
Expand All @@ -288,13 +300,31 @@ def _camera_compressor(topic: str, compressed_topic: str) -> Node:
launch_arguments={"gz_args": gz_args}.items(),
)

# Second process for the Qt GUI on macOS (see gz_args). Delayed so the
# server's transport is advertising before the GUI connects to it.
gazebo_gui_actions = []
if _IS_DARWIN:
gazebo_gui_actions.append(
TimerAction(
period=6.0,
actions=[
ExecuteProcess(
cmd=["gz", "sim", "-g"],
name="gazebo_gui",
output="screen",
condition=UnlessCondition(LaunchConfiguration("headless")),
)
],
)
)

spawn_robot = TimerAction(
period=8.0,
actions=[
Node(
package="ros_gz_sim",
executable="create",
arguments=["-name", "lucy", "-topic", "robot_description", "-z", "0.5"],
arguments=["-name", "lucy", "-topic", "robot_description", "-z", "0.0"],
output="screen",
parameters=[{"use_sim_time": True}],
)
Expand Down Expand Up @@ -354,6 +384,7 @@ def spawner_actions_from_yaml(context, *args, **kwargs):
supervisor,
OpaqueFunction(function=spawner_actions_from_yaml),
gz_sim_launch,
*gazebo_gui_actions,
spawn_robot,
bridge,
*camera_compressors,
Expand Down
Loading