turn.c

来自「一个机器人提足球的代码!基于神经网络! 一个机器人提足球的代码!基于神经网络!」· C语言 代码 · 共 51 行

C
51
字号
#ifndef _TURN_
#define _TURN_
#include "HardwareInfo.c"
#include <SetSysTime.h>
#include <GetCompassB.h>
#include <GetSysTime.h>
#include <SetMotor.h>
#include <GetCompoI.h>

void turn(unsigned char jGuan)
{
    unsigned int degree = 0;   //指南针返回值
    unsigned long t = 0;   //系统时间
    unsigned char fy3 = 0;   //当前3号复眼通道
    unsigned char fy4 = 0;   //当前4号复眼通道
    unsigned char fy5 = 0;   //当前5号复眼通道
    unsigned int p1 = 45;   //场定义角
    unsigned int p2 = 315;   //场定义角
    t=0;
    SetSysTime(0);
    while ( ((degree>5)&&(degree<355))  )
    {
        degree = GetCompassB(_COMPASS_jd_);
        t = GetSysTime();
        if ( t>100 )
        {
            break;
        }
    }
    SetMotor(_MOTOR_left_, 2, 100);
    SetMotor(_MOTOR_right_, 2, 80);
    degree = GetCompassB(_COMPASS_jd_);
    t=0;
    SetSysTime(0);
    fy3 = GetCompoI(_COMPOUNDEYE_fy_, 3);
    fy4 = GetCompoI(_COMPOUNDEYE_fy_, 4);
    fy5 = GetCompoI(_COMPOUNDEYE_fy_, 5);
    while ( ((fy3<jGuan||fy4<jGuan || fy5 <jGuan) && ((degree<p1) ||(degree>p2))) && (t<60) )
    {
        degree = GetCompassB(_COMPASS_jd_);
        fy3 = GetCompoI(_COMPOUNDEYE_fy_, 3);
        fy4 = GetCompoI(_COMPOUNDEYE_fy_, 4);
        fy5 = GetCompoI(_COMPOUNDEYE_fy_, 5);
        t = GetSysTime();
    }
    t=0;
    SetSysTime(0);
}
#endif

⌨️ 快捷键说明

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