Skip to content

Commit

Permalink
gazebo_static_camera: use param instead of file (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-labs committed Sep 2, 2024
1 parent f3dbaaa commit cbe030d
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
# and limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
import tempfile
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, Command
from launch.substitutions.path_join_substitution import PathJoinSubstitution

from launch_ros.actions import Node
Expand Down Expand Up @@ -53,14 +52,10 @@ def generate_launch_description():
update_rate = LaunchConfiguration('update_rate')
image_width = LaunchConfiguration('image_width')
image_height = LaunchConfiguration('image_height')
camera_sdf = tempfile.NamedTemporaryFile(prefix='gazebo_static_camera_', suffix='.sdf', delete=False)

x, y, z = LaunchConfiguration('x'), LaunchConfiguration('y'), LaunchConfiguration('z')
roll, pitch, yaw = LaunchConfiguration('roll'), LaunchConfiguration('pitch'), LaunchConfiguration('yaw')

camera_sdf_xacro = ExecuteProcess(
cmd=['xacro', '-o', camera_sdf.name, ['update_rate:=', update_rate], ['image_width:=', image_width], ['image_height:=', image_height], PathJoinSubstitution([gazebo_static_camera_dir, 'models', 'camera.sdf.xacro'])])

camera_bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
Expand Down Expand Up @@ -96,12 +91,13 @@ def generate_launch_description():
'-R', roll,
'-P', pitch,
'-Y', yaw,
'-file', camera_sdf.name],
'-param', 'robot_description'],
parameters=[{
'robot_description': Command(['xacro ', 'update_rate:=', update_rate, ' image_width:=', image_width, ' image_height:=', image_height, ' ', PathJoinSubstitution([gazebo_static_camera_dir, "models", "camera.sdf.xacro"])])}],
output='screen'
)

ld = LaunchDescription(ARGUMENTS)
ld.add_action(camera_sdf_xacro)
ld.add_action(camera_bridge)
ld.add_action(spawn_camera)
return ld

0 comments on commit cbe030d

Please sign in to comment.