Omni-wheel robot wheel speed calculation library

Revision:
2:e4b06a9b3ff2
Parent:
1:74cfff9b981e
--- a/omni.h	Mon Jun 20 00:40:33 2022 +0900
+++ b/omni.h	Mon Jun 20 21:28:05 2022 +0900
@@ -5,18 +5,14 @@
 template <size_t wheelSize>
 class Omni {
   public:
-    Omni(const std::array<float, wheelSize>& radians) : radians(radians) {
-        for(auto& out: m_outs) {
-            out = 0.0;
-        }
+    Omni(const std::array<float, wheelSize>& radians) : radians(radians) {}
+    
+    void computeXY(const float& x, const float& y, const float& a) {
+      computeCircular(std::hypot(x, y), std::atan2(x, y), a);
     }
     
-    void computeXY(float x, float y, float a) {
-      computeCircular(hypot(x, y), atan2(x, y), a);
-    }
-    
-    void computeCircular(float r, float rad, float a) {
-      for(int i = 0; i < wheelSize; i++) {
+    void computeCircular(const float& r, const float& rad, const float& a) {
+      for(size_t i = 0; i < wheelSize; i++) {
         m_outs[i] = sin(rad + radians[i]) * r + a;
       }
       const float maxOut = *std::max_element(m_outs.begin(), m_outs.end(), [](const auto& a, const auto& b){return std::abs(a) < std::abs(b);});