Add an environment variable in ExecuteProcess
I'm trying to add an environment variable to an ExecuteProcess action in ROS2 launch file, like so:
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import ExecuteProcess
def generate_launch_description():
share_dir = get_package_share_directory('tello_gazebo')
world_path = os.path.join(share_dir, 'worlds', 'tello.world')
model_path = os.path.join(share_dir, 'models')
cmd = ['gazebo', '--verbose', world_path]
env = {'GAZEBO_MODEL_PATH': model_path}
return LaunchDescription([
ExecuteProcess(cmd=cmd, env=env, output='screen'),
])
When I run this I get a bunch of errors -- perhaps because the environment is scrubbed of everything _except_ the environment variable I passed in, or perhaps I'm just Doing It Wrong.
$ ros2 launch tello_gazebo sim_launch.py
[INFO] [launch]: process[gazebo-1]: started with pid [22508]
[Err] [ClientConfig.cc:222] Error copying default configuration file from [/usr/share/ignition/fuel_tools//config.yaml] to [/.ignition/fuel/config.yaml]
[Err] [ClientConfig.cc:222] Error copying default configuration file from [/usr/share/ignition/fuel_tools//config.yaml] to [/.ignition/fuel/config.yaml]
Gazebo multi-robot simulator, version 9.0.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org
[Err] [Console.cc:160] Missing HOME environment variable.No log file will be generated.[Err] [ClientConfig.cc:222] Error copying default configuration file from [/usr/share/ignition/fuel_tools//config.yaml] to [/.ignition/fuel/config.yaml]
Gazebo multi-robot simulator, version 9.0.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org
[Err] [Console.cc:160] Missing HOME environment variable.No log file will be generated.[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 192.168.86.105
[Err] [RenderEngine.cc:725] Can't open display:
[Wrn] [RenderEngine.cc:93] Unable to create X window. Rendering will be disabled
[Wrn] [RenderEngine.cc:293] Cannot initialize render engine since render path type is NONE. Ignore this warning ifrendering has been turned off on purpose.
[Wrn] [ModelDatabase.cc:340] Getting models from[http://gazebosim.org/models/]. This may take a few seconds.
[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 192.168.86.105
[Err] [GuiIface.cc:499] Unable to save INI file[""]
[Wrn] [GuiIface.cc:297] Couldn't locate specified .ini. Creating file at ""
[Err] [GuiIface.cc:308] Unable to read configuration file ""
[Err] [RenderEngine.cc:725] Can't open display:
[Wrn] [RenderEngine.cc:93] Unable to create X window. Rendering will be disabled
[Wrn] [RenderEngine.cc:293] Cannot initialize render engine since render path type is NONE. Ignore this warning ifrendering has been turned off on purpose.
[Wrn] [GuiIface.cc:120] QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-clyde'
[Wrn] [GuiIface.cc:120] QXcbConnection: Could not connect to display
[Err] [GuiIface.cc:124] Could not connect to any X display.
[ERROR] [launch]: process[gazebo-1] process has died [pid 22508, exit code 255, cmd 'gazebo --verbose /home/clyde/ros2/flock2_ws/install/tello_gazebo/share/tello_gazebo/worlds/tello.world'].
Is there a ...