Skip to content

Commit bf0db8f

Browse files
committed
added ability to flip the turn direction
1 parent 32059a4 commit bf0db8f

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

Runtime/Scripts/ROS/Unity/Controllers/ZODifferentialDriveController.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public ZOHingeJoint LeftWheelMotor {
7676
}
7777
public float _wheelRadius = 0;
7878
public float _wheelSeperation = 0;
79-
80-
// public ZO.Physics.ZOSpeedLimiter _speedLimiterLinear;
81-
// public ZO.Physics.ZOSpeedLimiter _speedLimiterAngular;
79+
public bool _steerOpposite = false;
8280

8381
private float _linearVelocity = 0;
8482
private float _angularVelocity = 0;
@@ -138,9 +136,14 @@ protected override void ZOOnDestroy() {
138136
}
139137

140138
protected override void ZOFixedUpdate() {
141-
// update the motors
139+
// update the motors from the twist message
142140
LinearVelocity = (float)-_twistMessage.linear.x * Mathf.Rad2Deg;
143-
AngularVelocity = (float)_twistMessage.angular.z * Mathf.Rad2Deg;
141+
if (_steerOpposite == true) {
142+
AngularVelocity = (float)-_twistMessage.angular.z * Mathf.Rad2Deg;
143+
} else {
144+
AngularVelocity = (float)_twistMessage.angular.z * Mathf.Rad2Deg;
145+
}
146+
144147
}
145148
protected override void ZOFixedUpdateHzSynchronized() {
146149

Samples~/ZeroSimSamples/Scenes/ROSIMUPublish_test.unity

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,8 +1681,8 @@ Transform:
16811681
m_PrefabInstance: {fileID: 0}
16821682
m_PrefabAsset: {fileID: 0}
16831683
m_GameObject: {fileID: 1298881059}
1684-
m_LocalRotation: {x: 0.33100855, y: 0, z: 0, w: 0.9436278}
1685-
m_LocalPosition: {x: 0, y: 0.3, z: -0.19}
1684+
m_LocalRotation: {x: -0.1828506, y: -0.7689693, z: 0.25178373, w: -0.5584416}
1685+
m_LocalPosition: {x: -3.4649842, y: 5.000902, z: 4.705735}
16861686
m_LocalScale: {x: 1, y: 1, z: 1}
16871687
m_Children: []
16881688
m_Father: {fileID: 0}
@@ -1700,8 +1700,8 @@ MonoBehaviour:
17001700
m_Script: {fileID: 11500000, guid: 3e0e3af0b8141964b85373790012f3b9, type: 3}
17011701
m_Name:
17021702
m_EditorClassIdentifier:
1703-
target: {fileID: 1189395070}
1704-
distance: 0.2
1703+
target: {fileID: 1753787007}
1704+
distance: 1.45
17051705
xSpeed: 60
17061706
ySpeed: 60
17071707
yMinLimit: -20
@@ -2109,6 +2109,7 @@ MonoBehaviour:
21092109
_name: ros.publisher.imu_IMU
21102110
_imuSensor: {fileID: 1753787004}
21112111
_coordinateSystem: 1
2112+
_reverseLinearAccelerations: 1
21122113
--- !u!114 &1753787004
21132114
MonoBehaviour:
21142115
m_ObjectHideFlags: 0
@@ -2121,11 +2122,10 @@ MonoBehaviour:
21212122
m_Script: {fileID: 11500000, guid: 5c60fd8f844d425c388b59c3631f6062, type: 3}
21222123
m_Name:
21232124
m_EditorClassIdentifier:
2124-
_updateRateHz: 10
2125+
_updateRateHz: 200
21252126
_debug: 0
21262127
_currentUpdateHz: 0
21272128
_currentFixedUpdateHz: 0
2128-
_imuId: my_imu
21292129
_angularNoise:
21302130
_mean: 0
21312131
_stdDev: 0.0002
@@ -2152,7 +2152,7 @@ Rigidbody:
21522152
m_Mass: 1
21532153
m_Drag: 0
21542154
m_AngularDrag: 0.05
2155-
m_UseGravity: 1
2155+
m_UseGravity: 0
21562156
m_IsKinematic: 0
21572157
m_Interpolate: 0
21582158
m_Constraints: 0
@@ -2169,7 +2169,7 @@ MonoBehaviour:
21692169
m_Script: {fileID: 11500000, guid: 6013e0556113f1e9f95189e724e765fc, type: 3}
21702170
m_Name:
21712171
m_EditorClassIdentifier:
2172-
_updateRateHz: 100
2172+
_updateRateHz: 10
21732173
_debug: 0
21742174
_currentUpdateHz: 0
21752175
_currentFixedUpdateHz: 0
@@ -2192,21 +2192,21 @@ Transform:
21922192
m_Father: {fileID: 0}
21932193
m_RootOrder: 7
21942194
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
2195-
--- !u!138 &1753787008
2196-
FixedJoint:
2195+
--- !u!114 &1753787008
2196+
MonoBehaviour:
21972197
m_ObjectHideFlags: 0
21982198
m_CorrespondingSourceObject: {fileID: 0}
21992199
m_PrefabInstance: {fileID: 0}
22002200
m_PrefabAsset: {fileID: 0}
22012201
m_GameObject: {fileID: 1753787002}
2202-
m_ConnectedBody: {fileID: 0}
2203-
m_ConnectedArticulationBody: {fileID: 0}
2204-
m_BreakForce: Infinity
2205-
m_BreakTorque: Infinity
2206-
m_EnableCollision: 0
2207-
m_EnablePreprocessing: 1
2208-
m_MassScale: 1
2209-
m_ConnectedMassScale: 1
2202+
m_Enabled: 1
2203+
m_EditorHideFlags: 0
2204+
m_Script: {fileID: 11500000, guid: 1ef77affe836d7c54adde928a35ad253, type: 3}
2205+
m_Name:
2206+
m_EditorClassIdentifier:
2207+
_minMax: {x: 0, y: 2}
2208+
_speed: 2
2209+
_moveType: 3
22102210
--- !u!1 &1764802517
22112211
GameObject:
22122212
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)