webots
webots copied to clipboard
Positional Sensor on Rotational Motor has a discontinuous value change at high speeds
Describe the Bug
When running a custom world (has some buildings and flat ground with grass) simulation of the Tesla Model 3 (proto downloaded from your webots cloud site), I am experiencing an issue when running at speeds over 15 m/s (this depends on the basicTimeStep parameter in the World settings).
I am running Webots R2023b.
Steps to Reproduce
- Open up a basic world that has a lot of space to drive.
- Set your basicTimeStep parameter to 33.
- Run the TeslaModel 3 proto in this world at a speed greater than 15 m/s.
- See error of Position Sensor (either wheel) spontaneously jumping up in it's cumulative increase/decrease in rads.
- I did some investigating into this issue. It seems when the difference in current to previous position sensor readings becomes greater than ~1.42 rads, this issue appears. This was confirmed by increasing the
basicTimeStepabove 33 (ms) and seeing this issue appear at lower speeds, then decreasing thebasicTimeStepand seeing this issue appear at higher speeds. The commonality seems to be when consecutive reads of the Position Sensor on the wheels are greater than 1.42 rads.
Expected behavior There would be a linear increase in difference between the current Position Sensor value read and the previous past the 1.4 rad mark.
Screenshots
I'll explain some things in this image
_leftPositionSensorData = a private variable which holds the this->_leftPositionSensor->getValue() (rads) where _leftPositionSensor is a webots::PositionSensor pointer to the left wheel's position sensor.
_previousLeftPositionSensorValue is _leftPositionSensorData value from the previous timestep (0.03 s).
RobotSpeed is the speed we are calculating based on the current RPM knowing the wheel radius.
CMD is the velocity (m/s) and spin rate (curvature) we are attempting to command to the vehicle.
As you can see from the first mention of _leftPositionSensorData in the terminal from the screenshot, we have a difference between timesteps of approximately 1.41, then to approximately 1.42, then this large jump happens to 4.86 on the third mention of _leftPositionSensorData in the terminal. This is the behaviour I find weird that is messing up my code.
System
- Operating System: Linux Ubuntu 20.04
- Graphics Card: Mesa Intel® Xe Graphics (TGL GT2)
Additional context
The speed was going crazy at this point (RobotSpeed) because our math would break when this would happen. I have since figured out that you can get a continuous decrease in the angle difference if you take the _leftPositionSensorData and _previousLeftPositionSensorValue, take the absolute, then subtract that value from 2Pi. This is also fairly confusing, but works at the moment... Here is what the code would look like
this->_leftRPM = ((Constants::TwoPI - std::abs(this->_previousLeftPositionSensorValue - this->_leftPositionSensorData)) / leftRpmSamplingPeriod) * SimulatorRobotChassisConstants::RPMConversion;
Bump - Is anyone able to look at this?