OSDN Git Service

ETBalanceRunner: balance API の turn を自力で計算してみた
authorkanja <hoge@hoge.hg>
Wed, 11 Sep 2013 11:00:41 +0000 (20:00 +0900)
committerkanja <hoge@hoge.hg>
Wed, 11 Sep 2013 11:00:41 +0000 (20:00 +0900)
ETBalanceRunner.cpp
ETLineTracer.cpp

index 835ad28..49cfd4d 100644 (file)
@@ -20,7 +20,16 @@ ETBalanceRunner::~ETBalanceRunner(void)
 void ETBalanceRunner::Run(int forward, int turn)\r
 {\r
        S8 r,l;\r
-       balance_control(forward,turn,m_gyro.get(),m_gyrooffset,m_motorL.getCount(),m_motorR.getCount(),m_nxt.getBattMv(),&l,&r);\r
+       balance_control(forward,0,m_gyro.get(),m_gyrooffset,m_motorL.getCount(),m_motorR.getCount(),m_nxt.getBattMv(),&l,&r);\r
+       l = l + turn;\r
+       r = r - turn;\r
+       if(100 < l){\r
+               r = r + (l - 100);\r
+               l = 100;\r
+       }else if(r < -100){\r
+               l = l - (r - (-100));\r
+               r = -100;\r
+       }\r
        m_motorL.setPWM(l);\r
        m_motorR.setPWM(r);\r
 }\r
index 3cf078a..bd7f649 100644 (file)
@@ -9,6 +9,6 @@ ETLineTracer::~ETLineTracer(void)
 }\r
 void ETLineTracer::CalcOutput(int speed, int linepos, int& forward, int& turn)\r
 {\r
-       forward = speed * 3 / 10;       // \82Æ\82è\82 \82¦\82¸\82Ì\8eÀ\91\95\r
+       forward = speed * 7 / 10;       // \82Æ\82è\82 \82¦\82¸\82Ì\8eÀ\91\95\r
        turn =static_cast<int>(m_pid.CalcControlValue(static_cast<float>(linepos)));\r
 }\r