Skip to content

Commit

Permalink
fix(simple_sensor_simulator): Fix if condition by adding negation to …
Browse files Browse the repository at this point in the history
…ensure proper logic
  • Loading branch information
SzymonParapura committed Dec 10, 2024
1 parent 547cb0a commit 682acd3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ class DetectionSensorBase
explicit DetectionSensorBase(
const double current_simulation_time,
const simulation_api_schema::DetectionSensorConfiguration & configuration)
: previous_simulation_time_(current_simulation_time),
configuration_(configuration),
ego_plane_opt_(std::nullopt),
ego_plane_pose_opt_(std::nullopt)
: previous_simulation_time_(current_simulation_time), configuration_(configuration)
{
}

Expand All @@ -66,8 +63,8 @@ class DetectionSensorBase
const std::vector<std::string> & lidar_detected_entities) = 0;

private:
std::optional<math::geometry::Plane> ego_plane_opt_;
std::optional<geometry_msgs::msg::Pose> ego_plane_pose_opt_;
std::optional<math::geometry::Plane> ego_plane_opt_{std::nullopt};
std::optional<geometry_msgs::msg::Pose> ego_plane_pose_opt_{std::nullopt};
};

template <typename T, typename U = autoware_perception_msgs::msg::TrackedObjects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ auto DetectionSensorBase::isOnOrAboveEgoPlane(
// update ego plane if needed
geometry_msgs::msg::Pose ego_pose_ros;
simulation_interface::toMsg(ego_pose, ego_pose_ros);
if (!ego_plane_opt_ || ego_plane_pose_opt_ || hasEgoOrientationChanged(ego_pose_ros)) {
if (!ego_plane_opt_ || !ego_plane_pose_opt_ || hasEgoOrientationChanged(ego_pose_ros)) {
ego_plane_opt_.emplace(
ego_pose_ros.position, math::geometry::getNormalVector(ego_pose_ros.orientation));
ego_plane_pose_opt_ = ego_pose_ros;
Expand Down

0 comments on commit 682acd3

Please sign in to comment.