NVIDIA-ISAAC-ROS / isaac_ros_common

Common utilities, packages, scripts, Dockerfiles, and testing infrastructure for Isaac ROS packages.
https://developer.nvidia.com/isaac-ros-gems
Other
197 stars 140 forks source link

How to pass bash commands to run_dev.sh ? #71

Closed mzahana closed 1 year ago

mzahana commented 1 year ago

Hi I need to pass bash commands to the docker container created using run_dev.sh when executing the docker run command

For example, I would usually do this using something like this

CMD="if [[ -f  "/file.txt" ]]; then
             do somehting
     fi"
docker run -it --name container_name image bash -c "$CMD"

However, when I add bash -c "$CMD" in the run command here, it does not log into the container terminal. Instead, I get the following output

declare -x AMENT_PREFIX_PATH="/opt/ros/humble/install"
declare -x CMAKE_PREFIX_PATH="/opt/ros/humble/install"
declare -x COLCON_PREFIX_PATH="/opt/ros/humble/install"
declare -x DEBIAN_FRONTEND="noninteractive"
declare -x DISPLAY="localhost:10.0"
declare -x FASTRTPS_DEFAULT_PROFILES_FILE="/usr/local/share/middleware_profiles/rtps_udp_profile.xml"
declare -x HOME="/home/admin"
declare -x HOSTNAME="ubuntu"
declare -x LANG="en_US.UTF-8"
declare -x LD_LIBRARY_PATH="/opt/ros/humble/install/opt/rviz_ogre_vendor/lib:/opt/ros/humble/install/lib:/usr/lib/aarch64-linux-gnu/tegra/weston:/usr/lib/aarch64-linux-gnu/tegra-egl:/usr/local/cuda-11.4/targets/aarch64-linux/lib:/usr/lib/aarch64-linux-gnu/tegra:/opt/nvidia/vpi2/lib64::/usr/lib/aarch64-linux-gnu-host:/opt/tritonserver/lib"
declare -x LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libgomp.so.1"
declare -x NVIDIA_DRIVER_CAPABILITIES="all"
declare -x NVIDIA_VISIBLE_DEVICES="all"
declare -x OLDPWD
declare -x PATH="/opt/ros/humble/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/nvidia/tao:/usr/local/cuda/bin"
declare -x PKG_CONFIG_PATH="/opt/ros/humble/install/lib/aarch64-linux-gnu/pkgconfig:/opt/ros/humble/install/lib/pkgconfig"
declare -x PWD="/workspaces"
declare -x PYTHONPATH="/opt/ros/humble/install/lib/python3.8/site-packages"
declare -x PYTHONWARNINGS="ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources"
declare -x RMW_IMPLEMENTATION="rmw_fastrtps_cpp"
declare -x ROS_DISTRO="humble"
declare -x ROS_LOCALHOST_ONLY="0"
declare -x ROS_PYTHON_VERSION="3"
declare -x ROS_ROOT="/opt/ros/humble"
declare -x ROS_VERSION="2"
declare -x SHELL="/bin/bash"
declare -x SHLVL="2"
declare -x TERM="xterm"
declare -x USERNAME="admin"
declare -x USER_GID="1000"
declare -x USER_UID="1000"
declare -x _="/bin/bash"

Can you please provide some guidance on how to do this properly?

Thanks.

jaiveersinghNV commented 1 year ago

The existing run_dev.sh script accepts a first positional argument that indicates the location of the isaac_ros-dev workspace, and then all other arguments are passed forward as arguments to docker run here. Then, our workspace entrypoint script script performs some one-time setup for ROS and udev rules, before running the /bin/bash executable provided as an argument here.

Based on your use case, you could try one of the following: