From 1146f91c77c3fe06de4a328af7fdae99bdb0c101 Mon Sep 17 00:00:00 2001 From: f0reachARR Date: Thu, 18 Apr 2024 15:51:32 +0900 Subject: [PATCH 1/2] Fix LiDAR on top of vehicle instead of bottom of vehicle --- .../src/sensor_simulation/lidar/lidar_sensor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp b/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp index 14d4a427f2d..1d6978b8acf 100644 --- a/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp +++ b/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp @@ -36,6 +36,7 @@ auto LidarSensor::raycast( geometry_msgs::msg::Pose pose; simulation_interface::toMsg(entity.pose(), pose); ego_pose = pose; + ego_pose->position.z += entity.bounding_box().dimensions().z(); } else { geometry_msgs::msg::Pose pose; simulation_interface::toMsg(entity.pose(), pose); From fa5a7ac2464d09782169aa203fd8a84457d9c3e3 Mon Sep 17 00:00:00 2001 From: f0reachARR Date: Thu, 25 Apr 2024 11:47:56 +0900 Subject: [PATCH 2/2] Refactor: use proper variable name --- .../src/sensor_simulation/lidar/lidar_sensor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp b/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp index 1d6978b8acf..5fad0ee2453 100644 --- a/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp +++ b/simulation/simple_sensor_simulator/src/sensor_simulation/lidar/lidar_sensor.cpp @@ -29,14 +29,14 @@ auto LidarSensor::raycast( const std::vector & entities, const rclcpp::Time & current_ros_time) -> sensor_msgs::msg::PointCloud2 { - std::optional ego_pose; + std::optional lidar_pose; for (const auto & entity : entities) { if (configuration_.entity() == entity.name()) { geometry_msgs::msg::Pose pose; simulation_interface::toMsg(entity.pose(), pose); - ego_pose = pose; - ego_pose->position.z += entity.bounding_box().dimensions().z(); + lidar_pose = pose; + lidar_pose->position.z += entity.bounding_box().dimensions().z(); } else { geometry_msgs::msg::Pose pose; simulation_interface::toMsg(entity.pose(), pose); @@ -57,12 +57,12 @@ auto LidarSensor::raycast( } } - if (ego_pose) { + if (lidar_pose) { std::vector vertical_angles; for (const auto vertical_angle : configuration_.vertical_angles()) { vertical_angles.push_back(vertical_angle); } - const auto pointcloud = raycaster_.raycast("base_link", current_ros_time, ego_pose.value()); + const auto pointcloud = raycaster_.raycast("base_link", current_ros_time, lidar_pose.value()); detected_objects_ = raycaster_.getDetectedObject(); return pointcloud; } else {