@@ -49,6 +49,21 @@ public CoordinateSystemEnum CoordinateSystem {
4949 set { _coordinateSystem = value ; }
5050 }
5151
52+ public bool _reverseLinearAccelerations = false ;
53+
54+ /// <summary>
55+ /// Flips gravity vector.
56+ /// Why would you: the accelerometer is an intertial sensor and it measures inertial force.
57+ /// The accelerometer doesn’t measure G-force, but rather the force that resists to G.
58+ /// The resisting force aims up to the ceiling.
59+ /// </summary>
60+ /// <value></value>
61+ public bool ReverseLinearAccelerations {
62+ get { return _reverseLinearAccelerations ; }
63+ set { _reverseLinearAccelerations = value ; }
64+ }
65+
66+
5267
5368 private ZOROSTransformPublisher _transformPublisher = null ;
5469 public ZOROSTransformPublisher TransformPublisher {
@@ -102,6 +117,12 @@ private Task OnPublishImuDelegate(ZOIMU lidar, string name, Vector3 linearAccel,
102117 _imuMessage . header . Update ( ) ;
103118 _imuMessage . header . frame_id = TransformPublisher . ChildFrameID ;
104119
120+
121+ if ( ReverseLinearAccelerations == true ) {
122+ linearAccel = linearAccel * - 1 ;
123+ }
124+
125+
105126 if ( _coordinateSystem == CoordinateSystemEnum . ROS_RightHanded_XForward_YLeft_ZUp ) {
106127 _imuMessage . linear_acceleration . UnityVector3 = linearAccel ;
107128 _imuMessage . angular_velocity . UnityVector3 = angularVelocity ;
@@ -133,7 +154,7 @@ private Task OnPublishImuDelegate(ZOIMU lidar, string name, Vector3 linearAccel,
133154 _imuMessage . linear_acceleration . z = linearAccel . z ;
134155
135156 _imuMessage . angular_velocity . x = angularVelocity . x ;
136- _imuMessage . angular_velocity . y = - angularVelocity . y ;
157+ _imuMessage . angular_velocity . y = angularVelocity . y ;
137158 _imuMessage . angular_velocity . z = angularVelocity . z ;
138159
139160 } else if ( CoordinateSystem == CoordinateSystemEnum . Unity_LeftHanded_XRight_YUp_ZForward ) {
@@ -153,6 +174,8 @@ private Task OnPublishImuDelegate(ZOIMU lidar, string name, Vector3 linearAccel,
153174 }
154175
155176
177+
178+
156179 ROSBridgeConnection . Publish ( _imuMessage , ROSTopic , Name ) ;
157180
158181 return Task . CompletedTask ;
0 commit comments