Robotics StackExchange | Archived questions

Socketcan_bridge : Error when publishing on sent_messages topic

Hi I am running socketcanbridge package and trying to publish a canmsgs/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

Asked by prj1508 on 2019-09-23 16:37:06 UTC

Comments

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

Asked by sagaryadav on 2021-08-20 11:14:06 UTC

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

Asked by tfoote on 2021-08-20 12:54:20 UTC

Answers

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.

Asked by tfoote on 2021-08-20 12:53:33 UTC

Comments