Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve script for decoding packets into a new rosbag #236

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions nebula_examples/CMakeLists.txt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the list() commands again, since they were only for debugging purposes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I remove them, there is no executable output...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, now this one looks good. The install command works

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ target_link_libraries(hesai_ros_offline_extract_pcd PUBLIC
nebula_decoders::nebula_decoders_hesai
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? We were avoiding ament_auto on purpose for reduce building time

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, when I first build this package without ament_auto, there is no output in the built output directory.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(please remind me to delete these two images when this is somehow resolved)

Copy link
Author

@Owen-Liuyuxuan Owen-Liuyuxuan Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built again with my current PR and I can see the contents correctly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solution is to take the steps that ament auto does manually. That requires some cmake knowledge, but there should be examples in nebula for you to follow.

Copy link
Author

@Owen-Liuyuxuan Owen-Liuyuxuan Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knzo25
I added list(APPEND ${PROJECT_NAME}_EXECUTABLES "${target}") and the build works, but the build time is similar to what we got with ament_auto_add_executable

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I instead add the install command in CMakeList to make it work.

add_executable(hesai_ros_offline_extract_pcd_node
ament_auto_add_executable(hesai_ros_offline_extract_pcd_node
${CMAKE_CURRENT_SOURCE_DIR}/src/hesai/hesai_ros_offline_extract_pcd_main.cpp
)

Expand All @@ -62,13 +62,29 @@ target_link_libraries(hesai_ros_offline_extract_bag_pcd PUBLIC
nebula_decoders::nebula_decoders_hesai
)

add_executable(hesai_ros_offline_extract_bag_pcd_node
ament_auto_add_executable(hesai_ros_offline_extract_bag_pcd_node
${CMAKE_CURRENT_SOURCE_DIR}/src/hesai/hesai_ros_offline_extract_bag_pcd_main.cpp
)

target_link_libraries(hesai_ros_offline_extract_bag_pcd_node PUBLIC
hesai_ros_offline_extract_bag_pcd
)
# Extraction for Hesai ROSBag
add_library(hesai_ros_offline_extract_bag_decode SHARED
${CMAKE_CURRENT_SOURCE_DIR}/src/hesai/hesai_ros_offline_extract_bag_decode.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/common/parameter_descriptors.cpp
)
target_link_libraries(hesai_ros_offline_extract_bag_decode PUBLIC
nebula_decoders::nebula_decoders_hesai
)

ament_auto_add_executable(hesai_ros_offline_extract_bag_decode_node
${CMAKE_CURRENT_SOURCE_DIR}/src/hesai/hesai_ros_offline_extract_bag_decode_main.cpp
)

target_link_libraries(hesai_ros_offline_extract_bag_decode_node PUBLIC
hesai_ros_offline_extract_bag_decode
)

## Velodyne
# Extraction for TEST Lib
Expand All @@ -79,7 +95,7 @@ target_link_libraries(velodyne_ros_offline_extract_bag_pcd PUBLIC
nebula_decoders::nebula_decoders_velodyne
)

add_executable(velodyne_ros_offline_extract_bag_pcd_node
ament_auto_add_executable(velodyne_ros_offline_extract_bag_pcd_node
${CMAKE_CURRENT_SOURCE_DIR}/src/velodyne/velodyne_ros_offline_extract_bag_pcd_main.cpp
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright 2023 Map IV, 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 NEBULA_HesaiRosOfflineExtractBagDecode_H
#define NEBULA_HesaiRosOfflineExtractBagDecode_H

#include <diagnostic_updater/diagnostic_updater.hpp>
#include <nebula_common/hesai/hesai_common.hpp>
#include <nebula_common/nebula_common.hpp>
#include <nebula_common/nebula_status.hpp>
#include <nebula_decoders/nebula_decoders_hesai/hesai_driver.hpp>
#include <nebula_ros/common/parameter_descriptors.hpp>
#include <rclcpp/rclcpp.hpp>

#include <nebula_msgs/msg/nebula_packet.hpp>
#include <nebula_msgs/msg/nebula_packets.hpp>
#include <pandar_msgs/msg/pandar_packet.hpp>
#include <pandar_msgs/msg/pandar_scan.hpp>

#include <memory>
#include <string>

namespace nebula::ros
{
class HesaiRosOfflineExtractBagDecode final : public rclcpp::Node
{
std::shared_ptr<drivers::HesaiDriver> driver_ptr_;
Status wrapper_status_;

std::shared_ptr<drivers::HesaiCalibrationConfiguration> calibration_cfg_ptr_;
std::shared_ptr<drivers::SensorConfigurationBase> sensor_cfg_ptr_;
std::shared_ptr<drivers::HesaiCorrection> correction_cfg_ptr_;

Status initialize_driver(
std::shared_ptr<drivers::SensorConfigurationBase> sensor_configuration,
std::shared_ptr<drivers::HesaiCalibrationConfigurationBase> calibration_configuration);

Status get_parameters(
drivers::HesaiSensorConfiguration & sensor_configuration,
drivers::HesaiCalibrationConfiguration & calibration_configuration,
drivers::HesaiCorrection & correction_configuration);

static inline std::chrono::nanoseconds seconds_to_chrono_nano_seconds(const double seconds)
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(seconds));
}

public:
explicit HesaiRosOfflineExtractBagDecode(
const rclcpp::NodeOptions & options, const std::string & node_name);

Status get_status();
Status read_bag();

private:
std::string bag_path_;
std::string storage_id_;
std::string out_path_;
std::string format_;
std::string target_topic_;
std::string correction_file_path_;
std::string frame_id_;
std::string output_topic_;
int out_num_;
int skip_num_;
bool only_xyz_;
};

} // namespace nebula::ros

#endif // NEBULA_HesaiRosOfflineExtractBagDecode_H
44 changes: 44 additions & 0 deletions nebula_examples/launch/hesai_offline_bag_decode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<launch>
<!-- io configuration -->
<arg name="sensor_model" default="Pandar128E4X" description="Pandar64|Pandar40P|PandarXT32|PandarXT32M|PandarAT128|PandarQT64"/>
<arg name="lidar_parameter_file" default="$(find-pkg-share nebula_ros)/config/lidar/hesai/Pandar128E4X.params.yaml"/>
<arg name="bag_path" default="rosbags/default_2024-10-24-10-50-48_p0900"/>
<arg name="target_topic" default="/sensing/lidar/top/pandar_packets"/>
<arg name="output_topic" default="/sensing/lidar/top/pointcloud"/>
<arg name="frame_id" default="lidar_top"/>
<arg name="out_path" default="output_rosbag"/>

<!-- output sample number configuration -->
<arg name="out_num" default="3999"/>
<arg name="skip_num" default="0"/>

<!-- LiDAR configuration overriding parameter file -->
<arg name="scan_phase" default="0.0" />
<arg name="return_mode" default="Dual" description="See readme for supported return modes"/>

<arg name="calibration_file" default="$(find-pkg-share nebula_decoders)/calibration/hesai/$(var sensor_model).csv"/>
<arg name="correction_file" default="$(find-pkg-share nebula_decoders)/calibration/hesai/$(var sensor_model).dat"/>

<arg name="storage_id" default="sqlite3"/>
<arg name="format" default="cdr"/>

<node pkg="nebula_examples" exec="hesai_ros_offline_extract_bag_decode_node"
name="hesai_cloud" output="screen">
<param from="$(var lidar_parameter_file)"/>
<param name="sensor_model" value="$(var sensor_model)"/>
<param name="return_mode" value="$(var return_mode)"/>
<param name="frame_id" value="$(var frame_id)"/>
<param name="scan_phase" value="$(var scan_phase)"/>
<param name="calibration_file" value="$(var calibration_file)"/>
<param name="correction_file" value="$(var correction_file)"/>
<param name="bag_path" value="$(var bag_path)"/>
<param name="storage_id" value="$(var storage_id)"/>
<param name="out_path" value="$(var out_path)"/>
<param name="format" value="$(var format)"/>
<param name="target_topic" value="$(var target_topic)"/>
<param name="output_topic" value="$(var output_topic)"/>
<param name="out_num" value="$(var out_num)"/>
<param name="skip_num" value="$(var skip_num)"/>
</node>
</launch>
Loading
Loading