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

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

?? rp6base_move_04.c

?? RP6機器人范例程序。包括移動
?? C
字號:
/* 
 * ****************************************************************************
 * RP6 ROBOT SYSTEM - ROBOT BASE EXAMPLES
 * ****************************************************************************
 * Example: Movement 4 - Subsumption based Robot
 * Author(s): Dominik S. Herwald
 * ****************************************************************************
 * Description:
 *
 * This is a rather complex example - here we use the principle published
 * by Rodney Brooks in the 1980's called "Subsumption Architechture" and
 * the principle of Behaviour based robots.
 *
 * s. (English original publication):
 * http://people.csail.mit.edu/brooks/papers/AIM-864.pdf
 *
 * s. (German, short summary):
 * http://www.igi.tugraz.at/STIB/WS98/Bergmann/einleitung.htm
 *
 * Basically, this is the way we can make our robot act like a simple
 * insect - e.g. like a Moth or an Ant.
 *
 * We start things off with the two "tentacles" our simple insect has - the
 * bumpers at the front of the robot.
 * 
 * In the previous example, we have seen how Finite State Machines work. 
 * Now we can use them to implement different behaviours.
 * 
 * In this example we only have the "Cruise" and the "Escape" behaviours.
 * The Cruise behaviour tells the robot to move straight forward all the time.
 * The Escape behaviour gets active when the robot hits an obstacle with its 
 * bumpers. Then this behaviour initiates a reaction: it stops the robot, 
 * moves back a few cm, turns left or right by a few degrees, depending on which 
 * bumper was hit and returns control to the Cruise behaviour afterwards.
 *
 * The reaction of the Escape behaviour also depends on how often the bumpers were 
 * hit - this allows the robot to escape from "hang up" situations when it loops 
 * around between two obstacles that are close to each other.
 *
 * Well - just let this program run, then you will see what it does.
 *
 *
 * A small Exercise:
 * There is a little problem with this program! 
 * The Robot can easily get into dead lock situations like this and does
 * not find the way out anymore. 
 * You only need to change TWO lines of code to solve this problem...
 * Think about it!
 *
 * ############################################################################
 * #+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+
 * 
 * ATTENTION: THE ROBOT MOVES AROUND IN THIS EXAMPLE! PLEASE PROVIDE ABOUT
 * 2m x 2m OR MORE FREE SPACE FOR THE ROBOT! 
 *
 * >>> DO NOT FORGET TO REMOVE THE FLAT CABLE CONNECTION TO THE USB INTERFACE
 * BEFORE YOU START THIS PROGRAM BY PRESSING THE START BUTTON ON THE ROBOT!
 *
 * #+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+
 * ############################################################################
 * ****************************************************************************
 */

/*****************************************************************************/
// Includes:

#include "RP6RobotBaseLib.h" 	

/*****************************************************************************/
// Here we define a Behaviour command data type - this makes life easier. 
// These structures contain all required information for movement request and 
// current state of our behaviours. 
// If you want to learn more about structs, unions and typedefs, read some of 
// the C-Tutorials we suggest in the manual!

#define IDLE  0

// The behaviour command data type:
typedef struct {
	uint8_t  speed_left;  // left speed (is used for rotation and 
						  // move distance commands - if these commands are 
						  // active, speed_right is ignored!)
	uint8_t  speed_right; // right speed (if required...)
	unsigned dir:2;       // direction (FWD, BWD, LEFT, RIGHT)
	unsigned move:1;      // move flag
	unsigned rotate:1;    // rotate flag
	uint16_t move_value;  // move value is used for distance and angle values
	uint8_t  state;       // state of the behaviour
} behaviour_command_t;


/*****************************************************************************/
// Cruise Behaviour:

#define CRUISE_SPEED_FWD    80  // Default speed when no obstacles are detected!

#define MOVE_FORWARDS 1
behaviour_command_t cruise = {CRUISE_SPEED_FWD, CRUISE_SPEED_FWD, FWD, 
								false, false, 0, MOVE_FORWARDS};

/**
 * We don't have anything to do here - this behaviour has only
 * a constant value for moving forwards - s. above!
 * Of course you can change this and add some random or timed movements 
 * in here...
 */
void behaviour_cruise(void)
{
}

/*****************************************************************************/
// Escape Behaviour:

// Some constants:
#define ESCAPE_SPEED_BWD    60
#define ESCAPE_SPEED_ROTATE 50

// States for the FSM of this behaviour:
#define ESCAPE_FRONT_START 	1
#define ESCAPE_FRONT_WAIT 	2
#define ESCAPE_LEFT_START  	3
#define ESCAPE_LEFT_WAIT	4
#define ESCAPE_RIGHT_START  5
#define ESCAPE_RIGHT_WAIT 	6
#define ESCAPE_WAIT_END		7
behaviour_command_t escape = {0, 0, FWD, false, false, 0, IDLE}; 

/**
 * This is the Escape behaviour for the Bumpers - remember the last FSM examples!
 * This is also a FSM - just with some more transitions between the states.
 */
void behaviour_escape(void)
{
	static uint8_t bump_count = 0;
	switch(escape.state)
	{
		case IDLE: 
			// We have no obstacles detected. Obstacles are detected in the
			// bumpersStateChanged function below!
			// Alternatively you could also put that code in here, but
			// when it is in the event handler below, it can also change this
			// behaviour when it is not in the idle state!
			// (when the robot is running, just hit a bumper several times with
			// your hand while it is moving backwards!)
		break;
		case ESCAPE_FRONT_START:
			escape.speed_left = ESCAPE_SPEED_BWD;
			escape.dir = BWD;
			escape.move = true;
			if(bump_count > 3)
				escape.move_value = 180;
			else
				escape.move_value = 120;
			escape.state = ESCAPE_FRONT_WAIT;
			bump_count+=2;
		break;
		case ESCAPE_FRONT_WAIT:			
			if(!escape.move) 
			{
				escape.speed_left = ESCAPE_SPEED_ROTATE;
				if(bump_count > 3)
				{
					escape.move_value = 90;
					escape.dir = RIGHT;
					bump_count = 0;
				}
				else 
				{
					escape.dir = LEFT;
					escape.move_value = 50;
				}
				escape.rotate = true;
				escape.state = ESCAPE_WAIT_END;
			}
		break;
		case ESCAPE_LEFT_START:
			escape.speed_left = ESCAPE_SPEED_BWD;
			escape.dir 	= BWD;
			escape.move = true;
			if(bump_count > 3)
				escape.move_value = 160;
			else
				escape.move_value = 100;
			escape.state = ESCAPE_LEFT_WAIT;
			bump_count++;
		break;
		case ESCAPE_LEFT_WAIT:
			if(!escape.move)
			{
				escape.speed_left = ESCAPE_SPEED_ROTATE;
				escape.dir = RIGHT;
				escape.rotate = true;
				if(bump_count > 3)
				{
					escape.move_value = 80;
					bump_count = 0;
				}
				else
					escape.move_value = 45;
				escape.state = ESCAPE_WAIT_END;
			}
		break;
		case ESCAPE_RIGHT_START:
			escape.speed_left = ESCAPE_SPEED_BWD;
			escape.dir 	= BWD;
			escape.move = true;
			if(bump_count > 3)
				escape.move_value = 160;
			else
				escape.move_value = 100;
			escape.state = ESCAPE_RIGHT_WAIT;
			bump_count++;
		break;
		case ESCAPE_RIGHT_WAIT:
			if(!escape.move)
			{
				escape.speed_left = ESCAPE_SPEED_ROTATE;		
				escape.dir = LEFT;
				escape.rotate = true;
				if(bump_count > 3)
				{
					escape.move_value = 80;
					bump_count = 0;
				}
				else
					escape.move_value = 45;
				escape.state = ESCAPE_WAIT_END;
			}
		break;
		case ESCAPE_WAIT_END:
			if(!(escape.move || escape.rotate))
				escape.state = IDLE;
		break;
	}
}

/**
 * Bumpers Event handler
 */
void bumpersStateChanged(void)
{
	if(bumper_left && bumper_right) // Both Bumpers were hit
	{
		escape.state = ESCAPE_FRONT_START;
	}
	else if(bumper_left)  			// Left Bumper was hit
	{
		if(escape.state != ESCAPE_FRONT_WAIT) 
			escape.state = ESCAPE_LEFT_START;
	}
	else if(bumper_right) 			// Right Bumper was hit
	{
		if(escape.state != ESCAPE_FRONT_WAIT)
			escape.state = ESCAPE_RIGHT_START;
	}
}

/*****************************************************************************/
// Behaviour control:

/**
 * This function processes the movement commands that the behaviours generate. 
 * Depending on the values in the behaviour_command_t struct, it sets motor
 * speed, moves a given distance or rotates.
 *
 * A small remark: with "->" you can access fields in 
 * structs of which you only have a pointer like it is here ( * cmd ).  
 * You can NOT use "." there - like "avoid.state" for example!
 * Read one of the C Tutorials suggested in the manual for more details!
 */
void moveCommand(behaviour_command_t * cmd)
{
	if(cmd->move_value > 0)  // any move/rotate commands?
	{
		if(cmd->rotate) 
			rotate(cmd->speed_left, cmd->dir, cmd->move_value, false); 
		else if(cmd->move) 
			move(cmd->speed_left, cmd->dir, DIST_MM(cmd->move_value), false); 
		cmd->move_value = 0; // clear move value - the move commands are only
		                     // given once and then runs in background.
	}
	else if(!(cmd->move || cmd->rotate)) // just move at speed? 
	{
		changeDirection(cmd->dir);
		moveAtSpeed(cmd->speed_left,cmd->speed_right);
	}
	else if(isMovementComplete()) // movement complete? --> clear flags!
	{
		cmd->rotate = false;
		cmd->move = false;
	}
}

// Define a default movement command:
behaviour_command_t STOP = {0, 0, FWD, false, false, 0, IDLE};

/**
 * The behaviourController task controls the subsumption architechture. 
 * It implements the priority levels of the different behaviours. 
 * In this Example we only have two behaviours, but of course there can be
 * a lot more! 
 */
void behaviourController(void)
{
    // Call all the behaviour tasks:
	behaviour_cruise();
	behaviour_escape();

    // Execute the commands depending on priority levels:
	if(escape.state != IDLE) // Highest priority (2)
		moveCommand(&escape);
	else if(cruise.state != IDLE) // Lower priority (1)
		moveCommand(&cruise); 
	else                     // Lowest priority (0)
		moveCommand(&STOP);  // Default command - do nothing! 
							 // In the current implementation this never 
							 // happens.
}

/*****************************************************************************/
// Main:

int main(void)
{
	initRobotBase(); 
	setLEDs(0b111111);
	mSleep(2500);
	setLEDs(0b100100); 

	// Set Bumpers state changed event handler:
	BUMPERS_setStateChangedHandler(bumpersStateChanged);
	
	powerON(); // Turn on Encoders, Current sensing, ACS and Power LED.

	// Main loop
	while(true) 
	{		
		behaviourController();
		task_RP6System();
	}
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av电影天堂一区二区在线观看| 欧美嫩在线观看| 懂色av一区二区三区免费看| 人人狠狠综合久久亚洲| 亚洲国产精品尤物yw在线观看| 亚洲天堂网中文字| 一区二区三区毛片| 午夜欧美在线一二页| 爽好多水快深点欧美视频| 日韩vs国产vs欧美| 国产东北露脸精品视频| 91麻豆成人久久精品二区三区| 欧美精品电影在线播放| 欧美精品自拍偷拍动漫精品| 精品区一区二区| 亚洲乱码一区二区三区在线观看| 午夜精品成人在线| 成人精品视频一区| 欧美一区二区久久| 国产精品美女久久久久久2018| 亚洲精品va在线观看| 国产黑丝在线一区二区三区| 欧美日韩久久一区二区| 国产精品久久久久精k8| 久久www免费人成看片高清| 色素色在线综合| 国产日产欧美一区二区视频| 亚洲永久精品大片| 91女人视频在线观看| 中文子幕无线码一区tr| 美女视频黄 久久| 欧美日韩国产综合草草| 亚洲乱码国产乱码精品精的特点| 国产剧情在线观看一区二区| 日韩一级成人av| 樱桃国产成人精品视频| 欧美艳星brazzers| 一区av在线播放| 欧美日韩精品专区| 日韩av在线发布| 日韩一区二区三区精品视频| 老司机午夜精品| 久久这里只精品最新地址| 国产精品自拍在线| 国产精品毛片久久久久久久| 国产99精品视频| 亚洲成人动漫精品| 欧美国产乱子伦| 色婷婷亚洲综合| 美女在线观看视频一区二区| 久久色在线视频| 色综合久久久网| 奇米影视在线99精品| 国产精品乱码一区二区三区软件| 91色九色蝌蚪| 国产一区二区三区综合| 一区二区三区在线视频观看| 久久久影视传媒| 5566中文字幕一区二区电影| 成人爱爱电影网址| 狠狠色丁香婷婷综合久久片| 亚洲综合一二区| 国产精品久久午夜| 中文字幕不卡在线| 久久综合狠狠综合久久综合88| 欧美中文字幕亚洲一区二区va在线| 精品一区二区久久| 国产永久精品大片wwwapp| 亚洲一区免费观看| 国产精品成人免费| 亚洲天堂成人在线观看| 国产精品―色哟哟| 中文字幕视频一区| 亚洲美女偷拍久久| 亚洲色图在线播放| 亚洲欧美一区二区三区孕妇| 国产精品私人影院| 亚洲靠逼com| 日韩激情在线观看| 国产一区在线看| 成人app软件下载大全免费| 成年人午夜久久久| 欧美三级蜜桃2在线观看| 欧美日韩一级黄| 久久综合九色综合97婷婷| 国产午夜精品一区二区三区视频 | 日韩黄色免费网站| 久久99精品国产91久久来源| 国产xxx精品视频大全| 99视频国产精品| 日韩一区二区精品| 国产欧美日韩三级| 日韩精品乱码免费| 99精品热视频| 日韩精品一区国产麻豆| 最新国产の精品合集bt伙计| 天天av天天翘天天综合网 | 秋霞午夜鲁丝一区二区老狼| 成人av在线资源网站| 欧美福利视频一区| 国产精品麻豆网站| 国产传媒欧美日韩成人| 91精品视频网| 午夜精品久久久久影视| aa级大片欧美| 国产精品久久毛片| 国产专区综合网| 26uuu精品一区二区三区四区在线| 日本一区免费视频| 亚洲人吸女人奶水| 欧美一区三区二区| 国产婷婷色一区二区三区| 综合在线观看色| 色婷婷一区二区| 一区二区三区中文字幕电影 | 亚洲毛片av在线| 99精品国产热久久91蜜凸| 日韩伦理免费电影| 成人高清视频在线| 亚洲男人天堂av网| 制服丝袜日韩国产| 蜜桃传媒麻豆第一区在线观看| 欧美一区二区网站| 国产精华液一区二区三区| 国产精品国产三级国产aⅴ入口 | 欧美电影一区二区| 精品一区二区三区的国产在线播放| 精品国产123| 在线精品视频一区二区三四| 美国十次综合导航| 国产精品国产自产拍在线| 欧美乱妇23p| www.日韩av| 麻豆精品久久久| 亚洲最新在线观看| 国产精品网站导航| 精品嫩草影院久久| 欧美另类videos死尸| 在线视频国内一区二区| 国产精品一区二区在线看| 亚洲福利一区二区| 亚洲精品免费看| 国产午夜精品久久久久久免费视 | 成人精品在线视频观看| 日韩av在线免费观看不卡| 亚洲欧洲av色图| 欧美国产丝袜视频| 国产欧美精品一区二区色综合 | 日韩制服丝袜av| 天堂久久久久va久久久久| 一区二区三区产品免费精品久久75| 久久亚洲一级片| 欧美激情一区二区| 国产精品免费视频网站| 中文字幕国产一区二区| 亚洲欧洲成人精品av97| 亚洲卡通动漫在线| 亚洲综合成人在线视频| 日日摸夜夜添夜夜添国产精品| 亚洲电影你懂得| 韩国女主播一区| av电影在线不卡| 欧美精品18+| 中文字幕一区在线观看| 偷拍一区二区三区| 国产一区二区调教| 日本在线不卡视频一二三区| 五月天视频一区| 国产老肥熟一区二区三区| 99久久伊人久久99| 欧美性生活一区| 精品久久久久av影院| 亚洲手机成人高清视频| 怡红院av一区二区三区| 奇米在线7777在线精品| 日本精品视频一区二区| 久久天堂av综合合色蜜桃网| 午夜精品久久久久久久久久久| 狠狠色狠狠色综合系列| 在线成人小视频| 最新成人av在线| 国产1区2区3区精品美女| 欧美一区二区三区人| 亚洲成av人片在线观看无码| 成人黄色免费短视频| 久久精品日韩一区二区三区| 免费在线观看日韩欧美| 欧美军同video69gay| 亚洲成人动漫av| 欧美日韩国产另类一区| 五月天激情小说综合| 精品视频1区2区| 日韩电影在线免费看| 69av一区二区三区| 久久国产精品99久久人人澡| 久久天堂av综合合色蜜桃网| 国产制服丝袜一区| 中文字幕在线播放不卡一区| 一本一道久久a久久精品| 五月天久久比比资源色|