Skip to content
Snippets Groups Projects
Commit 5dec8be7 authored by SK's avatar SK
Browse files

Finish adjusting simulation to changed files

for testing, add runtimecommandfactory to scene
parent 3eda39d8
No related branches found
No related tags found
No related merge requests found
......@@ -204,6 +204,11 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3638271986234392477, guid: bf8e3cbd745336648bd2f934ed57ca73,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: -0.7921938
objectReference: {fileID: 0}
- target: {fileID: 4210807086003635631, guid: bf8e3cbd745336648bd2f934ed57ca73,
type: 3}
propertyPath: m_Name
......
......@@ -890,7 +890,7 @@ HingeJoint:
m_Anchor: {x: 0, y: 0, z: 0}
m_Axis: {x: 0, y: -1, z: 0}
m_AutoConfigureConnectedAnchor: 1
m_ConnectedAnchor: {x: 1.2071272, y: -1.3262701, z: -0.79219365}
m_ConnectedAnchor: {x: 1.2071272, y: -1.3262701, z: -0.7921938}
m_UseSpring: 0
m_Spring:
spring: 0
......@@ -1491,6 +1491,7 @@ GameObject:
m_Component:
- component: {fileID: 879489888396195772}
- component: {fileID: 4210807086003635628}
- component: {fileID: 3367204457853155817}
- component: {fileID: 4210807086003635629}
- component: {fileID: 4210807086003635630}
m_Layer: 0
......@@ -1550,6 +1551,19 @@ MonoBehaviour:
avoidanceDistance: 0.2
robotHeight: 0
state: 7
--- !u!114 &3367204457853155817
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4210807086003635631}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ca9fc5f4bcbce3b4abfccb08e82b7f27, type: 3}
m_Name:
m_EditorClassIdentifier:
movementController: {fileID: 4210807086003635628}
--- !u!54 &4210807086003635629
Rigidbody:
m_ObjectHideFlags: 0
......
......@@ -23,7 +23,10 @@ public class SimulationCommunicator : MonoBehaviour
public void simulate()
{
List<RuntimeCommand> commands = programStore.getCommands();
//List<RuntimeCommand> commands = programStore.getCommands();
//////FOR TESTING//////////////////////////////////////////////////////
List<RuntimeCommand> commands = FindObjectOfType<RuntimeCommandFactory>().createSampleProgram();
////////////////////////////////////////////////////////////////////////////////////
List <MovementController.states> stateList = new List<MovementController.states>();
List<Vector3> values = new List<Vector3>();
......@@ -34,14 +37,10 @@ public class SimulationCommunicator : MonoBehaviour
{
if (command.command.Lcommand == LegoCommand.MOVE)
{
stateList.Add(MovementController.states.MOVE);
values.Add(this.fixRotation((Vector3)command.arguments[0]));
stateList.Add(MovementController.states.BRUTEMOVE); //because the legoCommand MOVE command is the simulation command BRUTEMOVE
Vector2 goal = (Vector2)command.arguments[0];
values.Add(this.fixRotation(new Vector3(goal.x, 0, goal.y)));
}
/*else if (command.command.Lcommand == LegoCommand.BRUTEMOVE)
{
stateList.Add(MovementController.states.BRUTEMOVE);
values.Add(this.fixRotation(command.arguments[0]));
}*/
else if (command.command.Lcommand == LegoCommand.CLAW_UP)
{
stateList.Add(MovementController.states.RELEASE);
......
......@@ -12,9 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d3e54a85d75d4e340bc966d6d511dcde, type: 3}
m_Name: ClawDown
m_EditorClassIdentifier:
isLegoCommand: 0
isLegoCommand: 1
Lcommand: 3
isDobotCommand: 0
Dcommand: 0
name:
ArgumentTypes: []
Signature: {fileID: 0}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RuntimeCommandFactory : MonoBehaviour
{
public SPEAREDCommand moveSPEAREDCommand;
public SPEAREDCommand clawUpSPEAREDCommand;
public SPEAREDCommand clawDownSPEAREDCommand;
public RuntimeCommandFactory()
{
}
public RuntimeCommand createMovementCommand(Vector2 positions)
{
RuntimeCommand runtimeCommand = ScriptableObject.CreateInstance<RuntimeCommand>();
runtimeCommand.command = moveSPEAREDCommand;
runtimeCommand.arguments = new List<object>{positions};
return runtimeCommand;
}
public RuntimeCommand createClawUpCommand()
{
RuntimeCommand runtimeCommand = ScriptableObject.CreateInstance<RuntimeCommand>();
runtimeCommand.command = clawUpSPEAREDCommand;
return runtimeCommand;
}
public RuntimeCommand createClawDownCommand()
{
RuntimeCommand runtimeCommand = ScriptableObject.CreateInstance<RuntimeCommand>();
runtimeCommand.command = clawDownSPEAREDCommand;
return runtimeCommand;
}
public List<RuntimeCommand> createSampleProgram()
{
List<RuntimeCommand> commands = new List<RuntimeCommand>();
commands.Add(this.createClawUpCommand());
commands.Add(this.createMovementCommand(new Vector2(0.6f, 0)));
commands.Add(this.createClawDownCommand());
commands.Add(this.createMovementCommand(new Vector2(1.1f, 0)));
commands.Add(this.createClawUpCommand());
commands.Add(this.createMovementCommand(new Vector2(0.9f, 0.4f)));
return commands;
}
}
fileFormatVersion: 2
guid: 613d3293a6363aa488fc8e0c001cf179
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3912279855018272371
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3912279855018272369}
- component: {fileID: 3912279855018272370}
m_Layer: 0
m_Name: RuntimeCommandFactory
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3912279855018272369
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3912279855018272371}
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 &3912279855018272370
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3912279855018272371}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 613d3293a6363aa488fc8e0c001cf179, type: 3}
m_Name:
m_EditorClassIdentifier:
moveSPEAREDCommand: {fileID: 11400000, guid: 04d17c138bd6cf04e8e71e643f53b024, type: 2}
clawUpSPEAREDCommand: {fileID: 11400000, guid: 566f61427c3ddd442a1f0a910a1d4007,
type: 2}
clawDownSPEAREDCommand: {fileID: 11400000, guid: a1e72d57d06dc064e8468699772ab394,
type: 2}
fileFormatVersion: 2
guid: 3cb5a3b01ad820144996141c8e4261cb
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -36,6 +36,7 @@ public class ResetScenario : MonoBehaviour
Destroy(currentScenario);
this.currentScenario = scenario;
code2canvas.movementController = scenario.GetComponentInChildren<MovementController>();
code2canvas.simulationCommunicator = scenario.GetComponentInChildren<SimulationCommunicator>();
}
// Update is called once per frame
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment