26 #include <sensor_msgs/LaserScan.h> 27 #include <diagnostic_msgs/DiagnosticArray.h> 32 #define DEG2RAD M_PI/180.0 85 nh.
param<std::string>(
"host",
host,
"192.168.1.2");
86 if(!nh.
hasParam(
"frame_id"))
ROS_WARN(
"Used default parameter for frame_id");
87 nh.
param<std::string>(
"frame_id",
frame_id,
"base_laser_link");
88 if(!nh.
hasParam(
"inverted"))
ROS_WARN(
"Used default parameter for inverted");
90 if(!nh.
hasParam(
"angle_resolution"))
ROS_WARN(
"Used default parameter for resolution");
92 if(!nh.
hasParam(
"scan_frequency"))
ROS_WARN(
"Used default parameter for frequency");
94 if(!nh.
hasParam(
"set_config"))
ROS_WARN(
"Used default parameter for set_config");
96 if(!nh.
hasParam(
"min_range"))
ROS_WARN(
"Used default parameter for min_range");
98 if(!nh.
hasParam(
"max_range"))
ROS_WARN(
"Used default parameter for max_range");
101 ROS_INFO(
"connecting to laser at : %s", host.c_str());
102 ROS_INFO(
"using frame_id : %s", frame_id.c_str());
103 ROS_INFO(
"inverted : %s", (inverted)?
"true":
"false");
104 ROS_INFO(
"using res : %f", resolution);
105 ROS_INFO(
"using freq : %f", frequency);
150 ROS_ERROR(
"Setting angle resolution failed: Current angle resolution is %f.",
cfg.angleResolution/10000.0);
152 ROS_ERROR(
"Setting scan frequency failed: Current scan frequency is %f.",
cfg.scaningFrequency/100.0);
155 ROS_ERROR(
"Connection to device failed");
178 if (
cfg.angleResolution == 2500)
182 else if (
cfg.angleResolution == 5000)
196 scan_msg.intensities.resize(num_values);
246 for (
int i = 0; i <
data.dist_len1; i++)
259 diagnostic_msgs::DiagnosticArray diagnostics;
260 diagnostics.status.resize(1);
261 diagnostics.status[0].level = 0;
263 diagnostics.status[0].message =
"sick scanner running";
280 diagnostic_msgs::DiagnosticArray diagnostics;
281 diagnostics.status.resize(1);
282 diagnostics.status[0].level = 2;
284 diagnostics.status[0].message = error_str;
291 int main(
int argc,
char** argv)
293 ros::init(argc, argv,
"sick_lms1xx_node");
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.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
void login()
Log into LMS1xx unit. Increase privilege level, giving ability to change device configuration.
void stopMeas()
Stop measurements. After receiving this command LMS1xx unit stop spinning laser and measuring...
Structure containing single scan message.
Structure containing scan configuration.
void setScanCfg(const scanCfg &cfg)
Set scan configuration. Get scan configuration :
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...
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
const std::string & getNamespace() const
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.
void publishError(std::string error_str)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
sensor_msgs::LaserScan scan_msg
void saveConfig()
Save data permanently. Parameters are saved in the EEPROM of the LMS and will also be available after...
bool getData(scanData &data)
Receive single scan message.
Structure containing scan data configuration.
Class responsible for communicating with LMS1xx device.
bool hasParam(const std::string &key) const
ROSCPP_DECL void spinOnce()
ros::Publisher diagnostic_pub