public RobotBase(Point position, float radius, Vector2D velocity, float maxSpeed, Vector2D heading, float mass, Vector2D scale, float turnRate, float maxForce, List<Node> patrolPath, Workspace traversabilityMap, Workspace visibilityMap) : base(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, traversabilityMap, visibilityMap) { CurrentTarget = null; NeedToRunTimeStep = false; LastDecisionPoint = DateTime.MinValue; CurrentPath = null; _patrolPath = patrolPath; }
public AerialPursuer(State<AerialPursuer> startState, Point position, float radius, Vector2D velocity, float maxSpeed, Vector2D heading, float mass, Vector2D scale, float turnRate, float maxForce, List<Node> patrolPath, Workspace traversabilityMap, Workspace visibilityMap) : base(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, patrolPath, traversabilityMap, visibilityMap) { StateMachine = new StateMachine<AerialPursuer>(this); if (startState != null) { StateMachine.SetCurrentState(startState); StateMachine.ChangeState(startState); StateMachine.SetGlobalState(GlobalAerialPursuerStates.TheInstance); } }
private void GenerateMilestones(Workspace workspace) { if (workspace == null || workspace.Milestones == null || workspace.Milestones.Count == 0) return; foreach (Node milestone in workspace.Milestones) GeneratePoint(milestone, Brushes.Gray, Brushes.DarkSlateGray, NORMAL_POINT_SIZE); }
public MainWindow() { InitializeComponent(); _workspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX); }
private void GenerateEdges(Workspace workspace) { if (workspace == null || workspace.Milestones == null || workspace.Milestones.Count == 0) return; Line line; foreach (Node milestone in workspace.Milestones) { foreach (Edge edge in milestone.Edges) { line = new Line() { Stroke = Brushes.Gray, StrokeThickness = 1, X1 = edge.FirstPoint.X * pixelsPerXUnit, X2 = edge.SecondPoint.X * pixelsPerXUnit, Y1 = edge.FirstPoint.Y * pixelsPerYUnit, Y2 = edge.SecondPoint.Y * pixelsPerYUnit }; myCanvas.Children.Add(line); } } }
private List<Target> GenerateTargets(HomeworkTwo.Point point, Workspace traversabilityMap, Workspace visibilityMap) { // Create our agents return new List<Target>() { new Target(TargetPatrol.TheInstance, point, // location RADIUS, // radius new Vector2D(), // intial velocity MAX_SPEED * .7f, // max speed new Vector2D(), // intial heading MASS, // mass new Vector2D(1.0, 1.0), // scale TURN_RATE, // turn rate MAX_FORCE, // max force new List<Node>(), // patrol path traversabilityMap, // traversability map visibilityMap)}; // visibility map }
private List<RobotBase> GeneratePursuers(HomeworkTwo.Point point, Workspace traversabilityMap, Workspace visibilityMap, List<Node> groundPatrolPath) { Workspace airWorkspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { }; airWorkspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1)); List<Node> airPatrolPath = new List<Node>() { airWorkspace.GetNode(new HomeworkTwo.Point(1, 39)), airWorkspace.GetNode(new HomeworkTwo.Point(39, 39)), airWorkspace.GetNode(new HomeworkTwo.Point(39, 1)), airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))}; return new List<RobotBase>() { new GroundPursuer(GroundPursuerPatrol.TheInstance, point, // location RADIUS, // radius new Vector2D(), // intial velocity MAX_SPEED * .6f, // max speed new Vector2D(), // intial heading MASS, // mass new Vector2D(1, 1), // scale TURN_RATE, // turn rate MAX_FORCE, // max force groundPatrolPath, // patrol path traversabilityMap, // traversability map visibilityMap),// visibility map new AerialPursuer(AerialPursuerPatrol.TheInstance, new HomeworkTwo.Point(1,15), // location RADIUS, // radius new Vector2D(), // intial velocity MAX_SPEED * .75f, // max speed new Vector2D(), // intial heading MASS, // mass new Vector2D(), // scale TURN_RATE, // turn rate MAX_FORCE, // max force airPatrolPath, // patrol path airWorkspace, // traversability map airWorkspace) }; // visibility map }
/// <summary> /// Generates all the farm stuff /// </summary> private void GenerateFarm() { backgroundName = "Farm"; _workspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { Obstacles = GenerateBaseFarmObstacles() }; _workspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1)); List<Node> groundPatrolPath = new List<Node>() { _workspace.GetNode(new HomeworkTwo.Point(18, 10)), _workspace.GetNode(new HomeworkTwo.Point(18, 35)), _workspace.GetNode(new HomeworkTwo.Point(28, 35)), _workspace.GetNode(new HomeworkTwo.Point(28, 2)), _workspace.GetNode(new HomeworkTwo.Point(28, 35)), _workspace.GetNode(new HomeworkTwo.Point(18, 35))}; // Create our robot group with our agents _robotGroup = new RobotGroup( GeneratePursuers(new HomeworkTwo.Point(25, 38), _workspace, _workspace, groundPatrolPath), GenerateTargets(new HomeworkTwo.Point(30, 39), _workspace, _workspace), TIME_STEP_LENGTH, TIME_HORIZON, VISIBLITY_CRITERIA); }
/// <summary> /// Generates all the city stuff /// </summary> private void GenerateCity() { backgroundName = "City"; Obstacles obstacles = new Obstacles(); // Create obstacles for (double i = 3.5; i <= 38; i = i + 5.5) for (double j = 25.5; j <= 38; j = j + 5.5) obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(j,i), 4, 4)); for (double i = 25.5; i <= 38; i = i + 5.5) for (double j = 3.5; j <= 22; j = j + 5.5) obstacles.Add(new RectangleObstacle(new HomeworkTwo.Point(j,i), 4, 4)); // Set up workspace and generate nodes _workspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { Obstacles = obstacles }; _workspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1)); Workspace airWorkspace = new Workspace(X_MIN, X_MAX, Y_MIN, Y_MAX) { }; airWorkspace.GenerateEvenGraph((UInt16)(X_RANGE + 1), (UInt16)(Y_RANGE + 1)); List<Node> groundPatrolPath = new List<Node>() { airWorkspace.GetNode(new HomeworkTwo.Point(1, 20)), airWorkspace.GetNode(new HomeworkTwo.Point(20, 20)), airWorkspace.GetNode(new HomeworkTwo.Point(20, 1)), airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))}; List<Node> airPatrolPath = new List<Node>() { airWorkspace.GetNode(new HomeworkTwo.Point(1, 39)), airWorkspace.GetNode(new HomeworkTwo.Point(39, 39)), airWorkspace.GetNode(new HomeworkTwo.Point(39, 1)), airWorkspace.GetNode(new HomeworkTwo.Point(1, 1))}; // Create our agents List<RobotBase> pursuerRobots = new List<RobotBase>() { new GroundPursuer(GroundPursuerPatrol.TheInstance, new HomeworkTwo.Point(1,1), // location RADIUS, // radius new Vector2D(), // intial velocity MAX_SPEED * .8f, // max speed new Vector2D(), // intial heading MASS, // mass new Vector2D(), // scale TURN_RATE, // turn rate MAX_FORCE, // max force groundPatrolPath, // patrol path _workspace, // traversability map _workspace), // visibility map new AerialPursuer(AerialPursuerPatrol.TheInstance, new HomeworkTwo.Point(1,15), // location RADIUS, // radius new Vector2D(), // intial velocity MAX_SPEED, // max speed new Vector2D(), // intial heading MASS, // mass new Vector2D(), // scale TURN_RATE, // turn rate MAX_FORCE, // max force airPatrolPath, // patrol path airWorkspace, // traversability map airWorkspace) }; // visibility map List<Target> targetRobots = new List<Target>() { new Target(TargetPatrol.TheInstance, new HomeworkTwo.Point(30,39), // location RADIUS, // radius new Vector2D(), // intial velocity MAX_SPEED, // max speed new Vector2D(), // intial heading MASS, // mass new Vector2D(), // scale TURN_RATE, // turn rate MAX_FORCE, // max force new List<Node>(), // patrol path _workspace, // traversability map _workspace)}; // visibility map // Create our robot group with our agents _robotGroup = new RobotGroup(pursuerRobots, targetRobots, TIME_STEP_LENGTH, TIME_HORIZON, VISIBLITY_CRITERIA); }