28 #include "sensor_msgs/LaserScan.h" 32 #define DEG2RAD M_PI/180.0 34 int main(
int argc,
char **argv)
41 sensor_msgs::LaserScan scan_msg;
54 n.
param<std::string>(
"host", host,
"192.168.1.2");
55 n.
param<std::string>(
"frame_id", frame_id,
"laser");
56 n.
param<
bool>(
"publish_min_range_as_inf", inf_range,
false);
57 n.
param<
int>(
"port", port, 2111);
65 ROS_WARN(
"Unable to connect, retrying.");
78 ROS_WARN(
"Unable to get laser output range. Retrying.");
85 ROS_DEBUG(
"Laser configuration: scaningFrequency %d, angleResolution %d, startAngle %d, stopAngle %d",
87 ROS_DEBUG(
"Laser output range:angleResolution %d, startAngle %d, stopAngle %d",
90 scan_msg.header.frame_id = frame_id;
91 scan_msg.range_min = 0.01;
92 scan_msg.range_max = 20.0;
95 scan_msg.angle_min =
static_cast<double>(outputRange.
startAngle / 10000.0 *
DEG2RAD - M_PI / 2);
96 scan_msg.angle_max =
static_cast<double>(outputRange.
stopAngle / 10000.0 *
DEG2RAD - M_PI / 2);
108 scan_msg.ranges.resize(num_values);
109 scan_msg.intensities.resize(num_values);
111 scan_msg.time_increment =
116 ROS_DEBUG_STREAM(
"Time increment is " << static_cast<int>(scan_msg.time_increment * 1000000) <<
" microseconds");
126 ROS_DEBUG(
"Setting scan data configuration.");
141 ROS_WARN(
"Laser not ready. Retrying initialization.");
169 ROS_DEBUG(
"Commanding continuous measurements.");
176 scan_msg.header.stamp = start;
177 ++scan_msg.header.seq;
185 float range_data = data.
dist1[i] * 0.001;
187 if (inf_range && range_data < scan_msg.range_min)
189 scan_msg.ranges[i] = std::numeric_limits<float>::infinity();
193 scan_msg.ranges[i] = range_data;
199 scan_msg.intensities[i] = data.
rssi1[i];
207 ROS_ERROR(
"Laser timed out on delivering scan, attempting to reinitialize.");
int startAngle
Start angle. 1/10000 degree.
Structure containing single scan message.
void setScanDataCfg(const scanDataCfg &cfg)
Set scan data configuration. Set format of scan message returned by device.
void publish(const boost::shared_ptr< M > &message) const
scanCfg getScanCfg() const
Get current scan configuration. Get scan configuration :
status_t queryStatus()
Get current status of LMS1xx device.
scanOutputRange getScanOutputRange() const
Get current output range configuration. Get output range configuration :
uint16_t dist1[1082]
Radial distance for the first reflected pulse.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void login()
Log into LMS1xx unit. Increase privilege level, giving ability to change device configuration.
int resolution
Remission resolution. Defines whether the remission values are output with 8-bit or 16bit resolution...
bool remission
Remission. Defines whether remission values are output.
int outputInterval
Output interval. Defines which scan is output.
Structure containing scan data configuration.
int angleResolution
Scanning resolution. 1/10000 degree.
int stopAngle
Stop angle. 1/10000 degree.
int encoder
Encoders channels. Defines which output channel is activated.
void stopMeas()
Stop measurements. After receiving this command LMS1xx unit stop spinning laser and measuring...
int scaningFrequency
Scanning frequency. 1/100 Hz.
Structure containing scan configuration.
bool getScanData(scanData *scan_data)
Receive single scan message.
void startDevice()
The device is returned to the measurement mode after configuration.
void scanContinous(int start)
Start or stop continuous data acquisition. After reception of this command device start or stop conti...
int outputChannel
Output channels. Defines which output channel is activated.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
int angleResolution
Scanning resolution. 1/10000 degree.
int dist_len1
Number of samples in dist1.
void startMeas()
Start measurements. After receiving this command LMS1xx unit starts spinning laser and measuring...
bool isConnected()
Get status of connection.
void disconnect()
Disconnect from LMS1xx device.
void connect(std::string host, int port=2111)
Connect to LMS1xx.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define ROS_DEBUG_STREAM(args)
int stopAngle
Stop angle. 1/10000 degree.
int startAngle
Start angle. 1/10000 degree.
Structure containing scan output range configuration.
int main(int argc, char **argv)
#define ROS_INFO_STREAM(args)
Class responsible for communicating with LMS1xx device.
bool position
Position. Defines whether position values are output.
ROSCPP_DECL void spinOnce()
uint16_t rssi1[1082]
Remission values for the first reflected pulse.
int rssi_len1
Number of samples in rssi1.
bool deviceName
Device name. Determines whether the device name is to be output.