找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
MakerMare-创客海社区 门户 查看主题

视频教程之循线试飞前的场地检查方法

发布者: 凡哥 | 发布时间: 2019-2-24 01:29 PM| 查看数: 1366| 评论数: 4|帖子模式

目前支持微信扫码直接登陆 或邮箱验证注册登陆,结交更多好友,享用更多功能,让你轻松玩转社区!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
QQ截图20190226003215.png 循线试飞前的场地检查方法

最新评论

凡哥 发表于 2019-3-27 16:59:49
玩物者四轴PID参数.png
凡哥 发表于 2019-3-27 17:13:55
[C] 纯文本查看 复制代码
//循迹控制,控制频率50hz
void Tracking_Ctrl(float dT)
{
	if(Follow_Line_Mode==0 || Follow_Line_En==0) 
	{
		Walk_Ctrl(S,0);
		tracking.time = 0;
		tracking.dir = S;
		return;
	}
	
	tracking.time += dT;//计时
	
	switch(tracking.dir)
	{
		case S://刚起飞悬停
			
			if( tracking.time>HOVER_TIME )
			{
				//判断飞行方向
				if		 (line.up_ok)    tracking.dir = F;
				else if(line.left_ok)  tracking.dir = L;
				else if(line.right_ok) tracking.dir = R;
				else if(line.down_ok)  tracking.dir = B;
				else                   tracking.dir = END;
				
				tracking.step = 0;
				tracking.time = 0;
			}
			else Walk_Ctrl(S,0);
			
		break;
		
		case F://往前走
		case B://往后走

			switch(tracking.step)
			{
				case 0:
					
					//悬停几秒后,往目标方向飞行
					if( tracking.time>HOVER_TIME )
					{
						tracking.step = 1;
						tracking.speed = TRACKING_SPEED;
						Walk_Ctrl(tracking.dir,tracking.speed);
					}
					else Walk_Ctrl(S,0);
					
				break;
				
				case 1:
					
					//判断是否已经往目标方向飞行
					if(line.left_ok==0 && line.right_ok==0)
					{
						tracking.step = 2;
					}
					Walk_Ctrl(tracking.dir,tracking.speed);
					
				break;
					
				case 2:
					
					//到达路口后判断飞行方向
					if( (tracking.dir==B && line.down_ok==0) ||
							(tracking.dir==F && line.up_ok==0)    )
					{
						if( line.left_ok && line.right_ok ) tracking.dir = END;
						else if(line.left_ok)  							tracking.dir = L;
						else if(line.right_ok) 							tracking.dir = R;
						else									 							tracking.dir = NUL;
						
						tracking.step = 0;
						tracking.time = 0;
					}
					else
					{
						tracking.speed = TRACKING_SPEED * cos(line.angle*ANG_2_RAD);//转弯时减速
						Walk_Ctrl(tracking.dir,tracking.speed);
					}
					
				break;
			}
			
		break;
		
		case L://往左走
		case R://往右走
			
			switch(tracking.step)
			{
				case 0:
					
					//悬停几秒后,往目标方向飞行
					if( tracking.time>HOVER_TIME )
					{
						tracking.step = 1;
						tracking.speed = TRACKING_SPEED;
						Walk_Ctrl(tracking.dir,tracking.speed);
					}
					else Walk_Ctrl(S,0);
					
				break;
					
				case 1:
					
					//判断是否已经往目标方向飞行
					if(line.up_ok==0 && line.down_ok==0)	
					{
						tracking.step = 2;
					}
					Walk_Ctrl(tracking.dir,tracking.speed);
					
				break;
					
				case 2:
					
					//到达路口后判断飞行方向
					if( (tracking.dir==L && line.left_ok==0) ||
							(tracking.dir==R && line.right_ok==0) )
					{
						if( line.up_ok && line.down_ok ) tracking.dir = END;
						else if(line.up_ok)   					 tracking.dir = F;
						else if(line.down_ok) 					 tracking.dir = B;
						else														 tracking.dir = NUL;
						
						tracking.step = 0;
						tracking.time = 0;
					}
					else
					{
						tracking.speed = TRACKING_SPEED * cos(line.angle*ANG_2_RAD);//转弯时减速
						Walk_Ctrl(tracking.dir,tracking.speed);
					}
					
				break;
			}
			
		break;
		
		case END://定点降落

			Walk_Ctrl(S,0);
			if(tracking.time>HOVER_TIME) auto_landing = 1;
			
		break;
		
		case NUL://降落

			auto_landing = 1;
			
		break;
		
		default: break;
	}
}

LZW 发表于 2019-5-18 20:26:57
玩物者四轴,想让其寻白色,如何调?
凡哥 发表于 2019-5-22 19:34:09
LZW 发表于 2019-5-18 08:26 PM
玩物者四轴,想让其寻白色,如何调?

调整MiniOpenMV颜色阈值