bark-simulator / bark

Open-Source Framework for Development, Simulation and Benchmarking of Behavior Planning Algorithms for Autonomous Driving
https://bark-simulator.github.io/
MIT License
288 stars 69 forks source link

distance between the two agents is always zero #506

Closed tinmodeHuang closed 3 years ago

tinmodeHuang commented 3 years ago

purpose: calculating the distances between any two agents. the snippet modified in the graph_observer.py as shown below:

from bark.core.geometry import Distance, Point2d

    # add edges to all visible agents
    for index, agent in agents:
      nearby_agents = self._nearby_agents(
        center_agent=agent, 
        agents=agents, 
        radius=self._visibility_radius)

      if self._add_self_loops:
        adjacency_matrix[index, index] = 1

      for target_index, nearby_agent in nearby_agents:
        # if agent is world.ego_agent:
        if agent.shape is not None and nearby_agent.shape is not None:
          print('%-8.3f' % Distance(agent.shape, nearby_agent.shape), end='')

the way to do it shows as the last lines of statements above. outputs in the terminal were all normal except that the distance is laways zero.

patrickhart commented 3 years ago

The agent.shape is not transformed but always the base shape. Need to use agent.GetPolygonFromState(agent.state) Should change the IF in the future to agent.GetPolygonFromState()

tinmodeHuang commented 3 years ago

all right. besides, could you please have a look at #505