public override void ExecuteBehavior(UrbanChallenge.Behaviors.Behavior b) { if (displaySignals) { if (b.Decorators != null) { Console.Write("Decorators: "); foreach (BehaviorDecorator bd in b.Decorators) { if (bd is TurnSignalDecorator) { TurnSignalDecorator tsd = (TurnSignalDecorator)bd; Console.Write(tsd.Signal.ToString() + ", "); } else { Console.Write("Unrecognized, "); } } Console.Write("\n"); } else { Console.WriteLine("Decorators: null"); } } }
public static UrbanChallenge.Common.Shapes.Polygon PolygonIntersection(UrbanChallenge.Common.Shapes.Polygon polygon, UrbanChallenge.Common.Shapes.Polygon eePolygon) { GpcWrapper.Polygon one = ToGpcPolygon(polygon); GpcWrapper.Polygon two = ToGpcPolygon(eePolygon); GpcWrapper.Polygon final = GpcWrapper.GpcWrapper.Clip(GpcWrapper.GpcOperation.Intersection, one, two); return ToShapePolygon(final); }
public static GpcWrapper.Polygon ToGpcPolygon(UrbanChallenge.Common.Shapes.Polygon input) { GraphicsPath gp = new GraphicsPath(); PointF[] polyPoints = new PointF[input.Count]; for (int i = 0; i < input.Count; i++) { polyPoints[i] = DrawingUtility.ToPointF(input[i]); } gp.AddPolygon(polyPoints); return new GpcWrapper.Polygon(gp); }
public void BeginTrackingCycle(UrbanChallenge.Common.CarTimestamp timestamp) { // nothing to do }
public override void InMove(UrbanChallenge.Common.Coordinates orig, UrbanChallenge.Common.Coordinates offset, RndfEditor.Display.Utilities.WorldTransform t) { throw new Exception("The method or operation is not implemented."); }
public void InMove(UrbanChallenge.Common.Coordinates orig, UrbanChallenge.Common.Coordinates offset, WorldTransform t) { throw new Exception("The method or operation is not implemented."); }
public void SetTurnSignal(UrbanChallenge.Behaviors.TurnSignal signal) { // do this "out of band" because it doesn't really fit with anything else commandTransport.SetTurnSignal(signal); }
public void InMove(UrbanChallenge.Common.Coordinates orig, UrbanChallenge.Common.Coordinates offset, WorldTransform t) { this.position = orig + offset; }
public void CancelMove(UrbanChallenge.Common.Coordinates orig, WorldTransform t) { this.position = orig; }
public void Update(UrbanChallenge.Common.Vehicle.VehicleState ourState) { // get lane ArbiterLane lane = this.turnFinalWaypoint.Lane; // get the possible vehicles that could be in this stop if (TacticalDirector.VehicleAreas.ContainsKey(lane)) { // get vehicles in the the lane of the exit List<VehicleAgent> possibleVehicles = TacticalDirector.VehicleAreas[lane]; // get the point we are looking from LinePath.PointOnPath referencePoint = lane.LanePath().GetClosestPoint(this.turnFinalWaypoint.Position); // tmp VehicleAgent tmp = null; double tmpDist = Double.MaxValue; // check over all possible vehicles foreach (VehicleAgent possible in possibleVehicles) { // get vehicle point on lane LinePath.PointOnPath vehiclePoint = lane.LanePath().GetClosestPoint(possible.ClosestPosition); // check if the vehicle is in front of the reference point double vehicleDist = lane.LanePath().DistanceBetween(referencePoint, vehiclePoint); if (vehicleDist >= 0 && vehicleDist < TahoeParams.VL * 2.0) { tmp = possible; tmpDist = vehicleDist; } } if (tmp != null) { if (this.currentVehicle == null || !this.currentVehicle.Equals(tmp)) { this.timer.Stop(); this.timer.Reset(); this.currentVehicle = tmp; } else this.currentVehicle = tmp; if (this.currentVehicle.IsStopped && !this.timer.IsRunning) { this.timer.Stop(); this.timer.Reset(); this.timer.Start(); } else if (!this.currentVehicle.IsStopped && this.timer.IsRunning) { this.timer.Stop(); this.timer.Reset(); } } else { this.currentVehicle = null; this.timer.Stop(); this.timer.Reset(); } } else { this.timer.Stop(); this.timer.Reset(); this.currentVehicle = null; } }
public bool IsCompletelyClear(UrbanChallenge.Common.Vehicle.VehicleState ourState) { this.Update(ourState); return this.Clear(ourState); }
public override void SetRoadNetwork(UrbanChallenge.Arbiter.ArbiterRoads.ArbiterRoadNetwork roadNetwork) { }
public override void SetProjection(UrbanChallenge.Common.EarthModel.PlanarProjection proj) { }
public UrbanChallenge.Behaviors.Behavior Resume(UrbanChallenge.Common.Vehicle.VehicleState currentState, double speed) { List<Polygon> stayOuts = new List<Polygon>(); foreach(Polygon so in this.Zone.StayOutAreas) { if(!so.IsInside(currentState.Front) && !so.IsInside(currentState.Position)) stayOuts.Add(so); } return new UTurnBehavior(this.Zone.Perimeter.PerimeterPolygon, new LinePath(new Coordinates[] { this.final.Start.Position, this.final.End.Position }), null, new ScalarSpeedCommand(1.7), stayOuts); }
public RndfEditor.Display.Utilities.HitTestResult HitTest(UrbanChallenge.Common.Coordinates loc, float tol, RndfEditor.Display.Utilities.WorldTransform wt, RndfEditor.Display.Utilities.DisplayObjectFilter filter) { return new HitTestResult(this, false, float.MaxValue); }
public bool Clear(UrbanChallenge.Common.Vehicle.VehicleState ourState) { return (this.currentVehicle == null || (this.currentVehicle.StateMonitor.Observed.speedValid && !this.currentVehicle.IsStopped && this.currentVehicle.Speed > 2.0)); }
public void BeginMove(UrbanChallenge.Common.Coordinates orig, WorldTransform t) { }
public void OnPreRender(UrbanChallenge.OperationalUI.Common.GraphicsWrapper.IGraphics g, WorldTransform transform) { }
public HitTestResult HitTest(UrbanChallenge.Common.Coordinates loc, float tol, WorldTransform wt, DisplayObjectFilter filter) { // check filter if (filter.Target == null || filter.Target is ArbiterParkingSpotWaypoint) { // get bounding box dependent on tolerance RectangleF bounding = this.GetBoundingBox(wt); bounding.Inflate(tol, tol); // check if contains point if (bounding.Contains(DrawingUtility.ToPointF(loc))) { return new HitTestResult(this, true, (float)loc.DistanceTo(this.Position)); } } return new HitTestResult(this, false, float.MaxValue); }
public void Transform(UrbanChallenge.Common.Mapack.Matrix3 m) { throw new NotSupportedException(); }
private LinePath ConvertPath(UrbanChallenge.Common.Path.Path p) { LinePath lineList = new LinePath(); lineList.Add(p[0].Start); for (int i = 0; i < p.Count; i++) { lineList.Add(p[i].End); } return lineList; }
public UrbanChallenge.Behaviors.Behavior Resume(UrbanChallenge.Common.Vehicle.VehicleState currentState, double speed) { return new StayInLaneBehavior(OpposingLane.LaneId, new ScalarSpeedCommand(0.0), new List<int>()); }
public HitTestResult HitTest(UrbanChallenge.Common.Coordinates loc, float tol, WorldTransform wt, DisplayObjectFilter filter) { return new HitTestResult(this, false, float.MaxValue); }
public HitTestResult HitTest(UrbanChallenge.Common.Coordinates loc, float tol, WorldTransform wt, DisplayObjectFilter filter) { if (filter(this)) { Coordinates closest = this.GetClosest(loc); if ((float)loc.DistanceTo(closest) < 5 + tol) { return new HitTestResult(this, true, (float)loc.DistanceTo(closest)); } } return new HitTestResult(this, false, float.MaxValue); }
public UrbanChallenge.Behaviors.Behavior Resume(UrbanChallenge.Common.Vehicle.VehicleState currentState, double speed) { return this.RecoveryBehavior != null ? this.RecoveryBehavior : new NullBehavior(); }
public override void BeginMove(UrbanChallenge.Common.Coordinates orig, RndfEditor.Display.Utilities.WorldTransform t) { }
public UrbanChallenge.Behaviors.Behavior Resume(UrbanChallenge.Common.Vehicle.VehicleState currentState, double speed) { return new HoldBrakeBehavior(); }
public override void InMove(UrbanChallenge.Common.Coordinates orig, UrbanChallenge.Common.Coordinates offset, RndfEditor.Display.Utilities.WorldTransform t) { this.VehicleState.Position = orig + offset; }
public void BeginTrackingCycle(UrbanChallenge.Common.CarTimestamp timestamp) { first.BeginTrackingCycle(timestamp); second.BeginTrackingCycle(timestamp); }
public double DistanceTo(UrbanChallenge.Common.Coordinates loc) { return this.Perimeter.PerimeterPolygon.IsInside(loc) ? 0.0 : Double.MaxValue; }