Skip to content

Commit c33247d

Browse files
authored
Merge pull request #145 from Field-Robotics-Japan/develop
Release new version
2 parents 655478c + 30c7854 commit c33247d

File tree

17 files changed

+289
-1708
lines changed

17 files changed

+289
-1708
lines changed

Assets/Test.unity

Lines changed: 0 additions & 1684 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &6658069106543365610
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
serializedVersion: 6
10+
m_Component:
11+
- component: {fileID: 6658069106543365612}
12+
- component: {fileID: 6658069106543365611}
13+
m_Layer: 0
14+
m_Name: GeoCoordinateSystem
15+
m_TagString: Untagged
16+
m_Icon: {fileID: 0}
17+
m_NavMeshLayer: 0
18+
m_StaticEditorFlags: 0
19+
m_IsActive: 1
20+
--- !u!4 &6658069106543365612
21+
Transform:
22+
m_ObjectHideFlags: 0
23+
m_CorrespondingSourceObject: {fileID: 0}
24+
m_PrefabInstance: {fileID: 0}
25+
m_PrefabAsset: {fileID: 0}
26+
m_GameObject: {fileID: 6658069106543365610}
27+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
28+
m_LocalPosition: {x: 0, y: 0, z: 0}
29+
m_LocalScale: {x: 1, y: 1, z: 1}
30+
m_ConstrainProportionsScale: 0
31+
m_Children: []
32+
m_Father: {fileID: 0}
33+
m_RootOrder: 0
34+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35+
--- !u!114 &6658069106543365611
36+
MonoBehaviour:
37+
m_ObjectHideFlags: 0
38+
m_CorrespondingSourceObject: {fileID: 0}
39+
m_PrefabInstance: {fileID: 0}
40+
m_PrefabAsset: {fileID: 0}
41+
m_GameObject: {fileID: 6658069106543365610}
42+
m_Enabled: 1
43+
m_EditorHideFlags: 0
44+
m_Script: {fileID: 11500000, guid: 5f2116b7f84275c4d877f9ac14990716, type: 3}
45+
m_Name:
46+
m_EditorClassIdentifier:
47+
_coordinate:
48+
latitude: 35.71020206575301
49+
longitude: 139.81070039691542
50+
altitude: 3

Assets/Test.unity.meta renamed to Assets/UnitySensors/Runtime/Prefabs/GNSS/GeoCoordinateSystem.prefab.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySensors/Runtime/Scripts/Sensors/GNSS/GNSSSensor.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace UnitySensors.Sensor.GNSS
1010
public class GNSSSensor : UnitySensor
1111
{
1212
[SerializeField]
13-
private GeoCoordinate _baseCoordinate = new GeoCoordinate(35.71020206575301, 139.81070039691542, 3.0f);
13+
private GeoCoordinateSystem _coordinateSystem;
1414

1515
private Transform _transform;
1616
private GeoCoordinateConverter _gcc;
@@ -22,16 +22,11 @@ public class GNSSSensor : UnitySensor
2222
protected override void Init()
2323
{
2424
_transform = this.transform;
25-
_gcc = new GeoCoordinateConverter(_baseCoordinate.latitude, _baseCoordinate.longitude);
26-
_coordinate = new GeoCoordinate(_baseCoordinate.latitude, _baseCoordinate.longitude, _baseCoordinate.altitude);
2725
}
2826

2927
protected override void UpdateSensor()
3028
{
31-
Vector3 position = _transform.position;
32-
(_coordinate.latitude, _coordinate.longitude) = _gcc.XZ2LatLon(position.x, position.z);
33-
_coordinate.altitude = _baseCoordinate.altitude + position.y;
34-
29+
_coordinate = _coordinateSystem.GetCoordinate(_transform.position);
3530
if (onSensorUpdated != null)
3631
onSensorUpdated.Invoke();
3732
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
using UnitySensors.Utils.GeoCoordinate;
6+
7+
namespace UnitySensors.Sensor.GNSS
8+
{
9+
public class GeoCoordinateSystem : MonoBehaviour
10+
{
11+
[SerializeField]
12+
private GeoCoordinate _coordinate = new GeoCoordinate(35.71020206575301, 139.81070039691542, 3.0f);
13+
14+
private Transform _transform;
15+
private GeoCoordinateConverter _converter;
16+
17+
private void Awake()
18+
{
19+
_transform = this.transform;
20+
_converter = new GeoCoordinateConverter(_coordinate.latitude, _coordinate.longitude);
21+
}
22+
23+
public GeoCoordinate GetCoordinate(Vector3 worldPosition)
24+
{
25+
Vector3 localPosition = _transform.InverseTransformPoint(worldPosition);
26+
double latitude, longitude;
27+
(latitude, longitude) = _converter.XZ2LatLon(localPosition.x, localPosition.z);
28+
return new GeoCoordinate(latitude, longitude, localPosition.y + _coordinate.altitude);
29+
}
30+
}
31+
}

Assets/UnitySensors/Runtime/Scripts/Sensors/GNSS/GeoCoordinateSystem.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/UnitySensors/Runtime/Scripts/Sensors/TF/TF.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public TFData[] GetTFData(string frame_id_parent, Matrix4x4 worldToLocalMatrix,
5555
tfData_self.frame_id_parent = frame_id_parent;
5656
tfData_self.frame_id_child = _frame_id;
5757
tfData_self.position = (Vector3)(worldToLocalMatrix * new Vector4(_transform.position.x, _transform.position.y, _transform.position.z, 1.0f));
58+
Vector3 localScale = _transform.localScale;
59+
Vector3 lossyScale = _transform.lossyScale;
60+
Vector3 scaleVector = new Vector3()
61+
{
62+
x = localScale.x != 0 ? lossyScale.x / localScale.x : 0,
63+
y = localScale.y != 0 ? lossyScale.y / localScale.y : 0,
64+
z = localScale.z != 0 ? lossyScale.z / localScale.z : 0
65+
};
66+
tfData_self.position.Scale(scaleVector);
5867
tfData_self.rotation = worldToLocalQuaternion * _transform.rotation;
5968
tfData.Add(tfData_self);
6069

Assets/UnitySensors/Runtime/Scripts/Utils/GeoCoordinates/GeoCoordinates.cs renamed to Assets/UnitySensors/Runtime/Scripts/Utils/GeoCoordinates/GeoCoordinate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace UnitySensors.Utils.GeoCoordinate
22
{
33
[System.Serializable]
4-
public class GeoCoordinate
4+
public struct GeoCoordinate
55
{
66
public GeoCoordinate(double lat, double lon, double alt)
77
{

Assets/UnitySensors/Samples/GNSS/Demo_GNSS.unity

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ NavMeshSettings:
123123
debug:
124124
m_Flags: 0
125125
m_NavMeshData: {fileID: 0}
126+
--- !u!114 &2054003459 stripped
127+
MonoBehaviour:
128+
m_CorrespondingSourceObject: {fileID: 6658069106543365611, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
129+
type: 3}
130+
m_PrefabInstance: {fileID: 6658069108059838184}
131+
m_PrefabAsset: {fileID: 0}
132+
m_GameObject: {fileID: 0}
133+
m_Enabled: 1
134+
m_EditorHideFlags: 0
135+
m_Script: {fileID: 11500000, guid: 5f2116b7f84275c4d877f9ac14990716, type: 3}
136+
m_Name:
137+
m_EditorClassIdentifier:
126138
--- !u!1001 &6460962622283155330
127139
PrefabInstance:
128140
m_ObjectHideFlags: 0
@@ -135,6 +147,11 @@ PrefabInstance:
135147
propertyPath: m_Name
136148
value: GNSS
137149
objectReference: {fileID: 0}
150+
- target: {fileID: 6460962621012238590, guid: a0db7cd58a019da4d84328d3f8cb748a,
151+
type: 3}
152+
propertyPath: _coordinateSystem
153+
value:
154+
objectReference: {fileID: 2054003459}
138155
- target: {fileID: 6460962621012238591, guid: a0db7cd58a019da4d84328d3f8cb748a,
139156
type: 3}
140157
propertyPath: m_RootOrder
@@ -192,3 +209,72 @@ PrefabInstance:
192209
objectReference: {fileID: 0}
193210
m_RemovedComponents: []
194211
m_SourcePrefab: {fileID: 100100000, guid: a0db7cd58a019da4d84328d3f8cb748a, type: 3}
212+
--- !u!1001 &6658069108059838184
213+
PrefabInstance:
214+
m_ObjectHideFlags: 0
215+
serializedVersion: 2
216+
m_Modification:
217+
m_TransformParent: {fileID: 0}
218+
m_Modifications:
219+
- target: {fileID: 6658069106543365610, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
220+
type: 3}
221+
propertyPath: m_Name
222+
value: GeoCoordinateSystem
223+
objectReference: {fileID: 0}
224+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
225+
type: 3}
226+
propertyPath: m_RootOrder
227+
value: 1
228+
objectReference: {fileID: 0}
229+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
230+
type: 3}
231+
propertyPath: m_LocalPosition.x
232+
value: 0
233+
objectReference: {fileID: 0}
234+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
235+
type: 3}
236+
propertyPath: m_LocalPosition.y
237+
value: 0
238+
objectReference: {fileID: 0}
239+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
240+
type: 3}
241+
propertyPath: m_LocalPosition.z
242+
value: 0
243+
objectReference: {fileID: 0}
244+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
245+
type: 3}
246+
propertyPath: m_LocalRotation.w
247+
value: 1
248+
objectReference: {fileID: 0}
249+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
250+
type: 3}
251+
propertyPath: m_LocalRotation.x
252+
value: 0
253+
objectReference: {fileID: 0}
254+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
255+
type: 3}
256+
propertyPath: m_LocalRotation.y
257+
value: 0
258+
objectReference: {fileID: 0}
259+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
260+
type: 3}
261+
propertyPath: m_LocalRotation.z
262+
value: 0
263+
objectReference: {fileID: 0}
264+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
265+
type: 3}
266+
propertyPath: m_LocalEulerAnglesHint.x
267+
value: 0
268+
objectReference: {fileID: 0}
269+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
270+
type: 3}
271+
propertyPath: m_LocalEulerAnglesHint.y
272+
value: 0
273+
objectReference: {fileID: 0}
274+
- target: {fileID: 6658069106543365612, guid: bfbdcabf0c3de544d92e2b824ec5a3a6,
275+
type: 3}
276+
propertyPath: m_LocalEulerAnglesHint.z
277+
value: 0
278+
objectReference: {fileID: 0}
279+
m_RemovedComponents: []
280+
m_SourcePrefab: {fileID: 100100000, guid: bfbdcabf0c3de544d92e2b824ec5a3a6, type: 3}

Assets/UnitySensors/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.frj.unity-sensors",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"displayName": "UnitySensors",
55
"description": "",
66
"unity": "2021.3",

Assets/UnitySensorsROS/Runtime/Prefabs/GNSS/GNSS_ros.prefab

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GameObject:
1010
m_Component:
1111
- component: {fileID: 3192925013080293983}
1212
- component: {fileID: 3192925013080293982}
13-
- component: {fileID: 3192925013080293981}
13+
- component: {fileID: 3192925012673096858}
1414
m_Layer: 0
1515
m_Name: GNSS_ros
1616
m_TagString: Untagged
@@ -46,15 +46,12 @@ MonoBehaviour:
4646
m_Name:
4747
m_EditorClassIdentifier:
4848
_frequency: 10
49-
_baseCoordinate:
50-
latitude: 35.71020206575301
51-
longitude: 139.81070039691542
52-
altitude: 3
49+
_coordinateSystem: {fileID: 0}
5350
_coordinate:
5451
latitude: 0
5552
longitude: 0
5653
altitude: 0
57-
--- !u!114 &3192925013080293981
54+
--- !u!114 &3192925012673096858
5855
MonoBehaviour:
5956
m_ObjectHideFlags: 0
6057
m_CorrespondingSourceObject: {fileID: 0}
@@ -63,13 +60,13 @@ MonoBehaviour:
6360
m_GameObject: {fileID: 3192925013080293980}
6461
m_Enabled: 1
6562
m_EditorHideFlags: 0
66-
m_Script: {fileID: 11500000, guid: 397c445553a6f3a40ac4d6892894ff7f, type: 3}
63+
m_Script: {fileID: 11500000, guid: c11ec5602b9e12544b78d1d2a4bdd5c6, type: 3}
6764
m_Name:
6865
m_EditorClassIdentifier:
6966
_frequency: 10
70-
_topicName: /navsat/fix
67+
_topicName: navsat
7168
_serializer:
7269
_header:
73-
_frame_id: /gnss_link
70+
_frame_id: map
7471
_status: 1
7572
_service: 0

0 commit comments

Comments
 (0)