From: kanja Date: Wed, 11 Sep 2013 11:00:41 +0000 (+0900) Subject: ETBalanceRunner: balance API の turn を自力で計算してみた X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1a8bbdbbd23eb9e6111c47c194647b199845a41d;hp=7ea5c0c8b1c6d0412374ffde72d763f45aa2c94b;p=tondenhei%2Fet2013.git ETBalanceRunner: balance API の turn を自力で計算してみた --- diff --git a/ETBalanceRunner.cpp b/ETBalanceRunner.cpp index 835ad28..49cfd4d 100644 --- a/ETBalanceRunner.cpp +++ b/ETBalanceRunner.cpp @@ -20,7 +20,16 @@ ETBalanceRunner::~ETBalanceRunner(void) void ETBalanceRunner::Run(int forward, int turn) { S8 r,l; - balance_control(forward,turn,m_gyro.get(),m_gyrooffset,m_motorL.getCount(),m_motorR.getCount(),m_nxt.getBattMv(),&l,&r); + balance_control(forward,0,m_gyro.get(),m_gyrooffset,m_motorL.getCount(),m_motorR.getCount(),m_nxt.getBattMv(),&l,&r); + l = l + turn; + r = r - turn; + if(100 < l){ + r = r + (l - 100); + l = 100; + }else if(r < -100){ + l = l - (r - (-100)); + r = -100; + } m_motorL.setPWM(l); m_motorR.setPWM(r); } diff --git a/ETLineTracer.cpp b/ETLineTracer.cpp index 3cf078a..bd7f649 100644 --- a/ETLineTracer.cpp +++ b/ETLineTracer.cpp @@ -9,6 +9,6 @@ ETLineTracer::~ETLineTracer(void) } void ETLineTracer::CalcOutput(int speed, int linepos, int& forward, int& turn) { - forward = speed * 3 / 10; // ‚Æ‚è‚ ‚¦‚¸‚ÌŽÀ‘• + forward = speed * 7 / 10; // ‚Æ‚è‚ ‚¦‚¸‚ÌŽÀ‘• turn =static_cast(m_pid.CalcControlValue(static_cast(linepos))); }