Running serial_node.py in rosserial gives error as "Creation of Publisher failed: unpack requires a string argument of length 4"

asked 2014-06-24 23:02:59 -0500

sumanth gravatar image

updated 2014-08-07 05:04:59 -0500

I am using ROS Hydro with rosserial library, Running the node serial_node.py as mentioned below: rosrun rosserial_python serial_node.py

Gives the error continuously as Creation of Publisher failed: unpack requires a string argument of length 4.

I am using an ARM (Atmel) 32-bit microcontroller to send the data on to the ROS over UART.

The code in the microcontroller goes in accordance with the protocol mentioned in the overview of the rosserial The code in the micro controller is as follows,

  u8_Ros_TxBuff[0] = Sync_Flag; //Sync Flag (Value: 0xff)
  u8_Ros_TxBuff[1] =  0xfe; //Protocol_Version_Sync; 
  u8_Ros_TxBuff[2] =  5  ; // message length - low byte
  u8_Ros_TxBuff[3] =  0    ;// message length - high byte
  u8_Ros_TxBuff[4] =  checksum_MessageLength(); // Checksum over message length
  u8_Ros_TxBuff[5] =  ID_PUBLISHER ; //Topic ID - Low Byte
  u8_Ros_TxBuff[6] =  0; //Topic ID - High Byte
  u8_Ros_TxBuff[7] =  1; //Serialized Message Data
  u8_Ros_TxBuff[8] =  7; // Serialized Message Data
  u8_Ros_TxBuff[9] =  9; // Serialized Message Data
  u8_Ros_TxBuff[10] = 2; // Serialized Message Data
  u8_Ros_TxBuff[11] = 7; // Serialized Message Data
  u8_Ros_TxBuff[12] =  checksum_MessageTopicID() ; // Checksum over Topic ID and Message Data

even the check sum's are calculated as per the protocol.

the 13 bytes are send over UART at 5700bps for every 10ms. I can see the data coming from the micro-controller correctly.

But when I run the node serial_node.py on ROS it gives the error: Creation of Publisher failed: unpack requires a string argument of length 4

I have checked the rosserial overview once again:

there is something called topic negotiation as follows,

Before data transfer can begin, the PC/Tablet side must query the Arduino or other embedded device for the names and types of topics which will be published or subscribed to.

Topic negotiation consists of a query for topics, a response with the number of topics, and packets to define each topic. The request for topics uses a topic ID of 0.

The query for topics will look like:

0xff 0xfd 0x00 0x00 0xff 0x00 0x00 0xff

A series of response packets (message type rosserial_msgs/TopicInfo, each containing information about a particular topic, with the following data in place of the serialized message:

uint16 topic_id string topic_name string message_type string md5sum int32 buffer_size

Here, the topic name is the name of the topic, for instance "cmd_vel", and message type is the type of the message, for instance "geometry_msgs/Twist".

If a response packet is not received correctly, another query may be sent.

New in 0.3.0 MD5 checksums are now transmitted to verify that both the sender and receiver are using the same message.

How can I achieve this Topic Negotiation on my micro controller using C-code.

Please help me out, if any one has an idea. thanks in advance.

edit retag flag offensive close merge delete

Comments

I'm having almost exactly the same problem (Using AT32UC3 family of microcontrollers). Did you find any solution/workaround to your problem?

sapient84 gravatar image sapient84  ( 2016-01-01 20:22:25 -0500 )edit