hi am trying create a map using lidat lite v3 through arduino,but it is not producing any map,my program is written below, can you guys please help me ? am new to ROS [closed]
enter code here
#include <ros.h>
#include <Wire.h>
#define LIDARLite_ADDRESS 0x62
#define RegisterMeasure 0x00
#define MeasureValue 0x04
#define RegisterHighLowB 0x8f
#define USB_USBCON
#include <LIDARLite.h>
#include <I2C.h>
#include <sensor_msgs/Range.h>
#include <sensor_msgs/LaserScan.h>
LIDARLite myLidarLite;
ros::NodeHandle nh;
sensor_msgs::LaserScan scan;
ros::Publisher pub_range( "lidar", &scan);
float ranges[7];
char frameid[] = "/my_frame";
int lidarGetRange(void)
{
int val = -1;
Wire.beginTransmission((int)LIDARLite_ADDRESS);
Wire.write((int)RegisterMeasure);
Wire.write((int)MeasureValue);
Wire.endTransmission();
delay(20);
Wire.beginTransmission((int)LIDARLite_ADDRESS);
Wire.write((int)RegisterHighLowB);
Wire.endTransmission();
delay(20);
Wire.requestFrom((int)LIDARLite_ADDRESS, 2);
if(2 <= Wire.available())
{
val = Wire.read();
val = val << 8;
val |= Wire.read();
}
return val;
}
void setup()
{
Serial.begin(57600);
nh.initNode();
nh.advertise(pub_range);
//delay(1000);
myLidarLite.begin(0, true);
myLidarLite.configure(0);
scan.header.frame_id = frameid;
scan.angle_min= 0;
scan.angle_max= 3.14;
scan.angle_increment =1;
scan.range_min = 0.03;
scan.range_max = 4000;
}
void loop()
{
for(int i = 0; i < 7; i++)
{
Serial.println(lidarGetRange());
scan.ranges[i] =lidarGetRange();
pub_range.publish(&scan);
}
nh.spinOnce();
}`enter code here`
Please format your question properly: a short and to the point title, the main question in the body, and any code or console text formatted using the Preformatted Text button (the one with
101010
on it). As it is, your question is rather hard to read.sorry about that,i formatted my question
Lets break this down so you can get the help you need. Does just the arduino and the lidar lite without any of the ROS stuff work? Do you have any other information on where it is not working? You should add these edits to your question.
i donot have any idea why it is not working ,am planning to use hector mapping for the mapping
i think it is a problem related to arrays