Hi i trying to send array data from arduino to my node but i have problems with it. I'm reading data from accelerometer and want to send xyz values in array message. Code compile properly but when i tryng to start serial connection with arduino it stucks even if i trying to send only one value. What is wrong here?
/*
* rosserial Publisher Example
* Prints "hello world!"
*/
#include "I2Cdev.h"
#include "MPU6050.h"
#include <Wire.h>
#include <ros.h>
//#include <std_msgs/Int16.h>
#include <std_msgs/Int16MultiArray.h>
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
ros::NodeHandle nh;
//std_msgs::Int16 x;
std_msgs::Int16MultiArray xar;
//ros::Publisher inty("inty", &x);
ros::Publisher intyarr("intyarr", &xar);
void setup()
{
nh.initNode();
nh.advertise(intyarr);
Wire.begin();
accelgyro.initialize();
}
void loop()
{
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
//x.data = ay;
//inty.publish(&x);
xar.data[1]=ax;
intyarr.publish(&xar);
nh.spinOnce();
delay(1000);
}
Also i want to resend data from my node to arduino to send it into robot but i dont know how to do it.
void messageCb( const std_msgs::Int16& msg){
//digitalWrite(13, HIGH-digitalRead(13)); // blink the led
msg->data;
}
Code like this doesn't work in Arduino IDE.
Originally posted by starcu on ROS Answers with karma: 1 on 2016-01-06
Post score: 0