mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 15:07:22 +02:00
Merge branch 'main' of https://git.uwaterloo.ca/capstone-group2/ui into main
This commit is contained in:
@@ -19,6 +19,12 @@ public class ControlLibrary : MonoBehaviour
|
|||||||
[DllImport("libc_control")]
|
[DllImport("libc_control")]
|
||||||
private static extern IntPtr get_configuration(out int module_id); // the data this points to will be invalidated when called again
|
private static extern IntPtr get_configuration(out int module_id); // the data this points to will be invalidated when called again
|
||||||
|
|
||||||
|
[DllImport("libc_control")]
|
||||||
|
public static extern int send_string_control(int module_id, string s);
|
||||||
|
|
||||||
|
[DllImport("libc_control")]
|
||||||
|
public static extern double get_distance_control(int module_id);
|
||||||
|
|
||||||
[DllImport("libc_control")]
|
[DllImport("libc_control")]
|
||||||
public static extern bool control_sentry_init(
|
public static extern bool control_sentry_init(
|
||||||
string dsn,
|
string dsn,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class DisplayModule : ModuleBase
|
public class DisplayModule : ModuleBase
|
||||||
{
|
{
|
||||||
@@ -17,5 +18,6 @@ public class DisplayModule : ModuleBase
|
|||||||
// Replace with actual hardware communication logic
|
// Replace with actual hardware communication logic
|
||||||
Debug.Log($"[DisplayModule] Sending display text: {text}");
|
Debug.Log($"[DisplayModule] Sending display text: {text}");
|
||||||
// Example: ControlLibrary.send_display_text(Int32.Parse(moduleID), text);
|
// Example: ControlLibrary.send_display_text(Int32.Parse(moduleID), text);
|
||||||
|
ControlLibrary.send_string_control(Int32.Parse(moduleID), text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
public class DistanceSensorModule : ModuleBase
|
public class DistanceSensorModule : ModuleBase
|
||||||
{
|
{
|
||||||
public bool objectDetected;
|
// Keep a fixed-size array (no GC alloc every frame)
|
||||||
public float distanceMeters;
|
public string[] infoLines = new string[2];
|
||||||
public string[] infoLines = new string[0];
|
|
||||||
public override string moduleType => "Distance";
|
public override string moduleType => "Distance";
|
||||||
public override string moduleName => "Distance Sensor Module";
|
public override string moduleName => "Distance Sensor Module";
|
||||||
|
|
||||||
|
// Optional: slow down polling to avoid spamming hardware
|
||||||
|
[SerializeField] float pollHz = 10f;
|
||||||
|
float nextPollTime;
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
// Replace with your ControlLibrary call pattern
|
// Always show something immediately
|
||||||
// var reading = ControlLibrary.get_distance(...)
|
infoLines[0] = $"ModuleID raw: '{moduleID}'";
|
||||||
|
|
||||||
if (!objectDetected)
|
// Poll at a fixed rate (avoids frame spam)
|
||||||
infoLines = new[] {"Object: Not detected" };
|
if (Time.unscaledTime < nextPollTime) return;
|
||||||
else
|
nextPollTime = Time.unscaledTime + (1f / Mathf.Max(1f, pollHz));
|
||||||
infoLines = new[] { "Object: Detected", $"Distance: {distanceMeters:F2} m" };
|
|
||||||
|
if (!int.TryParse(moduleID, out var id))
|
||||||
|
{
|
||||||
|
infoLines[1] = "ERROR: moduleID is not an int";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Control library call
|
||||||
|
double distance = ControlLibrary.get_distance_control(id);
|
||||||
|
|
||||||
|
infoLines[1] = $"Distance: {distance:F0} mm";
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// SHOW THE PROBLEM ON SCREEN (works in release builds)
|
||||||
|
infoLines[1] = $"EXCEPTION: {e.GetType().Name}: {e.Message}";
|
||||||
|
|
||||||
|
// Also log to Player.log (works in builds)
|
||||||
|
Debug.LogException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetInfoLines() => infoLines;
|
public string[] GetInfoLines() => infoLines;
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: e4735e9a5ae30490bba1dc35e4603bce, type: 3}
|
m_Script: {fileID: 11500000, guid: e4735e9a5ae30490bba1dc35e4603bce, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: '::'
|
m_EditorClassIdentifier: '::'
|
||||||
objectDetected: 0
|
infoLines:
|
||||||
distanceMeters: 0
|
-
|
||||||
infoLines: []
|
-
|
||||||
|
pollHz: 10
|
||||||
--- !u!1 &5041994602013865196
|
--- !u!1 &5041994602013865196
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -713,24 +713,11 @@ PrefabInstance:
|
|||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
m_AddedComponents: []
|
m_AddedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 8f54eee4d6fe643ba98e080c86deb5d1, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 8f54eee4d6fe643ba98e080c86deb5d1, type: 3}
|
||||||
--- !u!1 &119477699
|
--- !u!1 &119477699 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 2070925441746177671, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
m_CorrespondingSourceObject: {fileID: 2070925441746177671, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
||||||
m_PrefabInstance: {fileID: 507316325}
|
m_PrefabInstance: {fileID: 507316325}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 119477707}
|
|
||||||
- component: {fileID: 119477706}
|
|
||||||
- component: {fileID: 119477705}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: PlayerFollowCamera
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 0
|
|
||||||
--- !u!114 &119477705
|
--- !u!114 &119477705
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -747,61 +734,6 @@ MonoBehaviour:
|
|||||||
cameraController: {fileID: 0}
|
cameraController: {fileID: 0}
|
||||||
focusCameraOnSelection: 1
|
focusCameraOnSelection: 1
|
||||||
inverseKinematicsViewRoot: {fileID: 0}
|
inverseKinematicsViewRoot: {fileID: 0}
|
||||||
--- !u!114 &119477706
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 2070925441746177913, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 507316325}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 119477699}
|
|
||||||
m_Enabled: 0
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 45e653bab7fb20e499bda25e1b646fea, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_ExcludedPropertiesInInspector:
|
|
||||||
- m_Script
|
|
||||||
m_LockStageInInspector:
|
|
||||||
m_StreamingVersion: 20170927
|
|
||||||
m_Priority: 10
|
|
||||||
m_StandbyUpdate: 2
|
|
||||||
m_LookAt: {fileID: 0}
|
|
||||||
m_Follow: {fileID: 0}
|
|
||||||
m_Lens:
|
|
||||||
FieldOfView: 40
|
|
||||||
OrthographicSize: 10
|
|
||||||
NearClipPlane: 0.2
|
|
||||||
FarClipPlane: 500
|
|
||||||
Dutch: 0
|
|
||||||
ModeOverride: 0
|
|
||||||
LensShift: {x: 0, y: 0}
|
|
||||||
GateFit: 2
|
|
||||||
FocusDistance: 10
|
|
||||||
m_SensorSize: {x: 1, y: 1}
|
|
||||||
m_Transitions:
|
|
||||||
m_BlendHint: 0
|
|
||||||
m_InheritPosition: 0
|
|
||||||
m_OnCameraLive:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
m_LegacyBlendHint: 0
|
|
||||||
m_ComponentOwner: {fileID: 1135363932}
|
|
||||||
--- !u!4 &119477707
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 2070925441746177912, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 507316325}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 119477699}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0.022258926, y: -0.6409151, z: 0.018598305, w: 0.7670636}
|
|
||||||
m_LocalPosition: {x: 628.26337, y: 0.588705, z: 925.5157}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children:
|
|
||||||
- {fileID: 1135363932}
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &131686076
|
--- !u!1 &131686076
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -8693,10 +8625,10 @@ MonoBehaviour:
|
|||||||
handCursor: {fileID: 0}
|
handCursor: {fileID: 0}
|
||||||
eyeCursor: {fileID: 0}
|
eyeCursor: {fileID: 0}
|
||||||
cursorHotspot: {x: 0, y: 0}
|
cursorHotspot: {x: 0, y: 0}
|
||||||
panSpeed: 3.5
|
panSpeed: 10
|
||||||
zoomSpeed: 10
|
zoomSpeed: 10
|
||||||
moveSmoothTime: 0.12
|
moveSmoothTime: 0.12
|
||||||
orbitSpeed: 20
|
orbitSpeed: 5
|
||||||
minPitch: -80
|
minPitch: -80
|
||||||
maxPitch: 80
|
maxPitch: 80
|
||||||
orbitSmoothTime: 0.08
|
orbitSmoothTime: 0.08
|
||||||
@@ -10125,26 +10057,11 @@ CanvasRenderer:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1133813083}
|
m_GameObject: {fileID: 1133813083}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1135363928
|
--- !u!1 &1135363928 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 2070925442191277755, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
m_CorrespondingSourceObject: {fileID: 2070925442191277755, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
||||||
m_PrefabInstance: {fileID: 507316325}
|
m_PrefabInstance: {fileID: 507316325}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1135363932}
|
|
||||||
- component: {fileID: 1135363934}
|
|
||||||
- component: {fileID: 1135363933}
|
|
||||||
- component: {fileID: 1135363931}
|
|
||||||
- component: {fileID: 1135363930}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: cm
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &1135363930
|
--- !u!114 &1135363930
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 3
|
m_ObjectHideFlags: 3
|
||||||
@@ -10194,50 +10111,6 @@ MonoBehaviour:
|
|||||||
m_YawDamping: 0
|
m_YawDamping: 0
|
||||||
m_RollDamping: 0
|
m_RollDamping: 0
|
||||||
m_AngularDamping: 0
|
m_AngularDamping: 0
|
||||||
--- !u!4 &1135363932
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 2070925442191277756, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 507316325}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1135363928}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 119477707}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &1135363933
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 2070925442191277753, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 507316325}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1135363928}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 68bb026fafb42b14791938953eaace77, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_NoiseProfile: {fileID: 11400000, guid: 46965f9cbaf525742a6da4c2172a99cd, type: 2}
|
|
||||||
m_PivotOffset: {x: 0, y: 0, z: 1}
|
|
||||||
m_AmplitudeGain: 0.5
|
|
||||||
m_FrequencyGain: 0.3
|
|
||||||
mNoiseOffsets: {x: -451.37964, y: 684.7062, z: 648.0488}
|
|
||||||
--- !u!114 &1135363934
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 2070925442191277757, guid: a1a802ecaf6775746bb2a929fb554ad8, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 507316325}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1135363928}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!1 &1140898551
|
--- !u!1 &1140898551
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user