52 #include <rslidar_msgs/rslidarScan.h> 59 private_nh.
param(
"frame_id",
config_.frame_id, std::string(
"rslidar"));
66 private_nh.
param(
"model",
config_.model, std::string(
"RS16"));
68 std::string model_full_name;
74 model_full_name =
"RS-LiDAR-16";
76 else if (
config_.model ==
"RS32")
79 model_full_name =
"RS-LiDAR-32";
86 std::string deviceName(std::string(
"Robosense ") + model_full_name);
89 double frequency = (
config_.rpm / 60.0);
94 int npackets = (int)ceil(packet_rate / frequency);
95 private_nh.
param(
"npackets",
config_.npackets, npackets);
98 std::string dump_file;
99 private_nh.
param(
"pcap", dump_file, std::string(
""));
107 private_nh.
param(
"cut_angle", cut_angle, -0.01);
112 else if (cut_angle < 360)
115 "Cutting rslidar points always at " 116 << cut_angle <<
" degree.");
121 <<
"between 0.0 and 360 negative values to deactivate this feature.");
127 config_.cut_angle =
static_cast<int>(cut_angle * 100);
130 srv_ = boost::make_shared<dynamic_reconfigure::Server<rslidar_driver::rslidarNodeConfig> >(private_nh);
131 dynamic_reconfigure::Server<rslidar_driver::rslidarNodeConfig>::CallbackType
f;
133 srv_->setCallback(f);
137 const double diag_freq = packet_rate /
config_.npackets;
174 rslidar_msgs::rslidarScanPtr scan(
new rslidar_msgs::rslidarScan);
180 scan->packets.reserve(
config_.npackets);
181 rslidar_msgs::rslidarPacket tmp_packet;
192 scan->packets.push_back(tmp_packet);
194 static int ANGLE_HEAD = -36001;
195 static int last_azimuth = ANGLE_HEAD;
197 int azimuth = 256 * tmp_packet.data[44] + tmp_packet.data[45];
201 if (azimuth < last_azimuth)
203 last_azimuth -= 36000;
206 if (last_azimuth != ANGLE_HEAD && last_azimuth < config_.cut_angle && azimuth >=
config_.cut_angle)
208 last_azimuth = azimuth;
211 last_azimuth = azimuth;
216 scan->packets.resize(
config_.npackets);
217 for (
int i = 0; i <
config_.npackets; ++i)
232 ROS_DEBUG(
"Publishing a full rslidar scan.");
233 scan->header.stamp = scan->packets.back().stamp;
234 scan->header.frame_id =
config_.frame_id;
247 rslidar_msgs::rslidarPacketPtr difop_packet_ptr(
new rslidar_msgs::rslidarPacket);
251 rslidar_msgs::rslidarPacket difop_packet_msg;
257 *difop_packet_ptr = difop_packet_msg;
269 config_.time_offset = config.time_offset;
diagnostic_updater::Updater diagnostics_
ros::Publisher difop_output_
void publish(const boost::shared_ptr< M > &message) const
std::string getPrefixParam(ros::NodeHandle &nh)
rslidarDriver(ros::NodeHandle node, ros::NodeHandle private_nh)
rslidarDriver
void setHardwareID(const std::string &hwid)
ros::Publisher msop_output_
static uint16_t MSOP_DATA_PORT_NUMBER
boost::shared_ptr< Input > msop_input_
int npackets
number of packets to collect
std::string resolve(const std::string &prefix, const std::string &frame_name)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
struct rslidar_driver::rslidarDriver::@0 config_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
boost::shared_ptr< diagnostic_updater::TopicDiagnostic > diag_topic_
void callback(rslidar_driver::rslidarNodeConfig &config, uint32_t level)
Callback for dynamic reconfigure.
#define ROS_DEBUG_STREAM(args)
boost::shared_ptr< Input > difop_input_
#define ROS_INFO_STREAM(args)
#define ROS_ERROR_STREAM(args)
static uint16_t DIFOP_DATA_PORT_NUMBER
ROSCPP_DECL void spinOnce()
boost::shared_ptr< boost::thread > difop_thread_
boost::shared_ptr< dynamic_reconfigure::Server< rslidar_driver::rslidarNodeConfig > > srv_
Pointer to dynamic reconfigure service srv_.