Skip to content

Instantly share code, notes, and snippets.

@ymd-stella
Created August 3, 2023 23:53
Show Gist options
  • Save ymd-stella/ba722eba40e7ec1dfc9444043077f7f8 to your computer and use it in GitHub Desktop.
Save ymd-stella/ba722eba40e7ec1dfc9444043077f7f8 to your computer and use it in GitHub Desktop.
# The MIT License (MIT)
#
# Copyright (c) 2023 ymd-stella
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Tested for humble
export SHELL="/bin/bash"
export EDITOR="nano"
# export EDITOR="code --wait"
alias rfim='ros2 interface list -m | tail -n +2 | fzf'
alias rfis='ros2 interface list -s | tail -n +2 | fzf'
alias rfia='ros2 interface list -a | tail -n +2 | fzf'
function rfactiontype () {
ros2 action list --show-types | grep $1 | sed -e "s/.*\[\(.*\)\]/\1/g"
}
function rftopicprev () {
msgtype=$(ros2 topic type $1)
echo $msgtype
echo ---
ros2 interface show --no-comments $msgtype
}
function rfserviceprev () {
srvtype=$(ros2 service type $1)
echo $srvtype
echo ---
ros2 interface show --no-comments $srvtype
}
function rfactionprev () {
acttype=$(rfactiontype $1)
echo $acttype
echo ---
ros2 interface show --no-comments $acttype
}
export -f rftopicprev rfserviceprev rfactionprev rfactiontype
alias rfnl='ros2 node list | fzf --preview="ros2 node info {}"'
alias rftl='ros2 topic list | fzf --preview="rftopicprev {}"'
alias rfsl='ros2 service list | fzf --preview="rfserviceprev {}"'
alias rfal='ros2 action list | fzf --preview="rfactionprev {}"'
alias rfism='rfim | xargs ros2 interface show'
alias rfiss='rfis | xargs ros2 interface show'
alias rfisa='rfia | xargs ros2 interface show'
alias rftb='rftl | xargs ros2 topic bw'
alias rfte='rftl | xargs ros2 topic echo'
alias rfth='rftl | xargs ros2 topic hz'
alias rftt='rftl | xargs ros2 topic type'
alias rfst='rfsl | xargs ros2 service type'
alias rfat='rfal | xargs -I {} bash -c "rfactiontype {}"'
function rftp () {
topic=$(rftl)
msgtype=$(ros2 topic type $topic)
file=/tmp/${topic//\//_}.yaml
touch $file
ros2 topic pub $topic $msgtype "$(cat $file | vipe | tee $file)"
}
alias rfpd='rfnl | xargs ros2 param dump'
alias rfpl='rfnl | xargs ros2 param list --param-type'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment