rosserial arduino faulty data [closed]
I'm running the following code un my Arduino Uno:
#include <ros.h>
#include <geometry_msgs/Twist.h>
ros::NodeHandle nh;
void messageCb( const geometry_msgs::Twist& velo_msg){
nh.loginfo(String(velo_msg.linear.x).c_str());
}
ros::Subscriber<geometry_msgs::Twist> sub("cmd_vel", &messageCb );
void setup() {
nh.initNode();
nh.subscribe(sub);
}
void loop() {
nh.spinOnce();
}
If I publish the following message:
linear:
x: 0.5
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
---
The output is correct:
[INFO] [WallTime: 1476202779.883673] 0.50
However if I publish this message:
linear:
x: -0.5
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0
---
The program seems to get faulty data from rosserial:
[INFO] [WallTime: 1476202781.667369] -0.00
Any idea what could be the issue? Am I making a type conversion mistake?
Asked by DKS on 2016-10-11 11:37:38 UTC
Comments