-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Diego Palma <dpalma@symbotic.com>
- Loading branch information
Diego Palma
committed
Nov 8, 2024
1 parent
27fd135
commit 1469782
Showing
8 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 Ekumen, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef BELUGA_ROS_LIKELIHOOD_FIELD_HPP | ||
#define BELUGA_ROS_LIKELIHOOD_FIELD_HPP | ||
|
||
#include <cstdint> | ||
|
||
#include <beluga/sensor/data/value_grid.hpp> | ||
#include <nav_msgs/msg/occupancy_grid.hpp> | ||
|
||
/** | ||
* \file | ||
* \brief Utilities for likelihood data over ROS interfaces. | ||
*/ | ||
|
||
namespace beluga_ros { | ||
|
||
inline void assign_likelihood_field( | ||
const beluga::ValueGrid2<float>& likelihood_field, | ||
nav_msgs::msg::OccupancyGrid& message) { | ||
// Set metadata | ||
message.info.width = static_cast<unsigned int>(likelihood_field.width()); | ||
message.info.height = static_cast<unsigned int>(likelihood_field.height()); | ||
message.info.resolution = static_cast<float>(likelihood_field.resolution()); | ||
|
||
// Populate the data field with the grid data | ||
message.data.resize(likelihood_field.size()); | ||
const auto& grid_data = likelihood_field.data(); | ||
|
||
for (std::size_t i = 0; i < likelihood_field.size(); ++i) { | ||
// Convert T to int8_t if necessary | ||
message.data[i] = static_cast<int8_t>(grid_data[i]); | ||
} | ||
} | ||
|
||
} // namespace beluga_ros | ||
|
||
#endif // BELUGA_ROS_LIKELIHOOD_FIELD_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters