ほぼ完成

Dependencies:   EC2 Math mbed

Fork of f3rc_3_auto_lintrace_905 by 2018F3RC3班

main.cpp

Committer:
Shunsaku
Date:
2018-08-29
Revision:
1:0fe1b3af8053
Parent:
0:260f1d62f487
Child:
2:d857188289be

File content as of revision 1:0fe1b3af8053:

#include "mbed.h"
#include "Math.h"
#include "Ec.h"
#include "SpeedController.h"
DigitalOut cylinder(p9);
DigitalOut cylindert(p10);
DigitalIn encoder1a(p11);
DigitalIn encoder1b(p12);
DigitalIn encoder2a(p13);
DigitalIn encoder2b(p14);
AnalogIn LBR1(p17,PullUp);
AnalogIn LBR2(p18,PullUp);
AnalogIn LBR3(p19,PullUp);
AnalogIn LBR4(p20,PullUp);
PwmOut servo12(p21);
PwmOut servo3(p22);
PwmOut motor1(p25);
PwmOut motor2(p26);
DigitalOut motor1cw(p27);
DigitalOut motor2cw(p28);

int old3,old4,now3,now4 = 0;
double basePower;
double Kp = ;
double Kd = ;
void linetrace;

int main()
{
    motor1.period_us(50);
    motor2.period_us(50);
    motor1cw = 0;
    motor2cw = 1;
    basePower = 0.5;
    while(LBR1.read() >  && LBR2.read() > ) {//ライントレース部分
        linetrace();
    }
    
    while(/*条件をかけや*/) {//ラインによる位置調整
        double Kp = ;
        motor1cw = 0;
        motor2cw = 1;
        motor1 =
            motor2 =
    }
}

void linetrace()
{
    old3 = now3;
    old4 = now4;
    now3 = 1000*LBR3.read();
    now4 = 1000*LBR4.read();
    double steering = Kp*(now3 - now4) + Kd*(now3 - now4 - (old3 - old4));
    motor1 = basePower + steering;
    motor2 = basePower - steering;
}