Nav2 with No Screen

Is it possible to use the stretch without a screen? I know about the Moonlight wireless HDMI dongle you can get, but that still requires you to connect to it. Ideally, I’d like to boot up Nav2 on startup, and then have it run a set ros2 launch file which has it do some action (Like the patrol demo)

Hey @byrnete, you definitely can get Nav2 (or any other ROS2 launch file) to start automatically when the robot boots up. This is typically done in Linux by writing a systemd unit file. I can put together a tutorial if you’d like. An easier way is to write a Bash script and put in Startup Applications (which actually uses systemd under the hood). @olaghattas’s team has done this and might be able to share how they did it / how well it works.

Hey @byrnete and @bshah,

I couldn’t upload a txt file so I just pasted the .sh script that we used to launch nav2 on boot. You will need to change some things like HELLO_FLEET_ID and the map. Just save the script in an .sh file then add it to startup applications.

Let me know if you need any help getting it to work.

Note: some times nav2 doesn’t start correctly so you might need to restart.

################## START OF SCRIPT #############
#!/bin/bash

######################
# STRETCH BASHRC SETUP
######################
export HELLO_FLEET_PATH=/home/hello-robot/stretch_user &&
export HELLO_FLEET_ID=stretch-se3-#### &&
export PATH=${PATH}:~/.local/bin &&
export LRS_LOG_LEVEL=None &&
export PYTHONWARNINGS='ignore:setup.py install is deprecated,ignore:Invalid dash-separated options,ignore:pkg_resources is deprecated as an API,ignore:Usage of dash-separated' &&
export _colcon_cd_root=/home/hello-robot/ament_ws &&
source /opt/ros/humble/setup.bash &&

export ROS_IP=192.168.1.32 &&
export CAMERA1_dock='153122071664' &&
export ROS_MASTER_URI=http://192.168.1.32:11311 &&
export ROS_DOMAIN_ID=25 &&

export cam_loc="doorway" &&
export cmd_vel="stretch/cmd_vel" &&

source /opt/ros/humble/setup.bash &&
source /home/hello-robot/smarthome_ws/install/setup.bash &&
source /home/hello-robot/ament_ws/install/setup.bash &&
source /usr/share/colcon_cd/function/colcon_cd.sh &&

port="/dev/hello-lrf"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"

port="/dev/hello-wacc"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"


# ls /dev/ | grep hello added so startup doesnt fail

port="/dev/hello-dynamixel-head"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"


port="/dev/hello-dynamixel-wrist"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"


port="/dev/hello-motor-arm"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"

port="/dev/hello-motor-left-wheel"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"

port="/dev/hello-motor-lift"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"

port="/dev/hello-respeaker"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"

port="/dev/hello-nav-head-camera"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"


port="/dev/hello-motor-right-wheel"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"

port="/dev/hello-pimu"
# Loop until the serial port is available
while true; do
    if [ -c "$port" ]; then
        echo "Serial port $port is available."
        break  # Exit the loop once the serial port is available
    else
        echo "Serial port $port is not available. Waiting..."
        sleep 1  # Wait for 1 second before checking again
    fi
done
echo "Serial port $SERIAL_PORT is available, proceeding with further actions"


echo "Script will run after 120 seconds sleep..."
sleep 300s # sleep for 5 mins

echo "Starting processes..."

ros2 launch stretch_nav2 navigation.launch.py map:=/home/hello-robot/stretch_user/maps/map.yaml > /tmp/navigation.txt 2>&1 &
sleep 60s

ros2 launch realsense2_camera rs_launch.py &
sleep 30s

ros2 service call /runstop std_srvs/srv/SetBool data:\ false\ &
sleep 30s

ros2 launch shr_plan real_robot.launch.py > /tmp/real_robot.txt 2>&1 &
sleep 60s

ros2 launch shr_plan action_servers.launch.py > /tmp/action_server.txt 2>&1 &
sleep 60s

ros2 run shr_plan planning_controller_node > /tmp/planner.txt 2>&1 &

sleep 20s 
ros2 run simple_logger simple_logger_web > /tmp/logger.txt 2>&1 &

wait

################## END OF SCRIPT #############
1 Like