1

I am trying to simulate an overtaking scenario by editing the existing highway_overtaking.wbt in Webots to observe the indicator lights turn on/off before switching lanes. How do I use the Driver library to do so?

In the modified scenario I currently have just 3 cars in the middle lane, with the grey Lincoln car in between the other 2 cars. I used the setIndicator() function to set the Indicator lights (as shown in code snippet below) But I do not observe any change when the Lincoln car is overtaking the car in front.

Following is the modified snippet of code from the highway_overtaking.py file

if (is_vehicle_on_side("left") and
                (not safeOvertake or sensors["rear left"].getValue() > 0.8 * sensors["rear left"].getMaxValue()) and
                sensors["left"].getValue() > 0.8 * sensors["left"].getMaxValue() and
                currentLane < 2):
            driver.setIndicator(1)
            currentLane += 1
            overtakingSide = 'right'
            lane_change = True
elif (is_vehicle_on_side("right") and
                (not safeOvertake or sensors["rear right"].getValue() > 0.8 * sensors["rear right"].getMaxValue()) and
                sensors["right"].getValue() > 0.8 * sensors["right"].getMaxValue() and
                currentLane > 0):
            driver.setIndicator(2)
            currentLane -= 1
            overtakingSide = 'left'
            lane_change = True

I read the value of the indicator using getIndicator() function and observed that the Indicator value was changed from 0 to 1 when I set it to 1. But I do not observe the Indicator lights changing color on the window. Please help!

Bot_potato
  • 25
  • 2

1 Answers1

1

This is due to the auto-disabling behavior of the indicators (when you turn the steering wheel in the opposite direction of the indicator, the indicator switches off automatically). This is causing issues in this simulation because the commands send to the steering wheels are quite noisy.

One simple solution to fix it is to disable this auto-disabling mechanism with the 'enableIndicatorAutoDisabling' function (https://www.cyberbotics.com/doc/automobile/car-library?tab=python#wbu_car_enable_indicator_auto_disabling).

However, in order to use this function, you should use the Car class instead of the Driver one (the Car class inherits from the Driver class). This requires to add the corresponding import:

from vehicle import Car

And call the Car constructor instead of the Driver one:

driver = Car()

One other minor detail, you should not use integer value with the 'setIndicator' but instead one of the pre-defined value such as:

driver.setIndicator(Driver.INDICATOR_OFF)
driver.setIndicator(Driver.INDICATOR_RIGHT)
driver.setIndicator(Driver.INDICATOR_LEFT)
David Mansolino
  • 1,713
  • 7
  • 13
  • Thank you so much for your response! I changed the car to a BMW model and I could see the indicator lights working but only in the front. I checked the documentation for "def getBackwardsLights(self)" it says that "the backwards and brake lights are switched on automatically by the library when appropriated" But I do not see the indicator lights working at the back. Also, the indicator lights are working only for the BMW car model and not other models. Is there a way I can enable blinking of indicators on the rear side of the BMW car? I really appreciate your response! – Bot_potato Aug 17 '19 at 02:47
  • Just for the note, we did improve the intensity of the vehicle lights recently: https://github.com/omichel/webots/pull/812 This will be included in the next release of Webots. – David Mansolino Aug 19 '19 at 09:00
  • About the rear blinking leds, it really depends on the mesh of the indicators, some of the car model do include rear indicator and some not. The BMW model does not include rear indicator, if you want to add them, you wil have to edit this mesh: https://github.com/omichel/webots/blob/revision/projects/vehicles/protos/bmw/BmwX5LeftIndicator.proto and https://github.com/omichel/webots/blob/revision/projects/vehicles/protos/bmw/BmwX5RightIndicator.proto – David Mansolino Aug 19 '19 at 09:05
  • Thank you for the information. I switched to using the Lincoln car instead of the BMW car and the indicator lights are working perfectly in the front and rear!! Thanks a lot! I really appreciate the help. – Bot_potato Aug 19 '19 at 18:34