public override void updateSensors(Environment env, List<Robot> robots, CollisionManager cm)
        {

           // Console.WriteLine(this.sensors.Count);
            base.updateSensors(env, robots, cm);
            pieSliceSensor.update(env, robots, cm);
        }
        public void update(Environment env, List<Robot> robots, CollisionManager cm)
        {
            distance = maxRange;
            seePrey = false;
            Point2D casted = new Point2D(owner.location);
            casted.x += Math.Cos(angle + owner.heading) * maxRange;
            casted.y += Math.Sin(angle + owner.heading) * maxRange;

            Line2D cast = new Line2D(owner.location, casted);

            foreach (Prey prey in env.preys)
            {
                bool found = false;

                double newDistance = cast.nearest_intersection(prey.circle, out found);

                if (found)
                {
                    if (newDistance < distance)
                    {
                        distance = newDistance;
                        seePrey = true;
                    }
                }
            }
        }
        //Different from PieSliceSensorArray in that EnemyRobots are used as targets instead
        // of goal points. 
        public void update(Engine.Environment env, List<Robot> robots, CollisionManager cm)
        {
            List<float> translatedEnemyAngles = new List<float>();
            // Start at 1: Assume all robots after first are enemies
            for (int i = 1; i < robots.Count; i++)
            {
                EnemyRobot er = (EnemyRobot) robots[i];
                if (!er.stopped) // Only sense prey robots that are active
                {
                    Point2D temp = new Point2D((int)er.location.x, (int)er.location.y);

                    temp.rotate((float)-(owner.heading), owner.circle.p);  //((float)-(owner.heading * 180.0 / 3.14), owner.circle.p);

                    //translate with respect to location of navigator
                    temp.x -= (float)owner.circle.p.x;
                    temp.y -= (float)owner.circle.p.y;

                    //what angle is the vector between target & navigator
                    float angle = angleValue((float)temp.x, (float)temp.y);// (float)temp.angle();

                    translatedEnemyAngles.Add(angle);
                }
            }

            //fire the appropriate radar sensor
            for (int i = 0; i < radarAngles1.Count; i++)
            {
                signalsSensors[i].setSignal(0.0);

                for (int a = 0; a < translatedEnemyAngles.Count; a++)
                {
                    float angle = translatedEnemyAngles[a];

                    if (angle >= radarAngles1[i] && angle < radarAngles2[i])
                    {
                        signalsSensors[i].setSignal(1.0);
                    }

                    if (angle + 360.0 >= radarAngles1[i] && angle + 360.0 < radarAngles2[i])
                    {
                        signalsSensors[i].setSignal(1.0);
                    }
                }
            }

        }
        //per default we use the goal point of the environment as our target point. 
        public void update(Engine.Environment env, List<Robot> robots, CollisionManager cm)
        {
            Point2D temp = new Point2D((int)env.goal_point.x, (int)env.goal_point.y);

            temp.rotate((float)-(owner.heading), owner.circle.p);  //((float)-(owner.heading * 180.0 / 3.14), owner.circle.p);

            //translate with respect to location of navigator
            temp.x -= (float)owner.circle.p.x;
            temp.y -= (float)owner.circle.p.y;

            //what angle is the vector between target & navigator
            float angle = angleValue((float)temp.x, (float) temp.y);// (float)temp.angle();

        //!    angle *= 57.297f;//convert to degrees

            //fire the appropriate radar sensor
            for (int i = 0; i < radarAngles1.Count; i++)
            {
                signalsSensors[i].setSignal(0.0);
                //radar[i] = 0.0f;

                if (angle >= radarAngles1[i] && angle < radarAngles2[i])
                {
                    signalsSensors[i].setSignal(1.0);
                 //   Console.WriteLine(i);
                }
                //radar[i] = 1.0f;

                if (angle + 360.0 >= radarAngles1[i] && angle + 360.0 < radarAngles2[i])
                {
                    signalsSensors[i].setSignal(1.0);
                   // Console.WriteLine(i);
                }
//                    radar[i] = 1.0f;

                
               // inputs[sim_engine.robots[0].rangefinders.Count + i] = sim_engine.radar[i];

            }

        }
 public void update(Environment env, List <Robot> robots, CollisionManager cm)
 {
 }
		public void update(Environment env, List<Robot> robots,CollisionManager cm) 
		{
		}
Exemple #7
0
 public override void updateSensors(Environment env, List <Robot> robots, CollisionManager cm)
 {
     base.updateSensors(env, robots, cm);
     pieSliceSensor.update(env, robots, cm);
 }
Exemple #8
0
        public virtual void updateSensors(Environment env, List<Robot> robots,CollisionManager cm)
        {
			foreach (ISensor sensor in sensors) {
				sensor.update(env, robots,cm);
			}
        }
 public override void updateSensors(Environment env, List <Robot> robots, CollisionManager cm)
 {
     // Console.WriteLine(this.sensors.Count);
     base.updateSensors(env, robots, cm);
     pieSliceSensor.update(env, robots, cm);
 }
 public void update(Environment env, List <Robot> robots, CollisionManager cm)
 {
     offsetx = Math.Cos(owner.heading + delta_theta) * delta_r;
     offsety = Math.Sin(owner.heading + delta_theta) * delta_r;
 }
 public override void updateSensors(Environment env, List<Robot> robots, CollisionManager cm)
 {
     base.updateSensors(env, robots, cm);
     pieSliceSensor.update(env, robots, cm);
 }
		public void update(Environment env, List<Robot> robots,CollisionManager cm)
		{
			bool hitRobot;
            offsetx = Math.Cos(owner.heading+delta_theta)*delta_r;
			offsety = Math.Sin(owner.heading+delta_theta)*delta_r;
			Point2D location = new Point2D(offsetx + owner.location.x, offsety + owner.location.y);
			SimulatorObject hit;			
			distance = cm.Raycast(angle,max_range,location,owner,out hit);

			if (hit is Robot) {
				seeRobot=true;			
			}
			else {
				seeRobot=false;
			}
			//apply sensor noise
			/*
			if(noise>0.0) {
				distance*= 1.0 + (noise * (owner.rng.NextDouble()-0.5)*2.0);				
				if(distance>max_range)
					distance=max_range;
				if(distance<0.0)
					distance=0.0;
			}
			*/
            Debug.Assert(!Double.IsNaN(distance), "NaN in inputs");
		}
		public void update(Environment env, List<Robot> robots,CollisionManager cm) 
		{
			offsetx = Math.Cos(owner.heading+delta_theta)*delta_r;
			offsety = Math.Sin(owner.heading+delta_theta)*delta_r;
		}
 public void update(Environment env, List<Robot> robots, CollisionManager cm)
 {
     int steps = robots[0].history.Count;
     time = (double)steps * timestep;
 }