From 75e795a0a01de7a0cb3c5a1febec59b4e976ee9b Mon Sep 17 00:00:00 2001
From: RicardoEA <ricardo@focus.uy>
Date: Wed, 2 Nov 2022 18:50:45 -0300
Subject: [PATCH] =?UTF-8?q?Implementaci=C3=B3n=20cuadrado=20usando=20omni?=
 =?UTF-8?q?=5Fdrive?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Robotito/src/main.c | 88 +++++++++++++++++++++++----------------------
 1 file changed, 45 insertions(+), 43 deletions(-)

diff --git a/Robotito/src/main.c b/Robotito/src/main.c
index 3c7c29f..1e9ecd8 100644
--- a/Robotito/src/main.c
+++ b/Robotito/src/main.c
@@ -23,50 +23,52 @@
 #define NMOTORS 3
 #define OMNI_NRO_TIMER 0
 
-
-
-static void timer_func() {
-    printf("ECHO TIMER \n");
-}
-
 void app_main(void)
 {
-
-    //1. mcpwm gpio initialization
-    motor_h_t *mot0;
-    motor_h_t *mot2;
-    
-    motor_install(26,27, MCPWM_UNIT_0, MCPWM0A, MCPWM0B, MCPWM_TIMER_0, &mot0);
-    motor_install(18,23, MCPWM_UNIT_1, MCPWM1A, MCPWM1B, MCPWM_TIMER_1, &mot2);
-    // pines de los motores 
-    //                      Motor 0: 26,27      Encoder 0: 37, 39
-    //                      Motor 1: 25,33      Encoder 1: 36, 38
-    //                      Motor 2: 18,23      Encoder 2: 34, 35
-    //2. initial mcpwm configuration
     printf("Configuring Initial Parameters of mcpwm...\n");
-    motor_start(mot0);    //Configure PWM0A & PWM0B with above settings
-    motor_start(mot2);
-
-    int inc = 10;
-    while (1) {        
-        
-        motor_set_speed(mot0, inc);
-        motor_set_speed(mot2, inc);
-        vTaskDelay(2000 / portTICK_RATE_MS);
-        motor_stop(mot0);
-        motor_stop(mot2);
-        vTaskDelay(2000 / portTICK_RATE_MS);
-        motor_set_speed(mot0, inc);
-        motor_set_speed(mot2, -inc);
-        vTaskDelay(2000 / portTICK_RATE_MS);
-        motor_stop(mot0);
-        motor_stop(mot2);
-        vTaskDelay(2000 / portTICK_RATE_MS);
-        
-        inc++;
-        if (inc == 30){
-            inc = 10;
+    omni_init();
+    omni_set_enable(true);
+    int vel;
+    while (1) {       
+        for (size_t i = 100; 98 < i; i--)
+        {
+            vel = i;
+            printf("---------------------------------------------------------------------\n");
+            printf("Busco vel=%d\n",vel);
+            printf("---------------------------------------------------------------------\n");
+            omni_drive(vel,0,0,0);
+            vTaskDelay( 1000/ portTICK_RATE_MS);
         }
-    }
-}
-
+        omni_drive(0,0,0,0);
+        vTaskDelay(1000/ portTICK_RATE_MS);
+        for (size_t i = 100; 98 < i; i--)
+        {
+            vel = i;
+            printf("---------------------------------------------------------------------\n");
+            printf("Busco vel=%d\n",vel);
+            printf("---------------------------------------------------------------------\n");
+            omni_drive(0,vel,0,0);
+            vTaskDelay( 1000/ portTICK_RATE_MS);
+        }
+        for (size_t i = 100; 98 < i; i--)
+        {
+            vel = i;
+            printf("---------------------------------------------------------------------\n");
+            printf("Busco vel=%d\n",vel);
+            printf("---------------------------------------------------------------------\n");
+            omni_drive(-vel,0,0,0);
+            vTaskDelay( 1000/ portTICK_RATE_MS);
+        }
+        omni_drive(0,0,0,0);
+        vTaskDelay(1000/ portTICK_RATE_MS);
+        for (size_t i = 100; 98 < i; i--)
+        {
+            vel = i;
+            printf("---------------------------------------------------------------------\n");
+            printf("Busco vel=%d\n",vel);
+            printf("---------------------------------------------------------------------\n");
+            omni_drive(0,-vel,0,0);
+            vTaskDelay( 1000/ portTICK_RATE_MS);
+        }
+    } 
+}
\ No newline at end of file
-- 
GitLab