So i have the following code in a Python controller inside Webots simulator.
from vehicle import Driver
from controller import Radar
radar = Radar("radar")
radar.enable(1)
while driver.step() != -1:
num_targets = radar.getNumberOfTargets()
targets = radar.getTargets()
for i in targets:
print(vars(i))
What i try to do with this code is to count how many objects does the radar detect, and print all the information about them (speed, distance, azimuth...).
The function getNumberOfTargets() works properly always, but getTargets() function returns a array with len == num_targets. The objets inside have the same values for all the attributes. I dont understand why is this happening.
The attributes are always the ones corresponding to the object that its more on the left side. I would like to obtain the information of all the objects in the range of the radar.
The parameters of the Radar Node are the default ones. I only changed the maxRange of the radar frustrums.
I tried looking in the documentation of Webots to see if there is a property for the Radar node to specify how many objects can max detect. However, there is no property similar to this.
Here is one example of the values i get for every target detected by the radar:
array of targets = [<controller.radar_target.RadarTarget object at 0x000002387D0002E0>, <controller.radar_target.RadarTarget object at 0x000002387D000BB0>]
object1values = {'distance': 49.36169833744215, 'receiver_power': -58.779710440658974, 'speed': -5.4952828061041314, 'azimuth': -1.4326991352820366}
object2values = {'distance': 49.36169833744215, 'receiver_power': -58.779710440658974, 'speed': -5.4952828061041314, 'azimuth': -1.4326991352820366}
As shown, both objects have different memory position, but same attribute values. The azimuth value shows that the information belongs to the object more on the left side of the radar range.
I would like to obtain the information about all the objects that are in the radar frustrums range.