亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rescuevansim.java

?? 一個多機器人的仿真平臺
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/* * RescueVanSim.java */package EDU.gatech.cc.is.abstractrobot;import java.awt.*;import java.util.Enumeration;import EDU.gatech.cc.is.util.*;import EDU.gatech.cc.is.simulation.*;import EDU.gatech.cc.is.communication.*;import EDU.cmu.cs.coral.simulation.*;import EDU.cmu.cs.coral.util.Polygon2;import EDU.cmu.cs.coral.util.Circle2;/** * RescueVanSim implements RescueVanSim for simulation. * Also includes code implementing communication, gripper and * vision. * <P> * <A HREF="../COPYRIGHT.html">Copyright</A> * (c)1998 Tucker Balch * * @see RescueVanSim * @author Tucker Balch * @version $Revision: 1.5 $ */public class RescueVanSim extends Simple	implements SimulatedObject, RescueVan	{	private	CircularBuffer	trail;	// robot's trail	private KinSensorSim	kin_sensor;	// senses our kin	private TransceiverSim	transceiver;	// comm to other robots	protected Vec2	position;	protected Vec2	steer;	private	double	speed;	protected Color	foreground, background;	private long	time;	private double	timed;	protected double left, right, top, bottom;	private	SimulatedObject[] all_objects = new SimulatedObject[0];	private	int	visionclass;	public	static final boolean DEBUG = false;	/**	 * Instantiate a <B>RescueVanSim</B> object.  Be sure	 * to also call init with proper values.	 * @see RescueVanSim#init	 */        public RescueVanSim()		{		/*--- set parameters ---*/                super(1);		position = new Vec2(0,0);		steer = new Vec2(1,0);		foreground = Color.black;		background = Color.black;		if (DEBUG) System.out.println("RescueVanSim: instantiated.");		/*--- set default bounds ---*/		top = 100000;		bottom = -100000;		left = -100000;		right = 100000;		}	        /**         * Initialize a <B>RescueVanSim</B> object.         */	public void init(double xp, double yp, double tp, double ignore,		Color f, Color b, int v, int i, long s)		{		trail = new CircularBuffer(1000);		setID(i);                kin_sensor = new KinSensorSim(this);		transceiver = new TransceiverSim(this, this);		position = new Vec2(xp,yp);		steer = new Vec2(1,0);		steer.sett(tp);		foreground = f;		background = b;		time = 0;		timed = 0;		visionclass = v;		if (DEBUG) System.out.println("RescueVanSim: initialized"			+" at "+xp+","+yp);		}	/**	 * Take a simulated step;	 */	private double last_traversability = 1.0;	public void takeStep(long time_increment, SimulatedObject[] all_objs)		{		if (DEBUG) System.out.println("RescueVanSim.TakeStep()");                if (DEBUG) System.out.println("position is "+position.x+","+position.y);		/*--- keep pointer to the other objects ---*/		all_objects = all_objs;		/*--- update the time ---*/		time += time_increment;		double time_incd = ((double)time_increment)/1000;		timed += time_incd;		/*--- update the steering ---*/		double sturn = Units.BestTurnRad(steer.t, desired_heading);		if (Math.abs(sturn) > (MAX_STEER*time_incd))			{			if (sturn<0)				sturn = -MAX_STEER*time_incd;			else sturn = MAX_STEER*time_incd;			}		steer.sett(steer.t + sturn);		/*--- compute velocity ---*/		Vec2 velocity = new Vec2(steer.x, steer.y);		if (in_reverse)			velocity.setr(-base_speed * last_traversability				* desired_speed);		else			velocity.setr(base_speed * last_traversability				* desired_speed);		/*--- compute a movement step ---*/		Vec2 mvstep = new Vec2(velocity.x, velocity.y);		mvstep.setr(mvstep.r * time_incd);		/*--- test the new position to see if in bounds ---*/		Vec2 pp = new Vec2(position.x, position.y);		pp.add(mvstep);		if (pp.x+RADIUS > right)			{			position.setx(right-RADIUS);			velocity.setx(0);			mvstep.setx(0);			}		else if (pp.x-RADIUS < left)			{			position.setx(left+RADIUS);			velocity.setx(0);			mvstep.setx(0);			}		if (pp.y+RADIUS > top)			{			position.sety(top-RADIUS);			velocity.sety(0);			mvstep.sety(0);			}		else if (pp.y-RADIUS < bottom)			{			position.sety(bottom+RADIUS);			velocity.sety(0);			mvstep.sety(0);			}		/*--- test the new position to see if on top of obstacle ---*/		pp = new Vec2(position.x, position.y);		boolean moveok = true;		last_traversability = 1.0;		pp.add(mvstep);		for (int i=0; i<all_objects.length; i++)			{			if (all_objects[i].isObstacle() && 				(all_objects[i].getID() != unique_id))				{				Vec2 tmp = all_objects[i].getClosestPoint(pp);				if (tmp.r < RADIUS)					{					moveok = false;					break;					}				}			else if (all_objects[i] instanceof 				SimulatedTerrainObject)				{				Vec2 tmp = all_objects[i].getClosestPoint(pp);				if (tmp.r == 0) // on/in object					last_traversability =				((SimulatedTerrainObject)all_objects[i]).getTraversability();				}			}		if (moveok) position.add(mvstep);		/*--- test the new position to see if on top of pushable ---*/		for (int i=0; i<all_objects.length; i++)			{			if (all_objects[i].isPushable() && 				(all_objects[i].getID() != unique_id))				{				Vec2 tmp = all_objects[i].getClosestPoint(pp);				if (tmp.r < RADIUS)					{					tmp.setr(RADIUS - tmp.r);					all_objects[i].push(tmp, velocity);					}				}			}                if (DEBUG) System.out.println("position is "+position.x+","+position.y);		}		/*--- From RescueVan ---*/	/**	 * Report how many things are loaded in the van.	 */	public int getNumObjectsCarrying(long timestamp)		{		return(num_loaded);		}	/**	 * Pick up something and load it in the van.	 */	private SimulatedObject[] loaded = new SimulatedObject[MAX_CAPACITY];	private int num_loaded = 0;	public boolean pickup(long timestamp)		{		boolean got_something = false;                /*--- check all objects ---*/		for(int i = 0; i<all_objects.length; i++)			{			/*--- check if it's not self ---*/			if (all_objects[i].getID() != unique_id)				{				Vec2 tmp = all_objects[i].getCenter(position);				// check if can pick it up				if ((tmp.r<PICKUP_CAPTURE_RADIUS)					&&(all_objects[i].isPickupable())					&&(all_objects[i].getVisionClass()>=0)					&&(num_loaded<MAX_CAPACITY))					{					// pick it up					loaded[num_loaded++] = all_objects[i];					all_objects[i].pickUp(						(SimulatedObject) this);					got_something = true;					break;                                        }                                }                        }		return(got_something);		}	/**	 * Drop something out of the van in Last-In-First-Out (LIFO) order.	 */	public void drop(long timestamp)		{		if (num_loaded>0)			{			num_loaded--;			loaded[num_loaded].putDown(new Vec2(position));			}		}	/*--- From SimulatedObject ---*/	public boolean isObstacle()		{		return(true);		}		public boolean isPushable()		{		return(false);		}		public boolean isPickupable()		{		return(false);		}		public Vec2 getClosestPoint(Vec2 from)		{		Vec2 tmp = new Vec2(position.x, position.y);		tmp.sub(from);		if (tmp.r < RADIUS)			tmp.setr(0);		else			tmp.setr(tmp.r-RADIUS);		return(tmp);		}        /**	 * determine if the object is intersecting with a specified circle.	 * This is useful for obstacle avoidance and so on.	 * @param c the circle which may be intersecting the current object.	 * @return true if collision detected.         */	public boolean checkCollision(Circle2 c)	    {	    Vec2 closest = getClosestPoint(c.centre); // closest is a vector with origin at centre that leads to closest point on current object	    if (closest.r <= c.radius) // closest point is within c.radius of c.centre			{			return true;			}	    else 			{			return false;			}	    }        /**	 * determine if the object is intersecting with a specified polygon.	 * This is useful for obstacle avoidance and so on.	 * @param p the polygon which may be intersecting the current object.	 * @return true if collision detected.         */	public boolean checkCollision(Polygon2 p)		{		Vec2 vertex1, vertex2, vec1, vector2, closestPt;		int numberEdges = p.vertices.size(); // n edges if n vertices (as vertex n+1 wraps round to vertex 0)		double scale;		for (int i=0;i<numberEdges;i++)			{			vertex1 = (Vec2)p.vertices.elementAt(i);			vertex2 = (Vec2)p.vertices.elementAt((i+1)%numberEdges);			vertex1.sub(position);			vertex2.sub(position);			// if either vertex is within the circles radius you are colliding			if ((vertex1.r < RADIUS) || (vertex2.r < RADIUS))				{				return true;				} 			vertex1.add(position);			vertex2.add(position);			vec1 = new Vec2(vertex2);			vec1.sub(vertex1);			vector2 = new Vec2(position);			vector2.sub(vertex1);			scale = ((vec1.x*vector2.x)+(vec1.y*vector2.y))/((vec1.x*vec1.x)+(vec1.y*vec1.y));			closestPt = new Vec2(scale*vec1.x, scale*vec1.y);			closestPt.add(vertex1); // absolute position of closest point			closestPt.sub(position); // position of closest point relative to centre of current object			if (closestPt.r < RADIUS)				{				// now need to check if closestPt lies between vertex1 and vertex2				// i.e. it could lie on vector between them but outside of them				if ( (scale > 0.0) && (scale < 1.0) )					{					return true;					}				}			}		return false; // closest point to object on each edge of polygon not within object					}	public Vec2 getCenter(Vec2 from)		{		Vec2 tmp = new Vec2(position.x, position.y);		tmp.sub(from);		return(tmp);		}	public void push(Vec2 d, Vec2 v)		{		// sorry no pushee robots!		}	public void pickUp(SimulatedObject o)		{		// sorry no pickupee robots!		}	public void putDown(Vec2 p)		{		// sorry no put downee robots!		}	public void setVisionClass(int v)		{		visionclass = v;		}	public int getVisionClass()		{		return(visionclass);		}	  public Color getForegroundColor() { return foreground; }	  public Color getBackgroundColor() { return background; }	/**         * Draw the robot's ID.         */        public void drawID(Graphics g, int w, int h,                double t, double b, double l, double r)                {                top =t; bottom =b; left =l; right =r;                if (DEBUG) System.out.println("draw "+                        w + " " +                        h + " " +                        t + " " +                        b + " " +                        l + " " +                        r + " ");                double meterspp = (r - l) / (double)w;                int radius = (int)(RADIUS / meterspp);                int xpix = (int)((position.x - l) / meterspp);                int ypix = (int)((double)h - ((position.y - b) / meterspp));                /*--- draw ID ---*/                g.setColor(background);                g.drawString(String.valueOf(getPlayerNumber(0))			,xpix-radius,ypix-radius);                }        private Point last = new Point(0,0);        /**         * Draw the robot's Trail.         */        public void drawTrail(Graphics g, int w, int h,                double t, double b, double l, double r)                {                top =t; bottom =b; left =l; right =r;                if (DEBUG) System.out.println("draw "+                        w + " " +                        h + " " +                        t + " " +                        b + " " +                        l + " " +                        r + " ");                double meterspp = (r - l) / (double)w;                int xpix = (int)((position.x - l) / meterspp);                int ypix = (int)((double)h - ((position.y - b) / meterspp));                /*--- record the point ---*/                Point p = new Point(xpix,ypix);                if ((last.x!=xpix)||(last.y!=ypix))                        trail.put(p);                last = p;                /*--- get the list of all points ---*/                Enumeration point_list = trail.elements();                /*--- draw the trail ---*/                g.setColor(background);                Point from = (Point)point_list.nextElement();                while (point_list.hasMoreElements())                        {                        Point next = (Point)point_list.nextElement();                        g.drawLine(from.x,from.y,next.x,next.y);                        from = next;                        }                }	private String display_string = "blank";	/**         * Set the String that is printed on the robot's display.         * For simulated robots, this appears printed below the agent         * when view "Robot State" is selected.         * @param s String, the text to display.         */        public void setDisplayString(String s)		{		display_string = s;		}        /**         * Draw the robot's state.         */        public void drawState(Graphics g, int w, int h,                double t, double b, double l, double r)                {                top =t; bottom =b; left =l; right =r;                if (DEBUG) System.out.println("draw "+                        w + " " +                        h + " " +                        t + " " +                        b + " " +                        l + " " +                        r + " ");                double meterspp = (r - l) / (double)w;                int radius = (int)(RADIUS / meterspp);                int xpix = (int)((position.x - l) / meterspp);                int ypix = (int)((double)h - ((position.y - b) / meterspp));                /*--- draw State ---*/                g.setColor(background);                g.drawString(display_string,xpix+radius+3,ypix-radius);                displayVectors.draw(g,w,h,t,b,l,r);		}	/**         * Set the length of the trail (in movement steps).         * @param l int, the length of the trail.         */        public void setTrailLength(int l)		{		trail = new CircularBuffer(l);		}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费高清视频在线| 国产成人在线网站| 青青国产91久久久久久| 日韩精品91亚洲二区在线观看| 亚洲不卡av一区二区三区| 日韩高清在线一区| 国产一区二区三区四| 99国产麻豆精品| 欧美一区二区三区精品| 26uuu成人网一区二区三区| 中文字幕va一区二区三区| 4hu四虎永久在线影院成人| 5858s免费视频成人| 久久久精品国产免费观看同学| 国产精品久久久久永久免费观看| 亚洲欧洲日韩综合一区二区| 一区二区三区久久| 日本成人在线一区| 91理论电影在线观看| 91精品蜜臀在线一区尤物| 国产欧美一区二区精品忘忧草 | 国产农村妇女毛片精品久久麻豆 | 亚洲精品国产精华液| 丝袜亚洲另类欧美综合| 国产成人精品三级麻豆| 欧美三级电影网站| 国产精品成人网| 亚洲国产成人av| 国产剧情一区二区| 欧美日韩成人综合天天影院 | 日韩电影免费在线观看网站| 成人手机电影网| 久久夜色精品一区| 久久激情五月激情| 欧美老女人第四色| 一区二区久久久久久| 国产成人精品一区二| 日韩欧美的一区| 免费在线观看日韩欧美| 欧美美女网站色| 亚洲一区二区在线免费看| 成人激情午夜影院| 日本一区二区三区高清不卡| 国内精品久久久久影院色| 欧美一区二区三区系列电影| 一级做a爱片久久| 国产91在线观看| 国产精品视频一二三区 | 精品亚洲国产成人av制服丝袜| 在线观看av一区二区| 亚洲一区二区av在线| 欧美日韩亚洲综合| 日韩精品免费视频人成| 欧美r级在线观看| 韩日欧美一区二区三区| 国产嫩草影院久久久久| 不卡在线观看av| 亚洲主播在线播放| 欧美一级片免费看| 国产成人av一区二区| 综合色中文字幕| 4438x亚洲最大成人网| 国产综合久久久久久久久久久久| 久久蜜桃av一区精品变态类天堂 | 精品一区二区免费视频| 26uuu国产一区二区三区| 99久久免费视频.com| 蜜臀av性久久久久蜜臀aⅴ| 日本一区二区三级电影在线观看| 99精品视频免费在线观看| 亚洲成人自拍一区| 亚洲国产精品二十页| 欧美日韩国产精品自在自线| 国产麻豆精品视频| 亚洲va韩国va欧美va精品 | 成人国产一区二区三区精品| 一区二区视频在线看| 精品日韩一区二区| 在线免费亚洲电影| 成人sese在线| 国产米奇在线777精品观看| 亚瑟在线精品视频| 亚洲日本电影在线| 久久久久久99久久久精品网站| www.久久精品| 日韩av不卡一区二区| 亚洲最大成人综合| 国产亚洲成aⅴ人片在线观看| 在线观看亚洲成人| 成人免费高清在线| 国产乱码精品一区二区三区忘忧草 | av在线免费不卡| 国产剧情一区二区三区| 精品在线免费视频| 日本系列欧美系列| 日韩二区三区四区| 视频在线观看一区二区三区| 玉米视频成人免费看| 国产精品久久99| 亚洲色图视频网| 亚洲三级在线观看| 亚洲欧美aⅴ...| 一区二区三区在线看| 亚洲自拍偷拍图区| 亚洲精品国产精品乱码不99| 国产日本欧洲亚洲| 国产精品国产精品国产专区不蜜| 26uuu亚洲综合色欧美| 久久久一区二区| 国产欧美精品一区二区色综合| 欧美精品一区二区高清在线观看| 欧美刺激脚交jootjob| 精品国产91久久久久久久妲己 | 欧美日韩在线亚洲一区蜜芽| 欧美吻胸吃奶大尺度电影| 欧美一区二区三区的| www国产精品av| 亚洲欧美日韩一区二区三区在线观看| 亚洲女同一区二区| 日本成人在线网站| 成人黄色软件下载| 欧美乱妇一区二区三区不卡视频| 久久久不卡网国产精品二区 | 一区二区久久久久久| 国内偷窥港台综合视频在线播放| 99久久精品国产一区二区三区| 国产激情一区二区三区四区 | 日本黄色一区二区| 欧美一区二区在线免费播放| 国产欧美日韩三级| 亚洲成人av免费| 成人在线视频一区| 日韩免费成人网| 亚洲成在人线免费| 99re热这里只有精品免费视频| 欧美日韩精品福利| 国产精品久久久99| 国产激情视频一区二区在线观看 | eeuss鲁一区二区三区| 日韩一区二区精品葵司在线| 亚洲一卡二卡三卡四卡无卡久久| 国产风韵犹存在线视精品| 日韩女优制服丝袜电影| 亚洲国产精品久久久久婷婷884| 成人网在线免费视频| 色欧美乱欧美15图片| 亚洲国产成人私人影院tom| 麻豆91小视频| 日韩一区二区三区免费观看| 亚洲国产成人av网| 欧美网站一区二区| 亚洲成人福利片| 欧美视频在线播放| 午夜精品免费在线| 欧美日韩激情在线| 日韩精品每日更新| 欧美狂野另类xxxxoooo| 日韩国产一二三区| 日韩一区二区三区免费看| 美女视频黄免费的久久| 亚洲精品一区二区三区影院 | 喷水一区二区三区| 欧美videofree性高清杂交| 久久精品国产精品亚洲综合| 日韩一区二区在线免费观看| 久99久精品视频免费观看| 精品国产免费人成在线观看| 国产乱淫av一区二区三区| 国产精品家庭影院| 在线亚洲+欧美+日本专区| 五月婷婷久久综合| 欧美日韩亚洲综合在线| 久久综合综合久久综合| 国产精品天干天干在观线| av不卡一区二区三区| 日韩成人午夜精品| 国产亚洲精品资源在线26u| 91传媒视频在线播放| 日本不卡中文字幕| 国产精品久久久久久久久图文区| 91福利视频网站| 国产乱子伦一区二区三区国色天香| 国产精品久久福利| 精品电影一区二区三区 | 一区二区不卡在线播放| 欧美大片在线观看一区| av不卡在线观看| 国产一区二区精品久久99| 亚洲一区二区三区视频在线| 久久久噜噜噜久久中文字幕色伊伊| 91久久一区二区| 成人综合在线视频| 免费成人在线网站| 亚洲成av人**亚洲成av**| 亚洲视频免费观看| 欧美激情一区二区三区在线| 久久综合九色综合欧美98| 在线不卡中文字幕播放| 日韩三级免费观看| jlzzjlzz亚洲日本少妇|