0
$\begingroup$

Rosanswers logo

I am using ROS Kinetic on Ubuntu 16.04. I've been trying to get a custom message type to work over rosserial_arduino for some time now. I have properly generated the C++ message headers in the package. For reference, here is the custom message type I am planning on using:

# MotorEncoder.msg
int32 leftValue
int32 rightValue
time leftTime
time rightTime

After running catkin_make on the project workspace, I run the source devel/setup.bash command to let ROS know I have messages that need to have generated Arduino-based headers. Then I run the command

rosrun rosserial_client make_libraries ~/Arduino/libraries

This generates the Arduino-based headers which I am able to properly compile and run using this Arduino script:

#include <ros.h>
#include <rover_core/MotorEncoder.h>

ros::NodeHandle nh;
rover_core::MotorEncoder msg;
ros::Publisher pub("/test", &msg);

void setup() {
  // put your setup code here, to run once:
  nh.initNode();
  nh.advertise(pub);
}

void loop() {
  // put your main code here, to run repeatedly:
  nh.spinOnce();
}

I ran the rosserial node after deploying it to the arduino:

 rosrun rosserial_python serial_node.py /dev/ttyUSB0

And I get the output:

[INFO] [1531232541.250369]: ROS Serial Python Node
[INFO] [1531232541.262715]: Connecting to /dev/ttyUSB0 at 57600 baud
[ERROR] [1531232543.413050]: Creation of publisher failed: too many values to unpack

I've tried a bunch of different solutions, but nothing seems to be fixing the problem. I've tried differently structured message types as well. Is something wrong with the process I'm using to generate these? Any help would be greatly appreciated. I'd be more than happy to provide an additional information as well.


Originally posted by nprof50 on ROS Answers with karma: 26 on 2018-07-10

Post score: 0


Original comments

Comment by josephcoombe on 2018-07-10:
Did you do this step "To add new messages to the library you have to delete (if already created) the whole ros_lib folder in your arduino libraries subpath and..." from http://wiki.ros.org/rosserial/Tutorials/Adding%20Other%20Messages. Just double checking!

Comment by nprof50 on 2018-07-10:
Yes, but my libraries folder is not ~/sketchbook/libraries. It's ~/Arduino/libraries. Furthermore the IDE complains about the ros_lib folder, saying it's not a valid library. I can internally download a library, but the folder is not named ros_lib. So I just move my headers over. Compiles fine

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

For anyone else experiencing this issue, I fixed it by adding a delay (of about 50-250) in the main loop after "nh.spinOnce()". Without the delay, it seems the serial buffer is overwritten or messed up before ROS can interpret the values properly.


Originally posted by nprof50 with karma: 26 on 2018-07-24

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.