使用rostopic echo某个话题内容时,需要将终端输出保存到文件中。
将所有内容保存到文件中
rostopic echo /mavros/state > my.txt
grep提取特定内容保存到文件中
rostopic echo /mavros/state |grep -w "mode" > my.txt
注:
会存在问题,因为是默认是全缓存 ,如果提取的内容太少,会无法保存到文件中。因此需要改为行缓存。
rostopic echo /mavros/state | grep --line-buffered -w "mode" > my.txt
覆盖或者追加内容到文件中
> my.txt //是覆盖保存
>> my.txt //是追加保存