fix some robotics scripts

feat/dark_sim
Leushina Vlada 4 weeks ago
parent 5c541b051c
commit 41373270b5

@ -1 +1 @@
Subproject commit 3163d782ca8788cae899a3ca280d9806e6de701b Subproject commit d2d59f891fa3d1c39299464dc165b2427a9b8995

@ -8560,9 +8560,9 @@ ArticulationBody:
target: 0 target: 0
targetVelocity: 0 targetVelocity: 0
driveType: 0 driveType: 0
m_LinearDamping: 0.05 m_LinearDamping: 0
m_AngularDamping: 0.05 m_AngularDamping: 0
m_JointFriction: 0.05 m_JointFriction: 0
m_CenterOfMass: {x: 0, y: 0, z: 0} m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1} m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
@ -86722,7 +86722,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 792546717} - component: {fileID: 792546717}
- component: {fileID: 792546718} - component: {fileID: 792546719}
m_Layer: 0 m_Layer: 0
m_Name: sirius_bot m_Name: sirius_bot
m_TagString: UtilityObj m_TagString: UtilityObj
@ -86745,7 +86745,7 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 357998453} m_Father: {fileID: 357998453}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &792546718 --- !u!114 &792546719
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -86754,19 +86754,23 @@ MonoBehaviour:
m_GameObject: {fileID: 792546716} m_GameObject: {fileID: 792546716}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 46757fd7e9d69626c8827a94cbb3965a, type: 3} m_Script: {fileID: 11500000, guid: 713fd61d8164fc73596a3b02b4cde489, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
front_left_wheel: {fileID: 1349958476} _wheelList:
front_right_wheel: {fileID: 2082835350} - name: front_left_wheel
back_left_wheel: {fileID: 1160352884} obj: {fileID: 1349958476}
back_right_wheel: {fileID: 814849843} - name: front_right_wheel
maxLinearSpeed: 3 obj: {fileID: 2082835350}
maxRotationalSpeed: 2 - name: back_left_wheel
wheelRadius: 0.22 obj: {fileID: 1160352884}
trackWidth: 0.47 - name: back_right_wheel
obj: {fileID: 814849843}
_robotBody: {fileID: 915175386}
maxLinearSpeed: 10
maxAngularSpeed: 2
_frequency: 1 _frequency: 1
use_namespace: 0 useNamespace: 1
--- !u!1001 &794370220 --- !u!1001 &794370220
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -89411,7 +89415,7 @@ ArticulationBody:
m_GameObject: {fileID: 814849839} m_GameObject: {fileID: 814849839}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 6 serializedVersion: 6
m_Mass: 5 m_Mass: 3
m_ParentAnchorPosition: {x: 0.27999878, y: -0.13500002, z: -0.3} m_ParentAnchorPosition: {x: 0.27999878, y: -0.13500002, z: -0.3}
m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1}
m_AnchorPosition: {x: 0, y: 0, z: 0} m_AnchorPosition: {x: 0, y: 0, z: 0}
@ -100888,7 +100892,7 @@ ArticulationBody:
m_GameObject: {fileID: 915175385} m_GameObject: {fileID: 915175385}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 6 serializedVersion: 6
m_Mass: 10 m_Mass: 1
m_ParentAnchorPosition: {x: 0, y: 0, z: 0} m_ParentAnchorPosition: {x: 0, y: 0, z: 0}
m_ParentAnchorRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068} m_ParentAnchorRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068}
m_AnchorPosition: {x: 0, y: 0, z: 0} m_AnchorPosition: {x: 0, y: 0, z: 0}
@ -100928,8 +100932,8 @@ ArticulationBody:
target: 0 target: 0
targetVelocity: 0 targetVelocity: 0
driveType: 0 driveType: 0
m_LinearDamping: 0.05 m_LinearDamping: 0
m_AngularDamping: 0.05 m_AngularDamping: 0
m_JointFriction: 0.05 m_JointFriction: 0.05
m_CenterOfMass: {x: -0, y: 0, z: 0} m_CenterOfMass: {x: -0, y: 0, z: 0}
m_InertiaTensor: {x: 0.56666666, y: 0.78, z: 0.37466666} m_InertiaTensor: {x: 0.56666666, y: 0.78, z: 0.37466666}
@ -128824,7 +128828,7 @@ ArticulationBody:
m_GameObject: {fileID: 1160352880} m_GameObject: {fileID: 1160352880}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 6 serializedVersion: 6
m_Mass: 5 m_Mass: 3
m_ParentAnchorPosition: {x: -0.27999878, y: -0.13500002, z: -0.3} m_ParentAnchorPosition: {x: -0.27999878, y: -0.13500002, z: -0.3}
m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1}
m_AnchorPosition: {x: 0, y: 0, z: 0} m_AnchorPosition: {x: 0, y: 0, z: 0}
@ -149749,7 +149753,7 @@ ArticulationBody:
m_GameObject: {fileID: 1349958472} m_GameObject: {fileID: 1349958472}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 6 serializedVersion: 6
m_Mass: 5 m_Mass: 3
m_ParentAnchorPosition: {x: -0.27999878, y: -0.13500002, z: 0.3} m_ParentAnchorPosition: {x: -0.27999878, y: -0.13500002, z: 0.3}
m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1}
m_AnchorPosition: {x: 0, y: 0, z: 0} m_AnchorPosition: {x: 0, y: 0, z: 0}
@ -180431,9 +180435,9 @@ ArticulationBody:
target: 0 target: 0
targetVelocity: 0 targetVelocity: 0
driveType: 0 driveType: 0
m_LinearDamping: 0.05 m_LinearDamping: 0
m_AngularDamping: 0.05 m_AngularDamping: 0
m_JointFriction: 0.05 m_JointFriction: 0
m_CenterOfMass: {x: 0, y: 0, z: 0} m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1} m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
@ -227282,7 +227286,7 @@ ArticulationBody:
m_GameObject: {fileID: 2082835346} m_GameObject: {fileID: 2082835346}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 6 serializedVersion: 6
m_Mass: 5 m_Mass: 3
m_ParentAnchorPosition: {x: 0.27999878, y: -0.13500002, z: 0.3} m_ParentAnchorPosition: {x: 0.27999878, y: -0.13500002, z: 0.3}
m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1}
m_AnchorPosition: {x: 0, y: 0, z: 0} m_AnchorPosition: {x: 0, y: 0, z: 0}

@ -1,57 +0,0 @@
using UnityEngine;
public class ResetPosition : MonoBehaviour
{
[SerializeField] private Terrain currentTerrain;
[SerializeField] private LayerMask _terrainLayer = 1 << 0;
[SerializeField] private float _groundOffset = 1.0f; // m, shift during raycast to stick robot to the ground
public bool startRotation = false;
private Vector3 targetEuler, targetPosition;
private Quaternion targetRotation;
private Vector3 terrainPosition, terrainNormal;
private float normalizedX, normalizedZ;
private Vector3 faceDirection;
private ArticulationBody body;
// draw ray and spawn object little up
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
body = GetComponent<ArticulationBody>();
}
void FixedUpdate() {
if (startRotation)
{
FixPosition();
}
}
void FixPosition()
{
terrainPosition = transform.position - currentTerrain.transform.position;
normalizedX = Mathf.InverseLerp(0, currentTerrain.terrainData.size.x, terrainPosition.x);
normalizedX = Mathf.Clamp01(normalizedX);
normalizedZ = Mathf.InverseLerp(0, currentTerrain.terrainData.size.z, terrainPosition.z);
normalizedZ = Mathf.Clamp01(normalizedZ);
terrainNormal = currentTerrain.terrainData.GetInterpolatedNormal(normalizedX, normalizedZ);
faceDirection = Vector3.Cross(terrainNormal, -transform.right);
Quaternion predictedRot = Quaternion.LookRotation(faceDirection, terrainNormal);
targetEuler = predictedRot.eulerAngles;
targetEuler.y = transform.rotation.eulerAngles.y;
targetRotation = Quaternion.Euler(targetEuler);
targetPosition = new Vector3(
transform.position.x,
transform.position.y + _groundOffset,
transform.position.z);
body.TeleportRoot(targetPosition, targetRotation);
startRotation = false;
}
}

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 4b9c4dfebd00ecd8aaf8dbf69d9248e2
Loading…
Cancel
Save