public void supervise() { if (!statusFlag.flagOrdered) { robotAgentOrdered = null; for (int index = 0; index < limitedAreainReady.Length; index++) { for (int pos = 0; pos < RegistrationAgent.robotAgentRegisteredList.Count; pos++) { RobotAgent robotAgent = RegistrationAgent.robotAgentRegisteredList.ElementAt(pos).Value; if (robotAgent.statusFlag.atReadyArea == true && robotAgent.statusFlag.flagProcess == false) { robotAgentOrdered = robotAgent; robotAgent.statusFlag.flagProcess = true; statusFlag.flagOrdered = true; robotAgent.requestRobotGotoCheckInDocking(); break; } } } } else { //reset statusFlag.flagOrdered=false; ResetFlagOrderToReadyArea(robotAgentOrdered.robotInfo.loc); } }
public void RegenerateRobots() { // Clean properties of existing robots foreach (RobotAgent r in robots) { r.cleanRobot(); } int newNumberRobots = (int)Academy.Instance.FloatProperties.GetPropertyWithDefault("number_robots", 2.0f); if (newNumberRobots < numRobots) { // Destroy exceeding robots for (int i = newNumberRobots; i < numRobots; i++) { Destroy(robots[i]); } numRobots = newNumberRobots; Debug.Log("Now robots are: " + numRobots); } else if (newNumberRobots > numRobots) { for (int i = numRobots; i < newNumberRobots; i++) { GameObject robot = Instantiate(robotPrefab); robot.transform.SetParent(transform); robot.transform.localPosition = new Vector3(UnityEngine.Random.Range(-2, 4), 0.15f, UnityEngine.Random.Range(-2, 4)); RobotAgent agent = robot.GetComponent <RobotAgent>(); agent.trainingArea = this; robots.Add(agent); } numRobots = newNumberRobots; Debug.Log("Now robots are: " + numRobots); } }
// Start is called before the first frame update void Awake() { text = GetComponent <TextMeshProUGUI>(); robotAgent = FindObjectOfType <RobotAgent>(); canvasRect = transform.parent.GetComponent <RectTransform>(); }
public void Update(RobotAgent robot) { /* * var msg = pw.Write($"It is robot {robot.Id}",1); * robot.Send(msg); */ }
static private RobotStatus Grip(RobotAgent robot_agent, object[] args) { int ret = robot_agent.MoveGripper(Convert.ToUInt16(args[0]), Convert.ToUInt16(args[1])); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }
static private RobotStatus WaitGripper(RobotAgent robot_agent, object[] args) { int ret = robot_agent.WaitGripperBusy((int)args[0], WAIT_TIMEOUT); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }
public void RegisterForReset(RobotAgent agent) { unregistered.Remove(agent); if (unregistered.Count == 0) { unregistered = new List <RobotAgent>(agents); Reset(); } }
static private RobotStatus Reset(RobotAgent robot_agent, object[] args) { int ret = robot_agent.Reset(); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }
static private RobotStatus HomeGripper(RobotAgent robot_agent, object[] args) { int ret = robot_agent.HomeGripper(); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }
public void resetEvolution() { evolutionMaze = HardMaze.loadEnvironment("QDMaze.xml"); evolutionFrame = new CoordinateFrame(0.0f, evolutionMaze.AOIRectangle.Y, 1.1f, 0.0f); optimaAgent = null; optima_net = null; optima_generation = -1; evolutionSession = new Session(this.evolutionMaze, new FitnessHandler(evolutionMaze.compute_fitness), EventHandler, new InstinctActionHandler(HardMaze.createInstinctAction), new OptimaGestureHandler(evolutionMaze.GetOptimaGestureHandler), new TaskBeginHandler(evolutionMaze.TaskBeginHandler)); }
public void InitializeEnvironment() { // Initialize variables environmentGeneration = transform.Find("Environment_Generation").GetComponent <EnvironmentGeneration>(); dropZone = transform.Find("DropZone").GetComponent <DropZone>(); robot = transform.Find("RobotAgent").GetComponent <RobotAgent>(); InitializeDebrisList(); currentDebrisInZone = new List <bool>(); previousDebrisInZone = new List <bool>(); }
private void CreateRobot(params Capability[] capabilities) { var robot = new Robot(capabilities.OfType <ProcessCapability>().ToArray()); var agent = new RobotAgent(capabilities, robot); Robots.Add(robot); RobotAgents.Add(agent); robot.SetNames(Robots.Count - 1); agent.Name = $"R{Robots.Count - 1}"; agent.ConfigurationUpdateFailed.Name = agent.Name + ".ConfigUpdateFailed"; }
static private RobotStatus SetPos(RobotAgent robot_agent, object[] args) { Pos_T target = new Pos_T(); target.pos = (double[])args[0]; int ret = robot_agent.SetHomePos(target); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }
public ControlService(RobotAgent robot, DoorService doorService) { if (robot != null) { robot.ZoneHandler += ZoneHandler; robot.FinishStatesHandler += FinishStatesHandler; robot.AmclPoseHandler += AmclPoseHandler; doorService.ReceiveRounterEvent += ReceiveRounterEvent; } if (doorService != null) { } }
static public RobotStatus Do(RobotAgent robot_agent, string action, object[] args) { Func <RobotAgent, object[], RobotStatus> act_func; if (selector.TryGetValue(action, out act_func)) { return(act_func(robot_agent, args)); } else { throw new System.ArgumentException("No Such Action!!", "action"); } }
static private RobotStatus PcsPTP(RobotAgent robot_agent, object[] args) { Pos_T dest = new Pos_T(); dest.pos = (double[])args[0]; int ret = robot_agent.PcsPTP(dest); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }
public void Register(ProcedureItemSelected ProcedureItem, RobotAgent robot) { switch (ProcedureItem) { case ProcedureItemSelected.PROCEDURE_FORLIFT_TO_BUFFER: break; case ProcedureItemSelected.PROCEDURE_BUFFER_TO_MACHINE: break; case ProcedureItemSelected.PROCEDURE_BUFFER_TO_HOPPER: break; } }
private void initInteraction() { interactive_time = 0; obs = null; gesture = null; actions = null; reward = 0; end = false; inferencing = false; if (demoNet != null) { demoAgent = new RobotAgent(demoNet, evolutionMaze); } this.refreshNetwork(demoNet, treeViewOpenedNetwork); }
static private RobotStatus Home(RobotAgent robot_agent, object[] args) { if ((int)args[0] < 0 || 5 < (int)args[0]) { throw new System.ArgumentOutOfRangeException("AxisId out of range!!", "AxisId(args[0])"); } int ret = robot_agent.HomeRobot((int)args[0]); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }
public ResponseStatus DoRoute(string target, string action, object[] args) { switch (target) { case "Robot": RobotAgent robot_agent = ether_cat_net.GetRobotAgent(0); return(RobotController.Do(robot_agent, action, args)); case "Camera": // EzCameraController; return(EzCameraController.Do(action, args)); default: throw new System.ArgumentException("No Such Target: ", target); } }
public override void InitializeAcademy() { robot = GameObject.Find("Robot").GetComponent <RobotAgent>(); robot.agentParameters.maxStep = (int)(resetParameters["AgentMaxSteps"]); if (resetParameters["CollectData"] == 1 || forceDataCollection) { if (resetParameters["EnableNoise"] == 1 || forceNoise) { robot.addNoise = true; } else { robot.addNoise = false; } } }
private void listBox3_SelectedIndexChanged(object sender, EventArgs e) { int select = listBox3.SelectedIndex; if (robotAgent.Active) { if (select < robotAgent.friends.Count && select >= 0) { showingParamerAgent = robotAgent.friends[select] as RobotAgent; } else { showingParamerAgent = null; } } }
void Start() { Walls = new List <GameObject>(); Agent = GetComponentInChildren <RobotAgent>(); grid = GetComponent <Grid>(); grid.WorldBottomLeft = transform.position - Vector3.right * grid.gridWorldSize.x / 2 - Vector3.forward * grid.gridWorldSize.y / 2; grid.CreateGrid(); aStarPath = GetComponent <AStarPathFinding>(); aStarPath.grid = grid; aStarPath.seeker = Agent.transform; aStarPath.target = Target.transform; grid.player = Agent.transform; SetTargetAtRandomPosition(); initializeMap(); aStarPath.enabled = false; }
void OnTriggerEnter2D(Collider2D hitInfo) { //Debug.Log(hitInfo.name); Destroy(gameObject); RobotAgent enemy = hitInfo.GetComponent <RobotAgent>(); if (enemy != null) { enemy.AddReward(-1.0f); shooter.AddReward(1.0f); //Debug.Log(shooter.transform.position.x.ToString()); //Debug.Log(enemy.transform.position.x.ToString()); shooter.Done(); enemy.Done(); } }
void OnValidate() { robot = GameObject.Find("Robot").GetComponent <RobotAgent>(); if (control == RobotControl.player) { robot.GiveBrain(playerBrain); broadcastHub.broadcastingBrains.Clear(); broadcastHub.broadcastingBrains.Add(playerBrain); } else { robot.GiveBrain(learningBrain); broadcastHub.broadcastingBrains.Clear(); broadcastHub.broadcastingBrains.Add(learningBrain); broadcastHub.SetControlled(learningBrain, true); } if (resetParameters["CollectData"] == 1 || forceDataCollection) { robot.sendRelativeData = true; robot.dataCollection = true; robot.mode = mode; robot.gateTargetObject = gateTargetObject; robot.pathTargetObject = pathTargetObject; } else { robot.sendRelativeData = false; robot.dataCollection = false; } if (resetParameters["Positive"] == 0 || forceNegativeExamples) { robot.positiveExamples = false; } else { robot.positiveExamples = true; } robot.randomQuarter = randomQuarter; robot.randomPosition = randomPosition; robot.randomOrientation = randomOrientation; }
private void btnOpenMaze_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "*.xml|*.xml"; if (dlg.ShowDialog() == DialogResult.Cancel) { return; } HardMaze maze = HardMaze.loadEnvironment(dlg.FileName); if (demoNet != null) { demoAgent = new RobotAgent(demoNet, maze); } evolutionMaze = maze; evolutionSession = new Session(evolutionMaze, new FitnessHandler(evolutionMaze.compute_fitness), EventHandler, new InstinctActionHandler(HardMaze.createInstinctAction), new OptimaGestureHandler(evolutionMaze.GetOptimaGestureHandler), new TaskBeginHandler(evolutionMaze.TaskBeginHandler)); this.Refresh(); }
public static void DebugAgent(bool toDebug, RobotAgent agent, float[] action) { if (!toDebug) { return; } int i; if (crazyJump == false && agent.transform.position.y > 5.5f) { string arrayStr = ""; crazyJump = true; for (i = 0; i < 20; i++) { arrayStr = arrayStr + "[" + pastStates.lastActions[i, 0].ToString() + "] [" + pastStates.lastActions[i, 1].ToString() + "] " + pastStates.lastHeights[i].ToString() + "\n"; } LogFromNamed(toDebug, agent.transform.position.y.ToString() + "\n" + actionCounter.ToString() + "\n" + arrayStr); } else if (crazyJump == true && agent.transform.position.y < 5.5f) { crazyJump = false; } //LogFromNamed(toDebug, agent.transform.position.y.ToString()); for (i = 0; i < 19; i++) { pastStates.lastActions[i, 0] = pastStates.lastActions[i + 1, 0]; pastStates.lastActions[i, 1] = pastStates.lastActions[i + 1, 1]; pastStates.lastHeights[i] = pastStates.lastHeights[i + 1]; } pastStates.lastActions[i, 0] = action[0]; pastStates.lastActions[i, 1] = action[1]; pastStates.lastHeights[i] = agent.transform.position.y; actionCounter++; }
void Awake() { if (useTextInsteadOfGraphics) { text = GetComponent <TextMeshProUGUI>(); } else { up = transform.Find("up").GetComponent <Image>(); down = transform.Find("down").GetComponent <Image>(); left = transform.Find("left").GetComponent <Image>(); right = transform.Find("right").GetComponent <Image>(); zero = transform.Find("zero").GetComponent <Image>(); shovelUp = transform.Find("shovel_up").GetComponent <Image>(); shovelDown = transform.Find("shovel_down").GetComponent <Image>(); } robotAgent = FindObjectOfType <RobotAgent>(); shovelUp.color = transparent; shovelDown.color = transparent; }
/// <summary> /// 交互式环境重置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton4_Click(object sender, EventArgs e) { if (demoNet == null) { demoNet = new Network(genomeFactory.createSimpleGenome(evolutionSession)); //demoNet = new Network(genomeFactory.createAccuracyHighLimitTestGenome(evolutionSession)); refreshNetwork(demoNet, treeViewOpenedNetwork); } interactiveMode = true; interactive_time = 0; (obs, gesture) = evolutionMaze.reset(demoNet); demoAgent = evolutionMaze.Agents[0]; demoAgent.Visible = true; this.txtObservation.Text = "time=" + interactive_time.ToString() + System.Environment.NewLine; this.txtObservation.Text += observationToString(obs, gesture, 0, false); prevObservationText = this.txtObservation.Text; inferencing = false; this.Refresh(); }
static private RobotStatus AcsJog(RobotAgent robot_agent, object[] args) { if ((int)args[0] < 0 || 5 < (int)args[0]) { throw new System.ArgumentOutOfRangeException("AxisId out of range!!", "AxisId(args[0])"); } if ((int)args[1] != 0 && (int)args[1] != 1) { throw new System.NotSupportedException("Not supported direction!!: Dir(args[1])"); } if ((int)args[2] < 0 || 2000 < (int)args[2]) { throw new System.ArgumentOutOfRangeException("Interval out of range!!", "Interval(args[2])"); } int ret = robot_agent.AcsJog((int)args[0], (int)args[1], (int)args[2], MAX_VEL); RobotStatus robot_status = robot_agent.GetStatus(); robot_status.ret_code = ret; return(robot_status); }