Skip to content

Commit

Permalink
GPS Plugin added
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang committed Jun 29, 2020
1 parent f35f81c commit 887e42a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
51 changes: 51 additions & 0 deletions Assets/Scripts/CustomPlugins/GpsPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2020 LG Electronics Inc.
*
* SPDX-License-Identifier: MIT
*/

using UnityEngine;
using Stopwatch = System.Diagnostics.Stopwatch;

public class GpsPlugin : CustomPlugin
{
public string partName = string.Empty;

private SensorDevices.GPS gps = null;

protected override void OnAwake()
{
partName = DeviceHelper.GetPartName(gameObject);

string hashKey = MakeHashKey(partName);
if (!RegisterTxDevice(hashKey))
{
Debug.LogError("Failed to register for GpsPlugin - " + hashKey);
}
}

protected override void OnStart()
{
gps = gameObject.GetComponent<SensorDevices.GPS>();

AddThread(Sender);
}

private void Sender()
{
Stopwatch sw = new Stopwatch();
while (true)
{
if (gps == null)
{
continue;
}

var datastreamToSend = gps.PopData();
sw.Restart();
Publish(datastreamToSend);
sw.Stop();
gps.SetTransportTime((float)sw.Elapsed.TotalSeconds);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/CustomPlugins/GpsPlugin.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Assets/Scripts/Devices/GPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public partial class GPS : Device

void Awake()
{
// sensorVelocity = new Vector3();
gpsLink = transform.parent;
deviceName = name;

Expand Down

0 comments on commit 887e42a

Please sign in to comment.