43 #include <geometry_msgs/Point.h> 44 #include <sensor_msgs/LaserScan.h> 46 #include <asr_sick_lms_400/sick_lms400.h> 92 nh_.
param (
"hostname", hostname_,
string (
"192.168.0.1"));
95 nh_.
param (
"password", password_,
string (
"81BE23AA"));
96 nh_.
param (
"port", port_, 2111);
110 nh_.
param (
"filter", filter_, 11);
114 nh_.
param (
"enable_eRIS", eRIS_, 1);
117 nh_.
param (
"mean_filter_parameter", mean_filter_params_, 3);
120 nh_.
param (
"range_filter_parameter_min", range_filter_params_min_, 700.0);
121 nh_.
param (
"range_filter_parameter_max", range_filter_params_max_, 3000.0);
125 nh_.
param (
"angular_resolution", angular_resolution_, 0.1);
128 nh_.
param (
"scanning_frequency", scanning_frequency_, 360.0);
130 nh_.
param (
"enable_laser", laser_enabled_,
true);
131 nh_.
param (
"enable_intensity", intensity_,
true);
134 nh_.
param (
"min_angle", min_angle_, 55.0);
135 nh_.
param (
"max_angle", max_angle_, 125.0);
138 scan_pub_ = nh_.
advertise<LaserScan>(
"laser_scan", 1);
160 ROS_ERROR (
"> [SickLMS400] Connecting to SICK LMS400 on [%s:%d]...[failed!]", hostname_.c_str (), port_);
163 ROS_INFO (
"> [SickLMS400] Connecting to SICK LMS400 on [%s:%d]... [done]", hostname_.c_str (), port_);
168 if (strncmp (password_.c_str (),
"NULL", 4) != 0)
172 ROS_WARN (
"> [SickLMS400] Unable to change userlevel to 'Service' using %s", password_.c_str ());
177 if ((mean_filter_params_ >= 2) && (mean_filter_params_ <= 200))
180 if ((range_filter_params_min_ >= 700.0) && (range_filter_params_max_> range_filter_params_min_) && (range_filter_params_max_ <= 3600.0))
185 ROS_INFO (
"> [SickLMS400] Enabling selected filters (%d, %f, %f, %d)... [done]", mean_filter_params_, (
float)range_filter_params_min_, (
float)range_filter_params_max_, filter_);
189 ROS_WARN (
"> [SickLMS400] Userlevel 3 password not given. Filter(s) disabled!");
195 ROS_INFO (
"> [SickLMS400] Enabling extended RIS detectivity... [done]");
199 ROS_ERROR (
"> [SickLMS400] Couldn't set values for resolution, frequency, and min/max angle. Using previously set values.");
201 ROS_INFO (
"> [SickLMS400] Enabling user values for resolution (%f), frequency (%f) and min/max angle (%f/%f)... [done]",
202 angular_resolution_, scanning_frequency_, min_angle_, max_angle_);
219 ROS_INFO (
"> [SickLMS400] SICK LMS400 driver shutting down... [done]");
227 float min_angle,
float diff_angle,
int intensity,
236 ROS_WARN (
"> Unable to change userlevel to 'Service' using %s", password_.c_str ());
257 nh_.
getParam (
"enable_laser", laser_enabled);
259 if (laser_enabled != laser_enabled_)
261 ROS_INFO (
"New enable_laser parameter received (%d)", laser_enabled);
262 laser_enabled_ = laser_enabled;
271 nh_.
getParam (
"enable_intensity", intensity);
273 if (intensity != intensity_)
275 ROS_INFO (
"New enable_intensity parameter received (%d)", intensity);
276 intensity_ = intensity;
279 double angular_resolution;
280 nh_.
getParam (
"angular_resolution", angular_resolution);
282 if (angular_resolution != angular_resolution_)
284 ROS_INFO (
"New angular_resolution parameter received (%f)", angular_resolution);
285 angular_resolution_ = angular_resolution;
286 restartMeasurementWithNewValues (scanning_frequency_, angular_resolution_, min_angle_, max_angle_ - min_angle_, intensity_, laser_enabled_);
290 nh_.
getParam (
"min_angle", min_angle);
292 if (min_angle != min_angle_)
294 ROS_INFO (
"New min_angle parameter received (%f)", min_angle);
295 min_angle_ = min_angle;
296 restartMeasurementWithNewValues (scanning_frequency_, angular_resolution_, min_angle_, max_angle_ - min_angle_, intensity_, laser_enabled_);
300 nh_.
getParam (
"max_angle", max_angle);
302 if (max_angle != max_angle_)
304 ROS_INFO (
"New max_angle parameter received (%f)", max_angle);
305 max_angle_ = max_angle;
306 restartMeasurementWithNewValues (scanning_frequency_, angular_resolution_, min_angle_, max_angle_ - min_angle_, intensity_, laser_enabled_);
309 double scanning_frequency;
310 nh_.
getParam (
"scanning_frequency", scanning_frequency);
312 if (scanning_frequency != scanning_frequency_)
314 ROS_INFO (
"New scanning_frequency parameter received (%f)", scanning_frequency);
315 scanning_frequency_ = scanning_frequency;
316 restartMeasurementWithNewValues (scanning_frequency_, angular_resolution_, min_angle_, max_angle_ - min_angle_, intensity_, laser_enabled_);
338 if (scan_.ranges.size () != 0)
void publish(const boost::shared_ptr< M > &message) const
int TerminateConfiguration()
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int SetResolutionAndFrequency(float freq, float ang_res, float angle_start, float angle_range)
int SetMeanFilterParameters(int num_scans)
void getParametersFromServer()
sensor_msgs::LaserScan ReadMeasurement()
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
double range_filter_params_min_
bool getParam(const std::string &key, std::string &s) const
void restartMeasurementWithNewValues(float scanning_frequency, float angular_resolution, float min_angle, float diff_angle, int intensity, bool laser_enabled)
int StartMeasurement(bool intensity=true)
LMS400Node(ros::NodeHandle &n)
int EnableFilters(int filter_mask)
ROSCPP_DECL void spinOnce()
int main(int argc, char **argv)
int SetRangeFilterParameters(float range_min, float range_max)
int SetUserLevel(int8_t userlevel, const char *password)
double scanning_frequency_