Questions regarding collision checking

Dear all,

I would like to ask two questions regarding collision checking using commonroad_dc.

  1. If I create the collision checker of one scenario and split the target trajectory (ego_vehicle_state_list) into multiple pycrcc.RectOBB as follows:

     # create collision checker of the scenario
     self.collision_checker_scenario = create_collision_checker(self.scenario)
     self.collision_checker_scenario.add_collision_object(road_boundary_sg_triangles)
     for i in range(len(ego_vehicle_state_list)):
         pos1 = ego_vehicle_state_list[i].position[0]
         pos2 = ego_vehicle_state_list[i].position[1]
         theta = ego_vehicle_state_list[i].orientation
         ego = pycrcc.TimeVariantCollisionObject(i)
         ego.append_obstacle(pycrcc.RectOBB(0.5 * self.length,
                                            0.5 * self.width,
                                            theta, pos1, pos2))
         # return the collision time
         if self.collision_checker_scenario.collide(ego):
             return i*self.dT
    

Will this consider the dynamic behaviors of the moving vehicles, i.e., the algorithm also checks the different positions of other vehicles in different time steps (not just the collision of the entire trajectory)?

  1. I would like to use trajectory_queries.trajectories_collision_static_obstacles to check the collision between ego vehicle and static obstacles, not just road boundary. But this function only accepts that static obstacles are the object of commonroad_dc.pycrcc.ShapeGroup(). How could I create a ShapeGroup object? I didn’t find related information in the API documentation.

Thank you so much in advance!

Best regards,
Yuanfei

Hi Yuanfei,

Regarding question 2: In order to create a shape group collision object of type commonroad_dc.pycrcc.ShapeGroup you could use commonroad_dc.collision.collision_detection.pycrcc_collision_dispatch.create_collision_object(). The required input is an object of type commonroad.geometry.shape.ShapeGroup.

I am not quite sure about your first question. I forwarded your post to a colleague of mine who will take a look at it.

Best regards,
Gerald

Hi Yuanfei,

  1. A collision checker may contain static obstacles, such as simple shapes and shape groups, as well as dynamic obstacles (each dynamic obstacle is a TimeVariantCollisionObject). When collide is called, the ego-vehicle trajectory is collided with all the static obstacles. It also goes through all the dynamic obstacles, and for each time step it collides the objects of the ego vehicle with the corresponding objects of the dynamic obstacles that belong to the same time step.

  2. You can find an example of creating a ShapeGroup in the tutorial.
    https://commonroad.in.tum.de/tutorial-python-wrapper
    (3: Creating Groups of Shapes).

Dear Gerald and Vitalii,

Thanks a lot, your explanations were really useful!! :laughing:

best,
Yuanfei