ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Unable to publish float fields with ros2 topic pub

asked 2022-06-30 21:49:41 -0500

PierceNichols gravatar image

I'm trying to publish a ros2 topic (ros2 version: humble, running on Ubuntu 22.04) that has several fields of type float32 and I can't figure out how to set them. Here's the command line and the result:

pierce@ros2-terminal:~/ssp_ws$ ros2 topic pub /att ssp_interfaces/msg/Attitude "{yaw:1.0}"

Failed to populate field: 'Attitude' object has no attribute 'yaw:1.0'

And here's the message I am trying to publish:

std_msgs/Header header

uint32 time_boot_ms
float32 roll
float32 pitch
float32 yaw
float32 rollspeed
float32 pitchspeed
float32 yawspeed

What am I doing wrong here?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2022-07-02 07:31:08 -0500

gvdhoorn gravatar image

Here's the command line and the result:

pierce@ros2-terminal:~/ssp_ws$ ros2 topic pub /att ssp_interfaces/msg/Attitude "{yaw:1.0}"
Failed to populate field: 'Attitude' object has no attribute 'yaw:1.0'

Tbh your response to Mike trying to help made me almost skip your question, but you're missing a space:

{yaw:1.0}

isn't valid yaml:

ERROR:

while scanning a plain scalar
  in "<unicode string>", line 1, column 2:
    {yaw:1.0}
     ^
found unexpected ':'
  in "<unicode string>", line 1, column 5:
    {yaw:1.0}
        ^
Please check https://pyyaml.org/wiki/YAMLColonInFlowContext for details

if you change it to {yaw: 1.0} it should work.

edit flag offensive delete link more
0

answered 2022-07-01 08:50:27 -0500

Mike Scheutzow gravatar image

According to http://design.ros2.org/articles/idl_i..., there is no native type named float32.

edit flag offensive delete link more

Comments

And according to https://design.ros2.org/articles/lega..., float32 in msg definitions maps to the underlying single precision float type. Do you have a useful answer?

PierceNichols gravatar image PierceNichols  ( 2022-07-01 12:15:16 -0500 )edit

@PierceNichols wrote:

Do you have a useful answer?

really?

gvdhoorn gravatar image gvdhoorn  ( 2022-07-02 14:58:10 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-06-30 21:49:41 -0500

Seen: 591 times

Last updated: Jul 02 '22