Hello,
I am new to both Arduino and ROS.
I have connected 3 IR detectors (E18-D50NK) to my Arduino Mega 2560.
I am using ROS-Indigo, standard installation on ubuntu
Here is the sketch I have uploaded:
#include
#include
std_msgs::Float32MultiArray obstacles_and_holes_msg;
ros::Publisher pub_obstacles_and_holes("obstacles_and_holes", &obstacles_and_holes_msg);
ros::NodeHandle nh;
// IR detectors
#define INFRA_NUM 3
#define INFRA_LATENCY 100
const int INFRA_Pins[INFRA_NUM] = {A0, A1, A2};
void setup()
{
nh.initNode(); // ROS node publisher initialization
obstacles_and_holes_msg.data_length = 3; // length of the message (8 IR detectors and 6 sonars)
nh.advertise(pub_obstacles_and_holes);
}
long publisher_timer;
void loop()
{
if (millis() > publisher_timer) {
for(int i = 0; i
↧