27 #include <sensor_msgs/Imu.h> 28 #include <sensor_msgs/PointCloud2.h> 30 #include "ouster_driver/PacketMsg.h" 33 using ns = std::chrono::nanoseconds;
36 int main(
int argc,
char** argv) {
40 auto scan_dur =
ns(nh.
param(
"scan_dur_ns", 100000000));
41 auto os1_hostname = nh.
param(
"os1_lidar_address", std::string(
"localhost"));
42 auto os1_udp_dest = nh.
param(
"pc_address", std::string(
"192.168.1.1"));
43 auto os1_lidar_port = nh.
param(
"os1_lidar_port", -1);
44 auto os1_imu_port = nh.
param(
"os1_imu_port", -1);
45 auto replay_mode = nh.
param(
"replay",
true);
46 auto points_topic_name = nh.
param(
"points_topic_name", std::string(
"/points_raw"));
47 auto imu_topic_name = nh.
param(
"imu_topic_name", std::string(
"/imu_raw"));
48 auto lidar_frame_name = nh.
param(
"lidar_frame_name", std::string(
"/os1"));
49 auto imu_frame_name = nh.
param(
"imu_frame_name", std::string(
"/os1_imu"));
50 auto pointcloud_mode = nh.
param(
"pointcloud_mode", std::string(
"NATIVE"));
51 auto operation_mode_str = nh.
param(
"operation_mode", std::string(
"1024x10"));
52 auto pulse_mode_str = nh.
param(
"pulse_mode", std::string(
"STANDARD"));
53 auto window_rejection = nh.
param(
"window_rejection",
true);
67 if (operation_mode_str == std::string(
"512x20") || operation_mode_str == std::string(
"1024x20")) {
69 scan_dur = scan_dur / 2;
73 auto lidar_pub = nh.
advertise<sensor_msgs::PointCloud2>(points_topic_name, queue_size);
74 auto imu_pub = nh.
advertise<sensor_msgs::Imu>(imu_topic_name, queue_size);
82 auto imu_handler = [&](
const PacketMsg& p) {
88 "lidar_packets", 500, lidar_handler);
90 "imu_packets", 500, imu_handler);
97 os1_lidar_port, os1_imu_port);
99 ROS_ERROR(
"Failed to initialize sensor at: %s", os1_hostname.c_str());
105 lidar_packet_pub.publish(pm);
109 imu_packet_pub.publish(pm);
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::shared_ptr< client > init_client(const std::string &hostname, const std::string &udp_dest_host, int lidar_port, int imu_port)
pcl::PointCloud< PointOS1 > CloudOS1
ROSCPP_DECL void spin(Spinner &spinner)
void set_point_mode(std::string mode_xyzir)
ouster_driver::PacketMsg PacketMsg
void set_advanced_params(std::string operation_mode_str, std::string pulse_mode_str, bool window_rejection)
int main(int argc, char **argv)
void spin(const ouster::OS1::client &cli, const std::function< void(const PacketMsg &pm)> &lidar_handler, const std::function< void(const PacketMsg &pm)> &imu_handler)
std::function< void(const PacketMsg &)> batch_packets(ns scan_dur, const std::function< void(ns, const CloudOS1 &)> &f)
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)
sensor_msgs::Imu packet_to_imu_msg(const PacketMsg &pm, const std::string &frame="os1_imu")
std::chrono::nanoseconds ns
sensor_msgs::PointCloud2 cloud_to_cloud_msg(const CloudOS1 &cloud, ns timestamp, const std::string &frame="os1")