Deserialization Error rosserial
HI i'm trying to create a subscriber and a publisher on my Arduino IDE to subscribe to the following message:
# Steering Wheel
float32 steering_wheel_angle_cmd # rad, range -9.6 to 9.6
float32 steering_wheel_angle_velocity # rad/s, range 0 to 17.5, 0 = maximum
float32 steering_wheel_torque_cmd # Nm, range -8.0 to 8.0
uint8 cmd_type
How ever getting the following error when i run
rosrun rosserial_python serial_node.py /dev/ttyACM0
Error:
[INFO] [1581828495.528782]: ROS Serial Python Node
[INFO] [1581828495.542420]: Connecting to /dev/ttyACM0 at 57600 baud
[INFO] [1581828498.162551]: Note: publish buffer size is 280 bytes
[INFO] [1581828498.163540]: Setup publisher on my_topic [dbw_mkz_msgs/SteeringCmd]
[INFO] [1581828498.171809]: Note: subscribe buffer size is 280 bytes
[INFO] [1581828498.172683]: Setup subscriber on /vehicle/steering_cmd [dbw_mkz_msgs/SteeringCmd]
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/rosserial_python/serial_node.py", line 89, in <module>
client.run()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosserial_python/SerialClient.py", line 504, in run
self.callbacks[topic_id](msg)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosserial_python/SerialClient.py", line 107, in handlePacket
m.deserialize(data)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/dbw_mkz_msgs/msg/_SteeringCmd.py", line 133, in deserialize
raise genpy.DeserializationError(e) #most likely buffer underfill
genpy.message.DeserializationError: unpack requires a string argument of length 18
The following is my code on Arduino IDE
#include <ros.h>
#include <dbw_mkz_msgs/SteeringCmd.h>
#include <std_msgs/Float64.h>
#include <std_msgs/Float32.h>
ros::NodeHandle nh;
dbw_mkz_msgs::SteeringCmd msg;
void messageCb(const dbw_mkz_msgs::SteeringCmd& msg1){
msg.steering_wheel_angle_cmd= msg1.steering_wheel_angle_cmd;
digitalWrite(13, HIGH-digitalRead(13)); }
ros::Subscriber<dbw_mkz_msgs::SteeringCmd> sub("/vehicle/steering_cmd", &messageCb );
ros::Publisher p("my_topic", &msg);
void setup()
{
pinMode(13, OUTPUT);
nh.initNode();
nh.subscribe(sub);
nh.advertise(p);
}
void loop()
{
p.publish(&msg );
nh.spinOnce();
delay(1000);}