1 #include "ETBalanceRunner.h"
\r
3 #include "GyroSensor.h"
\r
7 #include "balancer.h"
\r
12 ETBalanceRunner::ETBalanceRunner(Motor& motorL, Motor& motorR, GyroSensor& gyro, Nxt& nxt)
\r
13 : m_motorL(motorL), m_motorR(motorR), m_gyro(gyro), m_nxt(nxt), m_gyrooffset(610), m_bException(false), m_msec(0)
\r
17 ETBalanceRunner::~ETBalanceRunner(void)
\r
20 void ETBalanceRunner::Run(int forward, int turn)
\r
23 balance_control(forward,0,m_gyro.get(),m_gyrooffset,m_motorL.getCount(),m_motorR.getCount(),m_nxt.getBattMv(),&l,&r);
\r
24 JudgeException(l,r);
\r
35 l = l + (r - (-100));
\r
41 bool ETBalanceRunner::IsException() const
\r
43 return m_bException;
\r
45 void ETBalanceRunner::Stop()
\r
50 void ETBalanceRunner::Reset()
\r
53 m_bException = false;
\r
56 void ETBalanceRunner::SetGyroOffset(int offset)
\r
58 m_gyrooffset = offset;
\r
60 void ETBalanceRunner::JudgeException(int l,int r)
\r
62 static const int LIMIT = 2000; /* 2[sec] */
\r
63 if((l == 100 && r == 100) || (l == -100 && r == -100)){ /* +100
\82©-100
\82É
\92£
\82è
\95t
\82« */
\r
64 if(m_msec >= LIMIT){ /*
\88ê
\92è
\8e\9e\8aÔ
\81}100
\82ð
\88Û
\8e\9d\82µ
\82½
\82ç
\97á
\8aO */
\r
65 m_bException = true;
\r
68 m_msec += 4; /* +4[msec] */
\r