Last active
May 13, 2023 13:55
-
-
Save lucasw/292dc8d7dc82d6c4e99350498e173181 to your computer and use it in GitHub Desktop.
Restart an already running ros node with same remappings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Lucas Walter | |
# source rosrerun.sh my_node_name | |
# https://answers.ros.org/question/378981/is-it-possible-to-stop-or-restart-a-node-at-run-time/ | |
node_name=$1 | |
echo $node_name | |
# only take first match | |
orig_cmd=`ps -eo args | grep "__name:=$node_name" | grep __name | head -n 1` | |
# get the namespace | |
# (why don't roslaunched nodes have namespaces in the ps output?) | |
node_path=`rosnode list | grep $node_name$ | sed 's:/[^/]*$::'` | |
echo $node_path | |
echo "press ctrl-c then up arrow to run this again (only works if running this with source)" | |
cmd="$orig_cmd __ns:=$node_path" | |
history -s $cmd | |
# echo "running node first attempt, it may fail with 'shutdown request: [...$node_name...] Reason: new node registered with same name'" | |
# $cmd | |
# set -x | |
$cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From https://answers.ros.org/question/378981/is-it-possible-to-stop-or-restart-a-node-at-run-time/