Skip to content

Commit

Permalink
Fix velocity bug and possibly fix scan bug
Browse files Browse the repository at this point in the history
- Velocity bug is where the reported velocity was much lower than actual. Also, the control signal expected -1.0 to 1.0 when it should have been any range because it is a velocity based control.
- Scan bug is where scan does not always initalize correctly and sometimes does not output values. This is likely a race condition that was probably fixed in this commit.
  • Loading branch information
noahzemlin committed Feb 17, 2020
1 parent d552972 commit a48d552
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ limitations under the License.
*/

using UnityEngine;
using System.Collections;

namespace RosSharp.RosBridgeClient
{
Expand All @@ -29,7 +30,8 @@ public class LaserScanPublisher : UnityPublisher<MessageTypes.Sensor.LaserScan>
protected override void Start()
{
base.Start();
InitializeMessage();

StartCoroutine(InitializeMessage());
}

private void FixedUpdate()
Expand All @@ -41,8 +43,14 @@ private void FixedUpdate()
}
}

private void InitializeMessage()
private IEnumerator InitializeMessage()
{
// Attempt to fix possible race condition by waiting for laser scan reader?
while (!(laserScanReader))
{
yield return new WaitForSeconds(0.5f);
}

scanPeriod = (float)laserScanReader.samples / (float)laserScanReader.update_rate;

message = new MessageTypes.Sensor.LaserScan
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scenes/Menu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -0.0005493164}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &371560650
Expand Down Expand Up @@ -1268,7 +1268,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1377950902}
m_HandleRect: {fileID: 1377950901}
m_Direction: 2
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down
12 changes: 6 additions & 6 deletions Assets/Scripts/SimpleCarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public void FixedUpdate()
{

float psi = transform.rotation.eulerAngles.y * Mathf.Deg2Rad;
float left;
float right;
float left, right;

if (useController)
{
left = Mathf.Pow(Input.GetAxis("Vertical"), 3);
right = -Mathf.Pow(Input.GetAxis("Vertical2"), 3);
left = Mathf.Pow(Input.GetAxis("Vertical"), 3) * speedMod;
right = -Mathf.Pow(Input.GetAxis("Vertical2"), 3) * speedMod;
}
else
{
Expand All @@ -51,9 +51,9 @@ public void FixedUpdate()
float dot_x = (vr + (vl - vr) / 4.0f) * Mathf.Sin(psi);
float dot_y = (vr + (vl - vr) / 4.0f) * Mathf.Cos(psi);

transform.Translate(new Vector3(dot_x, 0, dot_y) * Time.deltaTime * speedMod, Space.World);
transform.Translate(new Vector3(dot_x, 0, dot_y) * Time.fixedDeltaTime, Space.World);

transform.Rotate(new Vector3(0, psi_dot * Mathf.Rad2Deg, 0) * Time.deltaTime * turnMod, Space.World);
transform.Rotate(new Vector3(0, psi_dot * Mathf.Rad2Deg, 0) * Time.fixedDeltaTime, Space.World);

}
}
Expand Down
2 changes: 1 addition & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.1.4",
"com.unity.test-framework": "1.1.9",
"com.unity.test-framework": "1.1.11",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.2.10",
"com.unity.ugui": "1.0.0",
Expand Down
59 changes: 40 additions & 19 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 18
serializedVersion: 20
productGUID: 36a539fc7dba8c041bafef7566190dad
AndroidProfiler: 0
AndroidFilterTouchesWhenObscured: 0
Expand Down Expand Up @@ -54,7 +54,6 @@ PlayerSettings:
m_StackTraceTypes: 010000000100000001000000010000000100000001000000
iosShowActivityIndicatorOnLoading: -1
androidShowActivityIndicatorOnLoading: -1
displayResolutionDialog: 1
iosUseCustomAppBackgroundBehavior: 0
iosAllowHTTPDownload: 1
allowedAutorotateToPortrait: 1
Expand Down Expand Up @@ -87,15 +86,13 @@ PlayerSettings:
useMacAppStoreValidation: 0
macAppStoreCategory: public.app-category.games
gpuSkinning: 1
graphicsJobs: 0
xboxPIXTextureCapture: 0
xboxEnableAvatar: 0
xboxEnableKinect: 0
xboxEnableKinectAutoTracking: 0
xboxEnableFitness: 0
visibleInBackground: 1
allowFullscreenSwitch: 1
graphicsJobMode: 0
fullscreenMode: 3
xboxSpeechDB: 0
xboxEnableHeadOrientation: 0
Expand All @@ -115,14 +112,15 @@ PlayerSettings:
switchNVNShaderPoolsGranularity: 33554432
switchNVNDefaultPoolsGranularity: 16777216
switchNVNOtherPoolsGranularity: 16777216
vulkanNumSwapchainBuffers: 3
vulkanEnableSetSRGBWrite: 0
m_SupportedAspectRatios:
4:3: 1
5:4: 1
16:10: 1
16:9: 1
Others: 1
bundleVersion: 11.0
bundleVersion: 14
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down Expand Up @@ -157,9 +155,9 @@ PlayerSettings:
v2Signing: 0
enable360StereoCapture: 0
isWsaHolographicRemotingEnabled: 0
protectGraphicsMemory: 0
enableFrameTimingStats: 0
useHDRDisplay: 0
D3DHDRBitDepth: 0
m_ColorGamuts: 00000000
targetPixelDensity: 30
resolutionScalingMode: 0
Expand All @@ -168,7 +166,7 @@ PlayerSettings:
applicationIdentifier: {}
buildNumber: {}
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 16
AndroidMinSdkVersion: 19
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
aotOptions:
Expand All @@ -183,10 +181,10 @@ PlayerSettings:
StripUnusedMeshComponents: 1
VertexChannelCompressionMask: 4054
iPhoneSdkVersion: 988
iOSTargetOSVersionString: 9.0
iOSTargetOSVersionString: 10.0
tvOSSdkVersion: 0
tvOSRequireExtendedGameController: 0
tvOSTargetOSVersionString: 9.0
tvOSTargetOSVersionString: 10.0
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIRequiresFullScreen: 1
Expand Down Expand Up @@ -276,7 +274,6 @@ PlayerSettings:
androidGamepadSupportLevel: 0
AndroidValidateAppBundleSize: 1
AndroidAppBundleSizeToValidate: 150
resolutionDialogBanner: {fileID: 0}
m_BuildTargetIcons:
- m_BuildTarget:
m_Icons:
Expand All @@ -302,6 +299,38 @@ PlayerSettings:
- m_BuildTarget: WebGL
m_StaticBatching: 0
m_DynamicBatching: 0
m_BuildTargetGraphicsJobs:
- m_BuildTarget: MacStandaloneSupport
m_GraphicsJobs: 0
- m_BuildTarget: Switch
m_GraphicsJobs: 0
- m_BuildTarget: MetroSupport
m_GraphicsJobs: 0
- m_BuildTarget: AppleTVSupport
m_GraphicsJobs: 0
- m_BuildTarget: BJMSupport
m_GraphicsJobs: 0
- m_BuildTarget: LinuxStandaloneSupport
m_GraphicsJobs: 0
- m_BuildTarget: PS4Player
m_GraphicsJobs: 0
- m_BuildTarget: iOSSupport
m_GraphicsJobs: 0
- m_BuildTarget: WindowsStandaloneSupport
m_GraphicsJobs: 0
- m_BuildTarget: XboxOnePlayer
m_GraphicsJobs: 0
- m_BuildTarget: LuminSupport
m_GraphicsJobs: 0
- m_BuildTarget: AndroidPlayer
m_GraphicsJobs: 0
- m_BuildTarget: WebGLSupport
m_GraphicsJobs: 0
m_BuildTargetGraphicsJobMode:
- m_BuildTarget: PS4Player
m_GraphicsJobMode: 0
- m_BuildTarget: XboxOnePlayer
m_GraphicsJobMode: 0
m_BuildTargetGraphicsAPIs:
- m_BuildTarget: AndroidPlayer
m_APIs: 150000000b000000
Expand All @@ -324,7 +353,6 @@ PlayerSettings:
openGLRequireES31: 0
openGLRequireES31AEP: 0
openGLRequireES32: 0
vuforiaEnabled: 0
m_TemplateCustomTags: {}
mobileMTRendering:
Android: 1
Expand Down Expand Up @@ -540,6 +568,7 @@ PlayerSettings:
ps4contentSearchFeaturesUsed: 0
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
ps4attribVROutputEnabled: 0
monoEnv:
splashScreenBackgroundSourceLandscape: {fileID: 0}
splashScreenBackgroundSourcePortrait: {fileID: 0}
Expand Down Expand Up @@ -625,7 +654,6 @@ PlayerSettings:
XboxOneAllowedProductIds: []
XboxOnePersistentLocalStorageSize: 0
XboxOneXTitleMemory: 8
xboxOneScriptCompiler: 1
XboxOneOverrideIdentityName:
vrEditorSettings:
daydream:
Expand All @@ -644,13 +672,6 @@ PlayerSettings:
luminVersion:
m_VersionCode: 1
m_VersionName:
facebookSdkVersion: 7.9.4
facebookAppId:
facebookCookies: 1
facebookLogging: 1
facebookStatus: 1
facebookXfbml: 0
facebookFrictionlessRequests: 1
apiCompatibilityLevel: 6
cloudProjectId:
framebufferDepthMemorylessMode: 0
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.3.0f6
m_EditorVersionWithRevision: 2019.3.0f6 (27ab2135bccf)
m_EditorVersion: 2019.3.1f1
m_EditorVersionWithRevision: 2019.3.1f1 (89d6087839c2)

0 comments on commit a48d552

Please sign in to comment.