-
Notifications
You must be signed in to change notification settings - Fork 4
/
rosbash.install
143 lines (125 loc) · 4.2 KB
/
rosbash.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
######################################################################
# Randolph Voorhies' ROS Bash Utilities
#
# The following are various command-line utility functions and bash
# autocompletions for ROS.
######################################################################
######################################################################
# _rostopic_list_cache: Just like 'rostopic list -v', except the
# results are cached for 10 seconds. Nice for
# <tab> completion!
_rostopic_list_cache()
{
local cache_file="/tmp/rosbash.cache"
if [ -f ${cache_file} ]; then
local mod_time=$(date --utc --reference=${cache_file} +%s)
local now_time=$(date +%s)
local del_time=$((${now_time}-${mod_time}))
if [ ${del_time} -lt 10 ]; then
cat ${cache_file}
return 0
fi
fi
rostopic list -v > ${cache_file}
cat ${cache_file}
return 0
}
######################################################################
# rosiv: Launch an image_viewer node. Use tab completion to see all
# available image topics
rosiv (){
if [ -z "$1" ]
then
echo "Usage: rosiv TopicName"
echo " (Press [tab] for TopicName autocompletion)"
else
rosrun image_view image_view image:=$1
fi
}
_rosiv()
{
topics=`_rostopic_list_cache | grep "sensor_msgs/.*Image" | cut -d' ' -f 3 | uniq`
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "${topics}" -- $cur) )
}
complete -F _rosiv rosiv
######################################################################
# rosdv: Launch an disparity_viewer node. Use tab completion to see all
# available disparity topics
rosdv (){
if [ -z "$1" ]
then
echo "Usage: rosdv TopicName"
echo " (Press [tab] for TopicName autocompletion)"
else
rosrun image_view disparity_view image:=$1
fi
}
_rosdv()
{
topics=`_rostopic_list_cache | grep "stereo_msgs/DisparityImage" | cut -d' ' -f 3 | uniq`
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "${topics}" -- $cur) )
}
complete -F _rosdv rosdv
######################################################################
# rosbag completion
_rosbag()
{
local cur=${COMP_WORDS[COMP_CWORD]}
local command=${COMP_WORDS[1]}
case "${command}" in
record)
topics=`_rostopic_list_cache | cut -d' ' -f 3 | sed '/^$/d'`
COMPREPLY=( $(compgen -W "${topics}" -- $cur) )
return 0
;;
play)
if [ "${COMP_CWORD}" == "2" ]; then
COMPREPLY=( $(compgen -o plusdirs -o nospace -o filenames -f -X "!*.bag" -- $cur) )
return 0
else
return 0
fi
;;
esac
COMPREPLY=( $(compgen -W "check compress decompress filter fix help info play record reindex" -- $cur) )
}
complete -F _rosbag -o filenames rosbag
######################################################################
# rxplot completion
_rxplot()
{
local cur=${COMP_WORDS[COMP_CWORD]}
topics=`rostopic list`
#if echo "$topics" | grep -x "$cur" ; then
# COMPREPLY=( $(compgen -W "" -- $cur) )
#else
COMPREPLY=( $(compgen -W "${topics}" -- $cur) )
#fi
}
complete -F _rxplot rxplot
######################################################################
# rosconfig: just a shortcut for dynamic_reconfigure reconfigure_gui
alias rosconfig='rosrun dynamic_reconfigure reconfigure_gui'
######################################################################
# rviz: just a shortcut for rviz rviz
alias rviz='rosrun rviz rviz'
######################################################################
# dynparam: just a shortcut for dynamic_reconfigure dynparam
alias dynparam='rosrun dynamic_reconfigure dynparam'
######################################################################
# roslaunch completion: Now with .xml completion!
#function _roslaunch {
# _roscomplete_search_dir "-type f -regex .*\.launch$\|.*\.test$\|.*\.xml$"
# if [[ $COMP_CWORD == 1 ]]; then
# arg="${COMP_WORDS[COMP_CWORD]}"
# COMPREPLY=($(compgen -o plusdirs -f -X "!*.launch" -- ${arg}) \
# $(compgen -o plusdirs -f -X "!*.xml" -- ${arg}) \
# ${COMPREPLY[@]} \
# $(compgen -o plusdirs -f -X "!*.test" -- ${arg})
# )
# fi
#}
#complete -F _roslaunch roslaunch
# vim:syntax=sh