Skip to content

Commit

Permalink
Bugfix 2.3 ROS support
Browse files Browse the repository at this point in the history
* Fix ROS node consumption of new 2.3 profiles
* Add glad to license
  • Loading branch information
kairenw committed Apr 22, 2022
1 parent f375a31 commit f60acf3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
23 changes: 23 additions & 0 deletions LICENSE-bin
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,26 @@ License: Zlib License

3. This notice may not be removed or altered from any source
distribution.

Name: glad
Description: statically linked
Availability: https://github.com/Dav1dde/glad/
License: MIT
Copyright (c) 2013-2021 David Herberth

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion ouster_ros/ouster.launch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<arg name="viz" default="false" doc="whether to run a rviz"/>
<arg name="rviz_config" default="-d $(find ouster_ros)/viz.rviz" doc="optional rviz config file"/>
<arg name="tf_prefix" default="" doc="namespace for tf transforms"/>
<arg name="udp_profile_lidar" default="" doc="lidar packet profile: LEGACY, RNG19_RFL8_SIG16_NIR16_DUAL"/>
<arg name="udp_profile_lidar" default="" doc="lidar packet profile: LEGACY, RNG19_RFL8_SIG16_NIR16_DUAL, RNG19_RFL8_SIG16_NIR16, RNG15_RFL8_NIR8"/>

<node pkg="ouster_ros" name="os_node" type="os_node" output="screen" required="true">
<param name="~/lidar_mode" type="string" value="$(arg lidar_mode)"/>
Expand Down
43 changes: 24 additions & 19 deletions ouster_ros/src/ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,36 @@ sensor::ChanField suitable_return(sensor::ChanField input_field, bool second) {
}
}

template <typename T>
inline ouster::img_t<T> get_or_fill_zero(sensor::ChanField f,
const ouster::LidarScan& ls) {
ouster::img_t<T> result{ls.h, ls.w};
if (ls.field_type(f)) {
ouster::impl::visit_field(ls, f, read_and_cast(), result);
} else {
result = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic,
Eigen::RowMajor>::Zero(ls.h, ls.w);
}
return result;
}

void scan_to_cloud(const ouster::XYZLut& xyz_lut,
ouster::LidarScan::ts_t scan_ts, const ouster::LidarScan& ls,
ouster_ros::Cloud& cloud, int return_index) {
bool second = (return_index == 1);
cloud.resize(ls.w * ls.h);

ouster::img_t<uint16_t> near_ir;
ouster::impl::visit_field(
ls, suitable_return(sensor::ChanField::NEAR_IR, second),
read_and_cast(), near_ir);

ouster::img_t<uint32_t> range;
ouster::impl::visit_field(ls,
suitable_return(sensor::ChanField::RANGE, second),
read_and_cast(), range);

ouster::img_t<uint32_t> signal;
ouster::impl::visit_field(
ls, suitable_return(sensor::ChanField::SIGNAL, second), read_and_cast(),
signal);

ouster::img_t<uint16_t> reflectivity;
ouster::impl::visit_field(
ls, suitable_return(sensor::ChanField::REFLECTIVITY, second),
read_and_cast(), reflectivity);
ouster::img_t<uint16_t> near_ir = get_or_fill_zero<uint16_t>(
suitable_return(sensor::ChanField::NEAR_IR, second), ls);

ouster::img_t<uint32_t> range = get_or_fill_zero<uint32_t>(
suitable_return(sensor::ChanField::RANGE, second), ls);

ouster::img_t<uint32_t> signal = get_or_fill_zero<uint32_t>(
suitable_return(sensor::ChanField::SIGNAL, second), ls);

ouster::img_t<uint16_t> reflectivity = get_or_fill_zero<uint16_t>(
suitable_return(sensor::ChanField::REFLECTIVITY, second), ls);

auto points = ouster::cartesian(range, xyz_lut);

Expand Down

0 comments on commit f60acf3

Please sign in to comment.