Skip to content

Commit

Permalink
Merge from 'develop' into 'main' for CLOiSim-4.6.0 (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang authored Jul 1, 2024
2 parents 5aa7e67 + f0294f6 commit 25e955e
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ MonoBehaviour:
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 512
m_AdditionalLightsRenderingMode: 1
m_MainLightShadowmapResolution: 2048
m_AdditionalLightsRenderingMode: 0
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 1
m_AdditionalLightsShadowmapResolution: 256
Expand All @@ -46,7 +46,7 @@ MonoBehaviour:
m_AdditionalLightsShadowResolutionTierHigh: 256
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 100
m_ShadowDistance: 50
m_ShadowCascadeCount: 4
m_Cascade2Split: 0.25
m_Cascade3Split: {x: 0.1, y: 0.3}
Expand All @@ -59,7 +59,7 @@ MonoBehaviour:
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 2048
m_AdditionalLightsCookieResolution: 1024
m_AdditionalLightsCookieFormat: 3
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 1
Expand Down
1 change: 1 addition & 0 deletions Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,7 @@ MonoBehaviour:
- ../world_resources/bluepearl/models
- ../world_resources/lawn_ground/models
- ../world_resources/seocho_tower/models
- ../world_resources/app.gazebosim.org
worldRootDirectories:
- ../sample_resources/worlds/
- ../world_resources/bluepearl/worlds
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/CLOiSimPlugins/Messages/gps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public double VelocityUp
public void ResetVelocityUp() => __pbn__VelocityUp = null;
private double? __pbn__VelocityUp;

[global::ProtoBuf.ProtoMember(9, Name = @"heading")]
public Imu Heading { get; set; }

}

}
Expand Down
99 changes: 55 additions & 44 deletions Assets/Scripts/Core/Modules/SphericalCoordinates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ public class WGS84
public const double EarthFlattening = 1d / 298.257223563d;
}

public enum SurfaceType { EARTH_WGS84 };
public enum SurfaceType
{
// Model of reference ellipsoid for earth, based on WGS 84 standard.
// see wikipedia: World_Geodetic_System
EARTH_WGS84 = 1,

// Model of the moon, based on the Selenographic coordinate system,
// see wikipedia: Selenographic Coordinate System.
MOON_SCS = 2
};

public enum CoordinateType
{
Expand Down Expand Up @@ -63,12 +72,38 @@ public enum CoordinateType

private SurfaceType surfaceType;

private double latitudeReference = 0; // in radian
private double longitudeReference = 0; // in radian
private double elevationReference = 0; // in meters
private double headingOffset = 0; // in radian
private double _latitudeReference = 0; // in radian
private double _longitudeReference = 0; // in radian
private double _elevationReference = 0; // in meters
private double _heading = 0; // in radian

private double _headingOrientationOffset = 0; // in degree

public void SetLatitudeReference(in double angle)
{
_latitudeReference = angle * Mathf.Deg2Rad;
UpdateTransformation();
}

public void SetLongitudeReference(in double angle)
{
_longitudeReference = angle * Mathf.Deg2Rad;
UpdateTransformation();
}

public void SetElevationReference(in double elevation)
{
_elevationReference = elevation;
UpdateTransformation();
}

public void SetHeadingOffset(in double angle)
{
_heading = (angle + _headingOrientationOffset) * Mathf.Deg2Rad;
UpdateTransformation();
}

private double haedingOrientationOffset = 0; // in degree
public float HeadingAngle => (float)(_heading * Mathf.Rad2Deg - _headingOrientationOffset);

void Awake()
{
Expand All @@ -80,10 +115,10 @@ void Awake()
private void UpdateTransformation()
{
// Cache trig results
var cosLat = Math.Cos(latitudeReference);
var sinLat = Math.Sin(latitudeReference);
var cosLon = Math.Cos(longitudeReference);
var sinLon = Math.Sin(longitudeReference);
var cosLat = Math.Cos(_latitudeReference);
var sinLat = Math.Sin(_latitudeReference);
var cosLon = Math.Cos(_longitudeReference);
var sinLon = Math.Sin(_longitudeReference);

// Create a rotation matrix that moves ECEF to GLOBAL
// Transformations_between_ECEF_and_ENU_coordinates
Expand Down Expand Up @@ -119,11 +154,11 @@ private void UpdateTransformation()
// -- note that we have to negate the heading in order to preserve backward compatibility.
// ie. Gazebo has traditionally expressed positive angle as a CLOCKWISE rotation that takes the GLOBAL
// frame to the LOCAL frame. However, right hand coordinate systems require this to be expressed as an ANTI-CLOCKWISE rotation. So, we negate it.
cosHea = Math.Cos(-headingOffset);
sinHea = Math.Sin(-headingOffset);
cosHea = Math.Cos(-_heading);
sinHea = Math.Sin(-_heading);

// Cache the ECEF coordinate of the origin
origin.Set(latitudeReference, longitudeReference, elevationReference);
origin.Set(_latitudeReference, _longitudeReference, _elevationReference);
origin = PositionTransform(origin, CoordinateType.SPHERICAL, CoordinateType.ECEF);
}

Expand All @@ -134,18 +169,18 @@ public void SetWorldOrientation(in string orientation)
switch (orientation)
{
case "NWU":
haedingOrientationOffset = 0;
_headingOrientationOffset = 0;
break;

case "NED":
Debug.LogWarning("need to check NED orientaion");
haedingOrientationOffset = 0;
_headingOrientationOffset = 0;
break;

case "ENU":
case "":
default:
haedingOrientationOffset = -90;
_headingOrientationOffset = -90;
break;
}
}
Expand Down Expand Up @@ -379,10 +414,10 @@ private Vector3d VelocityTransform(in Vector3d velocity, in CoordinateType input
public void SetCoordinatesReference(in double latitudeAngle, in double longitudeAngle, in double elevation, in double headingAngle)
{
// Set the coordinate transform parameters in degree
latitudeReference = latitudeAngle * Mathf.Deg2Rad;
longitudeReference = longitudeAngle * Mathf.Deg2Rad;
elevationReference = elevation;
headingOffset = (headingAngle + haedingOrientationOffset) * Mathf.Deg2Rad;
_latitudeReference = latitudeAngle * Mathf.Deg2Rad;
_longitudeReference = longitudeAngle * Mathf.Deg2Rad;
_elevationReference = elevation;
_heading = (headingAngle + _headingOrientationOffset) * Mathf.Deg2Rad;

UpdateTransformation();
}
Expand Down Expand Up @@ -422,28 +457,4 @@ public Vector3d LocalFromGlobal(in Vector3 xyz)
{
return VelocityTransform(xyz, CoordinateType.GLOBAL, CoordinateType.LOCAL);
}

public void SetLatitudeReference(in double angle)
{
latitudeReference = angle * Mathf.Deg2Rad;
UpdateTransformation();
}

public void SetLongitudeReference(in double angle)
{
longitudeReference = angle * Mathf.Deg2Rad;
UpdateTransformation();
}

public void SetElevationReference(in double elevation)
{
elevationReference = elevation;
UpdateTransformation();
}

public void SetHeadingOffset(in double angle)
{
headingOffset = (angle + haedingOrientationOffset) * Mathf.Deg2Rad;
UpdateTransformation();
}
}
Loading

0 comments on commit 25e955e

Please sign in to comment.