⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deathhandle.c

📁 机器人足球教程footballteaching
💻 C
字号:
#include "HardwareInfo.c"
#include <SetSysTime.h>
#include <GetCompassB.h>
#include <GetSysTime.h>
#include <GetCompoI.h>
#include "checkDeath.c"
#include <SetMotor.h>
#include <SetTenthS.h>
#include "findBall.c"
//#include <util/IncludeAll.h>

// define global var
unsigned int beginDeathHeading = 0;   //全局变量,其存储上一循环时的角度,也就是刚卡死时的角度;
unsigned long beginDeathTime = 0;   //全局变量,其存储上一循环时的时间,也就是刚卡死时的时间
unsigned int g_distanceLeft = 0;

int main(void)
{
    unsigned char fyMax = 0;   //当前复眼通道的最大值。
    unsigned char minValue = 0;   //当前复眼通道的最小值。
    unsigned char i = 0;   //checkDeath()的返回值
    unsigned long t = 0;   //系统时间
    unsigned char yfy = 40;   //近距离复眼的光值,一般是指无球的情况
    unsigned int b = 0;   //指南针的返回值
    unsigned char jGuan = 200;   //近距离的光值。
    unsigned char var0 = 10;
    unsigned char maxIndex = 0;
    SetSysTime(0);
    beginDeathHeading = GetCompassB(_COMPASS_1_);
    beginDeathTime = GetSysTime();
    while (1)
    {
        fyMax = GetCompoI(_COMPOUNDEYE_Guan_, 9);
        minValue = GetCompoI(_COMPOUNDEYE_Guan_, 11);
        if ( (fyMax>yfy)||(fyMax-minValue>var0) )
        {
            i = checkDeath(15);
            if ( i )
            {
                beginDeathHeading = GetCompassB(_COMPASS_1_);
                if ( beginDeathHeading>180 )
                {
                    SetMotor(_MOTOR_left_, 0, 100);
                    SetMotor(_MOTOR_right_, 2, 100);
                    SetTenthS(3);
                }
                else
                {
                    SetMotor(_MOTOR_left_, 2, 100);
                    SetMotor(_MOTOR_right_, 0, 100);
                    SetTenthS(3);
                }
            }
            findBall(jGuan);
        }
        else
        {
            SetMotor(_MOTOR_left_, 2, 50);
            SetMotor(_MOTOR_right_, 0, 50);
        }
    }
    return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -