Failed Packet Flags
Ok... More issues are occurring... Now, the code is publishing [I use the spinOnce() to correct the sync error], but the terminal gives me a new error:
allenh1@muri-pc7:~$ rosrun rosserial_python serial_node.py /dev/ttyACM0
[INFO] [WallTime: 1332971976.596828] ROS Serial Python Node
[INFO] [WallTime: 1332971976.601747] Connected on /dev/ttyACM0 at 57600 baud
[INFO] [WallTime: 1332971978.757289] Note: publish buffer size is 512 bytes
[INFO] [WallTime: 1332971978.757710] Setup publisher on imu [sensor_msgs/Imu]
[INFO] [WallTime: 1332971995.901270] Failed Packet Flags
[INFO] [WallTime: 1332971998.228596] Failed Packet Flags
[INFO] [WallTime: 1332971999.715138] Failed Packet Flags
[INFO] [WallTime: 1332972000.021163] Failed Packet Flags
[INFO] [WallTime: 1332972001.216033] Failed Packet Flags
[INFO] [WallTime: 1332972001.883928] Failed Packet Flags
[INFO] [WallTime: 1332972002.676350] Failed Packet Flags
[INFO] [WallTime: 1332972003.079734] Failed Packet Flags
[INFO] [WallTime: 1332972003.143579] Failed Packet Flags
[INFO] [WallTime: 1332972003.897713] Packet Failed : Failed to read msg data
[INFO] [WallTime: 1332972005.732057] Failed Packet Flags
[INFO] [WallTime: 1332972006.467836] Failed Packet Flags
[INFO] [WallTime: 1332972006.535782] Failed Packet Flags
[INFO] [WallTime: 1332972007.064265] Failed Packet Flags
[INFO] [WallTime: 1332972007.592927] Failed Packet Flags
[INFO] [WallTime: 1332972007.859641] Failed Packet Flags
[INFO] [WallTime: 1332972011.647770] Failed Packet Flags
[INFO] [WallTime: 1332972012.508285] Failed Packet Flags
[INFO] [WallTime: 1332972013.304900] Failed Packet Flags
What could be the cause of this error? Is this a code issue? Here's my arduino code:
#include <ros.h>
#include <std_msgs/String.h>
#include <std_msgs/Float64.h>
#include <sensor_msgs/Imu.h>
ros::NodeHandle nh;
sensor_msgs::Imu data;
ros::Publisher p("imu", &data);
char frame[] = "/imu";
int xPin = A0;
int yPin = A1; // select the input pin for the potentiometer// select the pin for the LED
double xValue = 0;
int xValueRaw = 0;
double yValue = 0;
int yValueRaw = 0; // variable to store the value coming from the sensor
void setup()
{
nh.initNode();
nh.advertise(p);
nh.spinOnce();
}
void loop() {
// read the value from the sensor:
xValueRaw = analogRead(xPin);
xValue = (((xValueRaw * 0.0049) - 1.66) / (0.312)) * 9.80665; //convert to volts
yValueRaw = analogRead(yPin);
yValue = (((yValueRaw * 0.0049) - 1.66) / (0.312)) * 9.80665;
nh.spinOnce();
//now, we publish the m/s^2 acceleration to ROS.
data.header.frame_id = frame;
data.orientation_covariance[0] = -1; //tells ROS to ignore the orientaiton of the data (not provided)
data.angular_velocity_covariance[0] = -1; //tells ROS to ignore the angular velocity of the data (not provided)
data.linear_acceleration.x = xValue;
data.linear_acceleration.y = yValue;
data.linear_acceleration.z = 0;
data.header.stamp = nh.now();
p.publish(&data);
nh.spinOnce();
delay(10);
}