Skip to content
Merged
Changes from all commits
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
16 changes: 13 additions & 3 deletions GEMstack/onboard/perception/pedestrian_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from copy import deepcopy
# ROS, CV
import rospy
import message_filters
import tf
from cv_bridge import CvBridge
from sensor_msgs.msg import Image, PointCloud2
Expand All @@ -52,7 +51,7 @@
from ..component import Component
from .IdTracker import IdTracker
from scipy.spatial.transform import Rotation as R
from septentrio_gnss_driver.msg import INSNavGeod


def box_to_fake_agent(box):
"""Creates a fake agent state from an (x,y,w,h) bounding box.
Expand Down Expand Up @@ -137,6 +136,7 @@ def update(self, vehicle : VehicleState) -> Dict[str,AgentState]:

# Edge cases

# Initial vehicle pose data
if(self.current_vehicle_state == None and self.previous_vehicle_state == None):
self.current_vehicle_state = vehicle
# We get vehicle state from GNSS in global state
Expand All @@ -150,8 +150,18 @@ def update(self, vehicle : VehicleState) -> Dict[str,AgentState]:
self.previous_vehicle_state = self.current_vehicle_state
self.current_vehicle_state = vehicle

# edge case to handle no pedestrian data
if(self.current_agent_obj_dims == {}):
return self.current_agents
return {}

# edge case to handle empty lists:
if(len(self.current_agent_obj_dims['pose']) == 0 or len(self.current_agent_obj_dims['dims']) == 0):
return {}

# Edge case to handle differently sized lists:
# TODO: Handle different lengths properly
if len(self.current_agent_obj_dims['pose']) != len(self.current_agent_obj_dims['dims']):
raise Exception( f"Length of extracted poses ({len(self.current_agent_obj_dims['pose'])}) and dimensions ({len(self.current_agent_obj_dims['dims'])}) are not equal")

# Update current time:
self.curr_time = vehicle.pose.t
Expand Down