From 189349f42174cb812034eed11c3f51cdd379b9dd Mon Sep 17 00:00:00 2001 From: Tom Erez Date: Fri, 16 Dec 2022 07:16:55 -0800 Subject: [PATCH] Don't add an empty "user" attribute to user sensors. This fixes the broken TAP tests. PiperOrigin-RevId: 495867491 Change-Id: I740651ed0dd8d1c84053a48f3fca577b6024bf95 --- unity/Runtime/Components/Sensors/MjUserSensor.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unity/Runtime/Components/Sensors/MjUserSensor.cs b/unity/Runtime/Components/Sensors/MjUserSensor.cs index 2534e94a..51e7ec3b 100644 --- a/unity/Runtime/Components/Sensors/MjUserSensor.cs +++ b/unity/Runtime/Components/Sensors/MjUserSensor.cs @@ -32,8 +32,10 @@ public class MjUserSensor : MjBaseSensor { var mjcf = doc.CreateElement("user"); mjcf.SetAttribute("name", Name); mjcf.SetAttribute("dim", $"{Dimension}"); - // TODO: add validation that UserData is a space-separated list of floating numbers? - mjcf.SetAttribute("user", UserData); + if (!String.IsNullOrEmpty(UserData)) { + // TODO: add validation that UserData is a space-separated list of floating numbers? + mjcf.SetAttribute("user", UserData); + } return mjcf; }