-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 12b6391
Showing
4 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* Copyright (c) 2018 LG Electronics, Inc. | ||
* | ||
* This software contains code licensed as described in LICENSE. | ||
* | ||
*/ | ||
|
||
using Simulator.Bridge; | ||
using Simulator.Bridge.Data; | ||
using Simulator.Utilities; | ||
using UnityEngine; | ||
using Simulator.Sensors.UI; | ||
using System.Collections.Generic; | ||
using System.Collections; | ||
using Simulator.Analysis; | ||
|
||
namespace Simulator.Sensors | ||
{ | ||
[SensorType("GPS-INS Status", new[] { typeof(GpsInsData) })] | ||
public class GpsInsSensor : SensorBase | ||
{ | ||
[SensorParameter] | ||
[Range(1.0f, 100f)] | ||
public float Frequency = 12.5f; | ||
|
||
double NextSend; | ||
uint SendSequence; | ||
|
||
BridgeInstance Bridge; | ||
Publisher<GpsInsData> Publish; | ||
|
||
public override SensorDistributionType DistributionType => SensorDistributionType.LowLoad; | ||
|
||
public override void OnBridgeSetup(BridgeInstance bridge) | ||
{ | ||
Bridge = bridge; | ||
Publish = Bridge.AddPublisher<GpsInsData>(Topic); | ||
} | ||
|
||
public void Start() | ||
{ | ||
NextSend = SimulatorManager.Instance.CurrentTime + 1.0f / Frequency; | ||
} | ||
|
||
void Update() | ||
{ | ||
if (Bridge == null || Bridge.Status != Status.Connected) | ||
{ | ||
return; | ||
} | ||
|
||
if (SimulatorManager.Instance.CurrentTime < NextSend) | ||
{ | ||
return; | ||
} | ||
NextSend = SimulatorManager.Instance.CurrentTime + 1.0f / Frequency; | ||
|
||
Publish(new GpsInsData() | ||
{ | ||
Name = Name, | ||
Frame = Frame, | ||
Time = SimulatorManager.Instance.CurrentTime, | ||
Sequence = SendSequence++, | ||
|
||
Status = 3, | ||
PositionType = 56, | ||
}); | ||
} | ||
|
||
public override void OnVisualize(Visualizer visualizer) | ||
{ | ||
Debug.Assert(visualizer != null); | ||
|
||
var graphData = new Dictionary<string, object>() | ||
{ | ||
{"Status", 3}, | ||
{"Position Type", 56} | ||
}; | ||
visualizer.UpdateGraphValues(graphData); | ||
} | ||
|
||
public override void SetAnalysisData() | ||
{ | ||
SensorAnalysisData = new List<AnalysisReportItem> | ||
{ | ||
new AnalysisReportItem | ||
{ | ||
name = "Status", | ||
type = MeasurementType.Misc, | ||
value = 3 | ||
}, | ||
new AnalysisReportItem | ||
{ | ||
name = "Position Type", | ||
type = MeasurementType.Misc, | ||
value = 56 | ||
}, | ||
}; | ||
} | ||
|
||
public override void OnVisualizeToggle(bool state) | ||
{ | ||
// | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &6467730501547923967 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 7277557481913521809} | ||
- component: {fileID: 7715284868972390602} | ||
m_Layer: 0 | ||
m_Name: GpsInsSensor | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &7277557481913521809 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6467730501547923967} | ||
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_Children: [] | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||
--- !u!114 &7715284868972390602 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 6467730501547923967} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 4679da8ef90252f4e93b3f4cbd860ecb, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
Name: | ||
Topic: | ||
Frame: | ||
Frequency: 12.5 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.