Publish ROS message from terminal

Here are some simple steps to make you know how to publish a ROS message in terminal by command line:

Step 1: Set up roscore by typing "roscore" in any terminal.

Step 2: Define a ROS message in your ROS workspace, I get a nonsense message ../message/Test.msg, it's made up of

            uint8 a

            uint8 b

            float32 c

            int32 d

            int64 e

            int8 f

Step 3: Open 2 new terminal by terminator or Ctrl+Alt+T, named them left_cmd and right_cmd here.

Step 4: In left_cmd, build the ROS workspace by typing "catkin_make" bellow workspace, then type "rostopic pub /cmd_0 message/Test -- 0 1 2.0 3 4 5" to publish single meaasge out.

Step 5: In roght_cmd, type "rostopic list". If lucky, you can find a topic with the name cmd_0.

Step 6: Check cmd_0, in right_cmd, type "ostopic echo cmd_0", it should come out with:      

            a: 0

            b: 1

            c: 2.0

            d: 3

            e 4

            f: 5


notes: In step 4, you can also type "rostopic pub -1 /cmd_0 message/Test -- 0 1 2.0 3 4 5"

                             this will keep on publishing message for 3 seconds.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值