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

Socketcan_bridge : Error when publishing on sent_messages topic

asked 2019-09-23 16:37:06 -0600

prj1508 gravatar image

updated 2019-09-23 19:24:39 -0600

jayess gravatar image

Hi I am running socketcan_bridge package and trying to publish a can_msgs/Frame type message to a rostopic using the command

rostopic pub -r 10 /sent_messages can_msgs/Frame 'header:
  seq: 0
  stamp: {secs: 0, nsecs: 0}
  frame_id: ''
id: 0x29F
is_rtr: false
is_extended: false
is_error: false
dlc: 8
data: [53,70,40,00,00,00,40,6a]

' from terminal, but it is throwing an error as follows

ERROR: Unable to publish message. One of the fields has an incorrect type:
  field data[] must be unsigned integer type

msg file:
std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
uint32 id
bool is_rtr
bool is_extended
bool is_error
uint8 dlc
uint8[8] data

The problem is due to '6a' which is not uint8. Should I change the data type in .msg to account for this? If so, what should it be to accommodate hex values. Is there any way I can change data field in the command itself without changing .msg? thanks

edit retag flag offensive close merge delete


This man didn't get the answer in two years. Can someone escalate it, I faced the same issue now.

sagaryadav gravatar image sagaryadav  ( 2021-08-20 11:14:06 -0600 )edit

@sagaryadav there's a vote for this question on the left of it if you'd like to give it more emphasis.

tfoote gravatar image tfoote  ( 2021-08-20 12:54:20 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-08-20 12:53:33 -0600

tfoote gravatar image

You need to send the data encoded in the correct way. Yaml doesn't understand hexidecimal it's relying on decimal. You need to convert your values to the expected encoding. So 0x6a is just 106 then it will be encoded into the uint8 binary data field as expected. The other fields are not going in as hex values that you expect either. Your 40 will represent 0x28 in the data. Whereas I think you want to represent 0x40 so it should be 64.

edit flag offensive delete link more

Question Tools


Asked: 2019-09-23 16:37:06 -0600

Seen: 1,211 times

Last updated: Aug 20 '21