Rosserial arduino, unpack requires a string arguement of length 4
EDIT: The exact cause of the issue is coming from my message having some odd bits of data in it.
str is
}chatterstd_msgs/String 992ce8a1687cec8c8bd883ec73ca41d1
str is
d
toggle_ledtdstd_msgs/String 92992ce8a1687cec8c8bd883ec73ca41d1
The first string is used to create the publisher and the second is used to create the subscriber, the second has some extra characters (which is throwing the length error and I can't figure out why.
---Original Question---
Okay so I'm following the rosserial arduino tutorials, having just installed hydro. I'm using ubuntu 12.04 and currently attempting to run roslib pubsub, the source code is below. However I am receiving this error:
[INFO] [WallTime: 1379669386.460493] ROS Serial Python Node
[INFO] [WallTime: 1379669386.472761] Connecting to /dev/ttyACM2 at 57600 baud
[INFO] [WallTime: 1379669389.183587] Note: publish buffer size is 280 bytes
[INFO] [WallTime: 1379669389.183904] Setup publisher on chatter [std_msgs/String]
[ERROR] [WallTime: 1379669389.185947] Creation of subscriber failed: unpack requires a string argument of length 4
So yeah, I've seen multiple other quesitons with the same error however no solution appears to be working for me.
I have ran
catkin_make
catkin_make install
source ws/install/setup.bash
this is after having cloned the repo with git. Any help would be appreciated thanks.
The source code is:
/*
* rosserial PubSub Example
* Prints "hello world!" and toggles led
*/
#include <ros.h>
#include <std_msgs/String.h>
#include <std_msgs/Empty.h>
ros::NodeHandle nh;
void messageCb( const std_msgs::Empty& toggle_msg){
digitalWrite(13, HIGH-digitalRead(13)); // blink the led
}
ros::Subscriber<std_msgs::Empty> sub("toggle_led", messageCb );
std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);
char hello[13] = "hello world!";
void setup()
{
pinMode(13, OUTPUT);
nh.initNode();
nh.advertise(chatter);
nh.subscribe(sub);
}
void loop()
{
str_msg.data = hello;
chatter.publish( &str_msg );
nh.spinOnce();
delay(500);
}
I first compile and run on the arduino then i use
roscore
rosrun rosserial_python serial_node.py /dev/ttyACM0
Which then throws the above error.