-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbag2csv.bash
executable file
·35 lines (26 loc) · 1.23 KB
/
bag2csv.bash
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
#!/usr/bin/env bash
##################################################
################### parameters ###################
##################################################
input_file=${1:?'Must specify bag file to convert'}
topics_to_export=${2:-''}
echo "===================================================================================================="
echo "===== Extracting data from: ${input_file}.bag"
echo "===== Exporting topics: ${topics_to_export}"
echo "===================================================================================================="
echo -e "\n"
for topic in `rostopic list -b ${input_file}.bag` ; do
output_file="${input_file}_`echo ${topic} | tr '/' '_'`.csv"
if echo ${topics_to_export} | grep -q ${topic} ; then
echo "Saving data from topic ${topic} into file ${output_file}"
rostopic echo -p -b ${input_file}.bag ${topic} > ${output_file} &
else
echo "Ignoring topic ${topic}"
fi
done
wait
echo -e "\n"
echo "===================================================================================================="
echo "===== Finished extraction of data from ${input_file}.bag"
echo "===================================================================================================="
echo -e "\n"