-
Notifications
You must be signed in to change notification settings - Fork 54
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
8828069
cb633d2
fe3df92
80f7b26
322fe29
af77670
04f2e7b
645052f
ba92cae
f5280ad
8c1fa5b
c18f4ca
f52eb41
7322f34
580b417
6835e0f
662275b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ target_link_libraries(hesai_ros_offline_extract_pcd PUBLIC | |
nebula_decoders::nebula_decoders_hesai | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? We were avoiding There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @knzo25 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
) | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
) | ||
|
||
|
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 |
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> |
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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