Skip to content

Commit

Permalink
ROS-227: Set LIDAR FOV on startup and add an option to persist the co…
Browse files Browse the repository at this point in the history
…nfig [NOETIC] (#356)

* Set LIDAR FOV on startup
* Add persist flags option to launch files.
* Add a breaking note about azimuth window config reset
  • Loading branch information
Samahu authored Aug 20, 2024
1 parent 993e471 commit 8b81347
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Changelog
* [BREAKING] Set xyz values of individual points in the PointCloud to NaNs when range is zero.
* Added support to replay pcap format direclty from ouster-ros. The feature needs to be enabled
explicitly by turning on the ``BUILD_PCAP`` cmake option and having ``libpcap-dev`` installed.
* [BREAKING] Added new launch files args ``azimuth_window_start`` and ``azimuth_window_end`` to
allow users to set LIDAR FOV on startup. The new options will reset the current azimuth window
to the default
* Added a new launch ``persist_config`` option to request the sensor persist the current config
* Added a new ``loop`` option to the ``replay.launch`` file.


ouster_ros v0.10.0
Expand Down
11 changes: 11 additions & 0 deletions launch/driver.launch
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
xyzir
}"/>

<arg name="azimuth_window_start" default="0" doc="azimuth window start;
values range [0, 360000] millidegrees"/>
<arg name="azimuth_window_end" default="360000" doc="azimuth window end;
values range [0, 360000] millidegrees"/>

<arg name="persist_config" default="false"
doc="request the sensor to persist settings"/>

<group ns="$(arg ouster_ns)">
<node pkg="nodelet" type="nodelet" name="os_nodelet_mgr"
output="screen" required="true" args="manager"/>
Expand Down Expand Up @@ -92,6 +100,9 @@
<param name="~/proc_mask" value="$(arg proc_mask)"/>
<param name="~/scan_ring" value="$(arg scan_ring)"/>
<param name="~/point_type" value="$(arg point_type)"/>
<param name="~/azimuth_window_start" value="$(arg azimuth_window_start)"/>
<param name="~/azimuth_window_end" value="$(arg azimuth_window_end)"/>
<param name="~/persist_config" value="$(arg persist_config)"/>
</node>
</group>

Expand Down
11 changes: 11 additions & 0 deletions launch/record.launch
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
xyzir
}"/>

<arg name="azimuth_window_start" default="0" doc="azimuth window start,
values range [0, 360000] millidegrees"/>
<arg name="azimuth_window_end" default="360000" doc="azimuth window end,
values range [0, 360000] millidegrees"/>

<arg name="persist_config" default="false"
doc="request the sensor to persist settings"/>

<group ns="$(arg ouster_ns)">
<node pkg="nodelet" type="nodelet" name="os_nodelet_mgr"
output="screen" required="true" args="manager"/>
Expand All @@ -86,6 +94,9 @@
<param name="~/lidar_mode" type="str" value="$(arg lidar_mode)"/>
<param name="~/timestamp_mode" type="str" value="$(arg timestamp_mode)"/>
<param name="~/metadata" type="str" value="$(arg metadata)"/>
<param name="~/azimuth_window_start" value="$(arg azimuth_window_start)"/>
<param name="~/azimuth_window_end" value="$(arg azimuth_window_end)"/>
<param name="~/persist_config" value="$(arg persist_config)"/>
</node>
</group>

Expand Down
9 changes: 8 additions & 1 deletion launch/replay.launch
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

<param name="use_sim_time" value="true"/>

<arg name="loop" default="false" doc="request loop playback"/>
<arg if="$(arg loop)" name="_loop" value="--loop"/>
<arg unless="$(arg loop)" name="_loop" value=" "/>

<remap from="/os_node/imu_packets" to="/ouster/imu_packets"/>
<remap from="/os_node/lidar_packets" to="/ouster/lidar_packets"/>

<arg name="ouster_ns" default="ouster" doc="Override the default namespace of all ouster nodes"/>
<arg name="metadata" default="" doc="path to read metadata file when replaying sensor data"/>
<arg name="bag_file" doc="file name to use for the recorded bag file"/>
Expand Down Expand Up @@ -93,6 +100,6 @@
<node if="$(arg _use_bag_file_name)" pkg="rosbag" type="play" name="rosbag_play_recording"
launch-prefix="bash -c 'sleep 3; $0 $@' "
output="screen" required="true"
args="--clock $(arg bag_file)"/>
args="--clock $(arg bag_file) $(arg _loop)"/>

</launch>
11 changes: 11 additions & 0 deletions launch/sensor.launch
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
xyzir
}"/>

<arg name="azimuth_window_start" default="0" doc="azimuth window start;
values range [0, 360000] millidegrees"/>
<arg name="azimuth_window_end" default="360000" doc="azimuth window end;
values range [0, 360000] millidegrees"/>

<arg name="persist_config" default="false"
doc="request the sensor to persist settings"/>

<group ns="$(arg ouster_ns)">
<node pkg="nodelet" type="nodelet" name="os_nodelet_mgr"
output="screen" required="true" args="manager"/>
Expand All @@ -90,6 +98,9 @@
<param name="~/lidar_mode" type="str" value="$(arg lidar_mode)"/>
<param name="~/timestamp_mode" type="str" value="$(arg timestamp_mode)"/>
<param name="~/metadata" type="str" value="$(arg metadata)"/>
<param name="~/azimuth_window_start" value="$(arg azimuth_window_start)"/>
<param name="~/azimuth_window_end" value="$(arg azimuth_window_end)"/>
<param name="~/persist_config" value="$(arg persist_config)"/>
</node>
</group>

Expand Down
11 changes: 11 additions & 0 deletions launch/sensor_mtp.launch
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
xyzir
}"/>

<arg name="azimuth_window_start" default="0" doc="azimuth window start,
values range [0, 360000] millidegrees"/>
<arg name="azimuth_window_end" default="360000" doc="azimuth window end,
values range [0, 360000] millidegrees"/>

<arg name="persist_config" default="false"
doc="request the sensor to persist settings"/>

<group ns="$(arg ouster_ns)">
<node pkg="nodelet" type="nodelet" name="os_nodelet_mgr"
output="screen" required="true"
Expand All @@ -97,6 +105,9 @@
<param name="~/lidar_mode" type="str" value="$(arg lidar_mode)"/>
<param name="~/timestamp_mode" type="str" value="$(arg timestamp_mode)"/>
<param name="~/metadata" type="str" value="$(arg metadata)"/>
<param name="~/azimuth_window_start" value="$(arg azimuth_window_start)"/>
<param name="~/azimuth_window_end" value="$(arg azimuth_window_end)"/>
<param name="~/persist_config" value="$(arg persist_config)"/>
</node>
</group>

Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="3">
<name>ouster_ros</name>
<version>0.12.4</version>
<version>0.12.5</version>
<description>Ouster ROS driver</description>
<maintainer email="[email protected]">ouster developers</maintainer>
<license file="LICENSE">BSD</license>
Expand Down
30 changes: 28 additions & 2 deletions src/os_sensor_nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using nonstd::optional;

using namespace std::chrono_literals;
using namespace std::string_literals;
using std::to_string;

namespace ouster_ros {

Expand Down Expand Up @@ -232,6 +233,9 @@ sensor::sensor_config OusterSensor::parse_config_from_ros_parameters() {
auto lidar_mode_arg = nh.param("lidar_mode", std::string{});
auto timestamp_mode_arg = nh.param("timestamp_mode", std::string{});
auto udp_profile_lidar_arg = nh.param("udp_profile_lidar", std::string{});
const int MIN_AZW = 0, MAX_AZW = 360000;
auto azimuth_window_start = nh.param("azimuth_window_start", MIN_AZW);
auto azimuth_window_end = nh.param("azimuth_window_end", MAX_AZW);

if (lidar_port < 0 || lidar_port > 65535) {
auto error_msg =
Expand Down Expand Up @@ -313,6 +317,14 @@ sensor::sensor_config OusterSensor::parse_config_from_ros_parameters() {
config.udp_port_imu = imu_port;
}

persist_config = nh.param("persist_config", false);
if (persist_config && (lidar_port == 0 || imu_port == 0)) {
NODELET_WARN("When using persist_config it is recommended to not "
"use 0 for port values as this currently will trigger sensor reinit "
"event each time");
}


config.udp_profile_lidar = udp_profile_lidar;
config.operating_mode = sensor::OPERATING_NORMAL;
if (lidar_mode) config.ld_mode = lidar_mode;
Expand All @@ -325,6 +337,16 @@ sensor::sensor_config OusterSensor::parse_config_from_ros_parameters() {
}
}

if (azimuth_window_start < MIN_AZW || azimuth_window_start > MAX_AZW ||
azimuth_window_end < MIN_AZW || azimuth_window_end > MAX_AZW) {
auto error_msg = "azimuth window values must be between " +
to_string(MIN_AZW) + " and " + to_string(MAX_AZW);
NODELET_ERROR_STREAM(error_msg);
throw std::runtime_error(error_msg);
}

config.azimuth_window = {azimuth_window_start, azimuth_window_end};

return config;
}

Expand Down Expand Up @@ -362,6 +384,11 @@ uint8_t OusterSensor::compose_config_flags(
config_flags |= ouster::sensor::CONFIG_FORCE_REINIT;
}

if (persist_config) {
NODELET_INFO("Configuration will be persisted");
config_flags |= ouster::sensor::CONFIG_PERSIST;
}

return config_flags;
}

Expand Down Expand Up @@ -450,9 +477,8 @@ void OusterSensor::allocate_buffers() {
bool OusterSensor::init_id_changed(const sensor::packet_format& pf,
const uint8_t* lidar_buf) {
uint32_t current_init_id = pf.init_id(lidar_buf);
if (!last_init_id_initialized) {
if (!last_init_id) {
last_init_id = current_init_id + 1;
last_init_id_initialized = true;
}
if (reset_last_init_id && last_init_id != current_init_id) {
last_init_id = current_init_id;
Expand Down
4 changes: 2 additions & 2 deletions src/os_sensor_nodelet.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ class OusterSensor : public OusterSensorNodeletBase {
std::atomic<bool> lidar_packets_processing_thread_active = {false};
std::unique_ptr<std::thread> lidar_packets_processing_thread;

bool persist_config = false;
bool force_sensor_reinit = false;
bool reset_last_init_id = true;

bool last_init_id_initialized = false;
uint32_t last_init_id;
nonstd::optional<uint32_t> last_init_id;

// TODO: add as a ros parameter
const int max_poll_client_error_count = 10;
Expand Down

0 comments on commit 8b81347

Please sign in to comment.