-
Notifications
You must be signed in to change notification settings - Fork 4.3k
RayPerceptionSensorComponent3D does not function as expected when the agent's scale is not 1. #3321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'll look into this tomorrow. Can you explain more what are you seeing and what do you expect? I would expect that when the scale changes, the length of the rays also increase. |
Thanks, the screenshot helps a lot. Looking into it now, I get the feeling the scale is being applied twice somehow. |
OK, I think I know what's going on. I believe this is just a visual bug, but it's definitely something we should fix. ml-agents/com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs Lines 219 to 228 in 4ba8b97
we cast up to rayLength units, and save the hit fraction. This fraction is based on rayLength units.
When doing the gizmo drawing here ml-agents/com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponentBase.cs Lines 127 to 128 in 4ba8b97
We try to use the hit fraction to interpolate between the start and end points. Since these start and end points are affected by the scale, they won't necessarily be rayLength units apart. So we'd need to scale the hit fraction (for display only) by rayLength / rayDirection.magnitude .
I think a cleaner fix would be to use the scaled ray length ( I'll have a PR for this tomorrow or early next week. In the meantime, I'm pretty confident that training with a RayPerceptionSensor and scale will still work. |
Thanks, Chris. Ml-agents is such an awesome project because of developers like you. |
This was fixed in #3334 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Uh oh!
There was an error while loading. Please reload this page.
All the agents in the example scenes have a scale of 1. However, if changed the scale to other numbers, the Debug gizmo would also scale, resulting in the wrong rays drawn in the editor.
I haven't checked whether the observed values are correct yet. Presumably, it may have the same issue.
To reproduce this bug, just change the scale of the agent of WallJump example and run using the trained model. You will see that the rays drawn in the editor is wrong.
The text was updated successfully, but these errors were encountered: