`Device`s with duplicate names cause unexpected behavior
brettle opened this issue · 0 comments
brettle commented
Describe the Bug
If two Device
nodes have the same name
, a controller will silently not distinguish between them.
Steps to Reproduce
- Create a world with 2
HingeJoint
s, each with aRotationalMotor
and aBrake
. Give theRotationalMotor
's different names but leave the names of theBrake
s at the default "brake". Attach a flywheel solid (with physics) to eachHingeJoint
so that the motors have something to drive. - In controller code, get each of the
Motor
s and then usemotor.getBrake()
to get each of theBrake
s. For each brake, callbrake.setDampingConstant(someValue)
. - Start the world and use the UI to start each flywheel spinning. One will slow to a stop but the other will spin forever because the damping constant only got set on one of the
Brake
devices.
Expected behavior
Ideally, both flywheels slow to a stop.
At a minimum, a warning or error message should be displayed indicating that multiple devices with the same name are not supported.
System
Any.
Additional context
I suspect the core of the problem is here:
webots/src/controller/cpp/Device.cpp
Lines 25 to 27 in 1c6c9a3
Since wb_robot_get_device()
returns the tag of the first device with a given name, a Device
's tag is fully determined by it's name.