23 #include "sensor_msgs/LaserScan.h" 29 #define DEG_CIRCLE 360 30 #define DEG_TO_RAD (M_PI / (DEG_CIRCLE / 2)) 32 int main(
int argc,
char** argv)
42 n.
param(
"baudrate", baudrate, 500000);
46 int init_attempts = 1;
47 n.
param(
"init_attempts", init_attempts, 1);
55 while(init_counter < init_attempts){
60 ROS_WARN(
"Init failed. Failed inits: %d, Start new.", init_counter+1);
71 double minrange = std::numeric_limits<double>::max(), maxrange = 0;
73 unsigned int num_measurement_values = 360;
77 unsigned int scan_data[num_measurement_values];
78 unsigned int *scan_data_pointer = scan_data;
79 scanner -> GetSickScan(scan_data_pointer,num_measurement_values);
80 sensor_msgs::LaserScan scan;
81 scan.header.seq = count;
83 scan.header.frame_id =
"base_laser";
87 for(
unsigned int i=0; i<num_measurement_values; i++)
89 if(scan_data[i]>maxrange)
90 maxrange = scan_data[i];
91 if(scan_data[i]<minrange)
92 minrange = scan_data[i];
93 scan.ranges.push_back((
double)(scan_data[i])/100.0);
96 scan.range_min = minrange/100;
97 scan.range_max = maxrange/100;
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
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)
int main(int argc, char **argv)
bool getParam(const std::string &key, std::string &s) const
Definition of class SickPLS. Code by Jason C. Derenick and Thomas H. Miller. Contact derenick(at)lehi...
ROSCPP_DECL void spinOnce()