carla icon indicating copy to clipboard operation
carla copied to clipboard

Different inplace modifications when the BasicAgent checks for obstacles? Asking for clarification.

Open Daraan opened this issue 1 year ago • 0 comments

This section in the BasicAgent always confuses me.

https://github.com/carla-simulator/carla/blob/4da0c7415499981f29874b899edd00c1368df06f/PythonAPI/carla/agents/navigation/basic_agent.py#L378

 ego_transform = self._vehicle.get_transform() 
 ego_location = ego_transform.location 
 ego_wpt = self._map.get_waypoint(ego_location) 
  
...

 # Get the transform of the front of the ego 
 ego_front_transform = ego_transform 
 ego_front_transform.location += carla.Location( 
     self._vehicle.bounding_box.extent.x * ego_transform.get_forward_vector()) 

Shouldn't ego_front_transform & ego_transform and ego_front_transform.location & ego_location reference to the same location/transformation, so a modification of one modifies all others? I looked into this a while ago and think I closed my thought that transform.location always creates a new python object, but it and its modification go back to the underlying same object.


As all variables are used multiple times in different semantics I wanted to raise this issue for clarification or potential changes in the future.

@glopezdiest can you maybe clarify this for me? Thanks a lot.

Daraan avatar Jun 26 '24 18:06 Daraan