Unable to run rostopic echo

Hello everyone! I have run this code in the terminal and I just want to print only Laserscan/ranges[90] in the terminal. But its error. May I know why? And second question is can I just print the Laserscan/ranges[90] in the terminal? or I need to coding first in python file and execute the file in the terminal?

mirul@nmy-lab:~$ rostopic echo /scan sensor_msgs/LaserScan/ranges[90]
Usage: rostopic echo [options] /topic

rostopic: error: you may only specify one input topic

Hi there, according to the syntax of rostopic echo you can just use one topic at a time but here you are using two and that is the reason for your error. You can use it like rostopic echo /scan, then it will work. For the other one, you can make the simple python script, where you can use the msg.ranges[90] to get the reading at 90. Here, ranges is the part of the msg that the topic /scan uses.

A simple example code is as shown below.

. Cheers

1 Like

Thank you @navjotsinghsodhi52

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.