Skip to content

Commit

Permalink
Added health to the robot. Capped robot acceleration and tweaked dyna…
Browse files Browse the repository at this point in the history
…mics.
  • Loading branch information
noahzemlin committed Apr 18, 2020
1 parent 01e4248 commit c43cd73
Show file tree
Hide file tree
Showing 18 changed files with 232 additions and 53 deletions.
8 changes: 0 additions & 8 deletions Unity/Assets/Graphics.meta

This file was deleted.

9 changes: 7 additions & 2 deletions Unity/Assets/Prefabs/CoronaObstacle.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GameObject:
- component: {fileID: 6420280404981083013}
m_Layer: 0
m_Name: CoronaObstacle
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
Expand Down Expand Up @@ -60,7 +60,7 @@ GameObject:
- component: {fileID: 7705045784659795140}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
Expand Down Expand Up @@ -213,6 +213,11 @@ PrefabInstance:
propertyPath: m_StaticEditorFlags
value: 4294967295
objectReference: {fileID: 0}
- target: {fileID: -927199367670048503, guid: 245cb1e3f7a32524aa3b4d54daf4357d,
type: 3}
propertyPath: m_TagString
value: Obstacle
objectReference: {fileID: 0}
- target: {fileID: 2534866581884222612, guid: 245cb1e3f7a32524aa3b4d54daf4357d,
type: 3}
propertyPath: m_StaticEditorFlags
Expand Down
4 changes: 2 additions & 2 deletions Unity/Assets/Prefabs/CylinderObstacle.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 235087896767986407}
m_Layer: 0
m_Name: CylinderObstacle
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
Expand Down Expand Up @@ -45,7 +45,7 @@ GameObject:
- component: {fileID: 3952956512997007577}
m_Layer: 0
m_Name: Cylinder
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
Expand Down
4 changes: 2 additions & 2 deletions Unity/Assets/Prefabs/SphereObstacle.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 3410795304565842202}
m_Layer: 0
m_Name: SphereObstacle
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
Expand Down Expand Up @@ -45,7 +45,7 @@ GameObject:
- component: {fileID: 5149887578041336147}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
Expand Down
4 changes: 2 additions & 2 deletions Unity/Assets/Prefabs/WallObstacle.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GameObject:
- component: {fileID: 3856744250248823490}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand Down Expand Up @@ -104,7 +104,7 @@ GameObject:
- component: {fileID: 235087896767986407}
m_Layer: 0
m_Name: WallObstacle
m_TagString: Untagged
m_TagString: Obstacle
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
Expand Down
30 changes: 21 additions & 9 deletions Unity/Assets/RosSharpModules/ControlSubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System.Threading;
using UnityEngine;

namespace RosSharp.RosBridgeClient.MessageTypes.swc_msgs
{
Expand All @@ -7,17 +8,26 @@ public class ControlSubscriber : UnitySubscriber<Control>
{
private AckermannController car;

private Control lastMessage;

private float angleNoiseStdDev = 0.4f;
private float powerNoiseStdDev = 0.1f;

private bool firstMessage = true;
private bool begingame = false;
private bool newMessage = false;
private float startTime = 100000;

protected override void Start()
{
if (ConfigLoader.simulator.ManualControl)
return;
base.Start();
car = GetComponent<AckermannController>();
lastMessage = new Control();
startTime = Time.realtimeSinceStartup;

if (ConfigLoader.simulator.ManualControl) {
this.enabled = false;
}

switch (ConfigLoader.competition.NoiseLevel) {
case ConfigLoader.CompetitionConfig.NoiseLevels.none:
Expand All @@ -30,10 +40,6 @@ protected override void Start()
break;
}

base.Start();
car = GetComponent<AckermannController>();
startTime = Time.realtimeSinceStartup;

if (!ConfigLoader.simulator.CompetitionMode) {
// Don't care about the stopsim stuff
begingame = false;
Expand All @@ -43,20 +49,26 @@ protected override void Start()
}

private void FixedUpdate() {
if (newMessage) {
car.SetControl(lastMessage.speed + SimUtils.getRandNormal(0, powerNoiseStdDev), lastMessage.turn_angle + SimUtils.getRandNormal(0, angleNoiseStdDev));
newMessage = false;
}

if (begingame)
{
begingame = false;
GameManager.instance.StartSim();
}

if (firstMessage && !begingame && Time.realtimeSinceStartup - startTime >= 30) {
GameManager.instance.StopSim("Did not start in 30 seconds!");
}
}

protected override void ReceiveMessage(Control control)
{
car.CntrlAngle = control.turn_angle + SimUtils.getRandNormal(0, angleNoiseStdDev);
car.CntrlPower = control.speed + SimUtils.getRandNormal(0, powerNoiseStdDev);
lastMessage = control;
newMessage = true;

if (firstMessage)
{
Expand Down
13 changes: 13 additions & 0 deletions Unity/Assets/Scenes/Loading.unity
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ GameObject:
- component: {fileID: 435357146}
- component: {fileID: 435357145}
- component: {fileID: 435357144}
- component: {fileID: 435357147}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
Expand Down Expand Up @@ -558,6 +559,18 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &435357147
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 435357143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a30d84b5887c8df45b0ffed826a200d4, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &477782510
GameObject:
m_ObjectHideFlags: 0
Expand Down
66 changes: 60 additions & 6 deletions Unity/Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ GameObject:
m_Component:
- component: {fileID: 829615085}
- component: {fileID: 829615086}
- component: {fileID: 829615088}
- component: {fileID: 829615087}
- component: {fileID: 829615089}
- component: {fileID: 829615090}
Expand All @@ -678,6 +677,8 @@ GameObject:
- component: {fileID: 829615091}
- component: {fileID: 829615093}
- component: {fileID: 829615094}
- component: {fileID: 829615088}
- component: {fileID: 829615098}
m_Layer: 0
m_Name: Robot
m_TagString: Untagged
Expand Down Expand Up @@ -726,8 +727,6 @@ MonoBehaviour:
frontAxleTf: {fileID: 360597449}
robotCamera: {fileID: 1822220454}
ManualTopSpeed: 1
CntrlAngle: 0
CntrlPower: 0
--- !u!114 &829615087
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -822,7 +821,7 @@ Rigidbody:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 829615084}
serializedVersion: 2
m_Mass: 2
m_Mass: 10
m_Drag: 0
m_AngularDrag: 0
m_UseGravity: 1
Expand Down Expand Up @@ -951,6 +950,18 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Topic: /sim/velocity
--- !u!114 &829615098
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 829615084}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b9e9655389f72214098993bf1e7e3a04, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &874833490
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1204,13 +1215,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 952696884}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0.3, y: 0.2, z: 0}
m_LocalScale: {x: 0.06, y: 0.015, z: 0.06}
m_Children: []
m_Father: {fileID: 829615085}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -1223,6 +1234,7 @@ GameObject:
- component: {fileID: 963194227}
- component: {fileID: 963194226}
- component: {fileID: 963194229}
- component: {fileID: 963194230}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
Expand Down Expand Up @@ -1308,6 +1320,18 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
speed: 0.1
--- !u!114 &963194230
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a30d84b5887c8df45b0ffed826a200d4, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1065359071
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1387,6 +1411,36 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1065359071}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1147577412
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1147577413}
m_Layer: 0
m_Name: blah
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1147577413
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1147577412}
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: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1340088700
GameObject:
m_ObjectHideFlags: 0
Expand Down
Loading

0 comments on commit c43cd73

Please sign in to comment.