PSL_2021 / Mbed OS recepteur_mbed_os_6

Dependencies:   servomotor_MX12_Lorenzo nRF24L01P dribble

Fork of recepteur_mbed_os_6 by Martin Raynaud

Files at this revision

API Documentation at this revision

Comitter:
martinr
Date:
Wed Jun 15 13:06:30 2022 +0000
Parent:
0:1294dd3b7664
Commit message:
fc;

Changed in this revision

dribble.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show diff for this revision Revisions of this file
nRF24L01P.lib Show annotated file Show diff for this revision Revisions of this file
servomotor_MX12_Lorenzo.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dribble.lib	Wed Jun 15 13:06:30 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/PSL_2021/code/dribble/#0fc1a21949f7
--- a/main.cpp	Fri May 20 09:53:16 2022 +0200
+++ b/main.cpp	Wed Jun 15 13:06:30 2022 +0000
@@ -1,22 +1,122 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2019 ARM Limited
- * SPDX-License-Identifier: Apache-2.0
- */
+/*/*
+RobotCup ENS Paris Saclay 2021-2022
+Team FC Furious
+Code by Martin Raynaud
+
+Programme communication PC-Robot
+Point de vue : Robot
+
+*/
 
 #include "mbed.h"
+#include "string.h"
+#include "nRF24L01P.h"
+#include "string.h"
+#include "MX12.h"
+#include "DRIBBLE.h"
+
+int8_t commande_dribble = 0;
+int8_t commande_tir = 0;
+int8_t commande_charge;
+int8_t commande_option2;
+int8_t commande_id;
+
+Thread thread;
+Thread thread2;
+
+DigitalOut myled(LED2);
+DigitalOut myled2(LED3);
+
+DigitalOut tir(D3);
+DigitalOut charge(D0);
 
 
-// Blinking rate in milliseconds
-#define BLINKING_RATE     300ms
+
+BufferedSerial pc_serie(USBTX,USBRX,115200);
+MX12 bus(PC_4,PC_5,115200);
+nRF24L01P my_nrf24l01p(D11, D12, D13, D9, D2, D1);    // mosi, miso, sck, csn, ce, irq
+dribbleur d(D15);
 
 
 int main()
 {
-    // Initialise the digital pin LED1 as an output
-    DigitalOut led(LED1);
+    myled = 1 ;
+    myled2 = 1;
+
+/*
+envoi d'une chaine de caractère de taille TRANSFER_SIZE
+*/
+
+#define TRANSFER_SIZE 12
+
+    int16_t Vavance_mm_s;
+    int16_t Vlat_mm_s;
+    int16_t Vrot_mrad_s;
+    int8_t commande_arret;
+
+    char tab[TRANSFER_SIZE];
+    char text[50];
+    char text2[50];
+
+    my_nrf24l01p.powerUp();
+    my_nrf24l01p.setRfFrequency(2418);
+    my_nrf24l01p.setAirDataRate(1000);
+    my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
+    my_nrf24l01p.setReceiveMode();
+    my_nrf24l01p.setCrcWidth(0);
+    my_nrf24l01p.setRxAddress();
+    my_nrf24l01p.enable();
+    while (1) {
+
+
+        if (my_nrf24l01p.readable()) {
+            myled = !myled;
+            my_nrf24l01p.read( NRF24L01P_PIPE_P0, tab, TRANSFER_SIZE );
+
 
-    while (true) {
-        led = !led;
-        ThisThread::sleep_for(BLINKING_RATE);
+            Vavance_mm_s = -((((int16_t)tab[0]) << 8 ) + (int16_t)tab[1]);
+            Vlat_mm_s = -(((int16_t)tab[2] << 8) + (int16_t)tab[3]);
+            Vrot_mrad_s = -(((int16_t)tab[4] << 8) + (int16_t)tab[5]);
+            commande_arret = ((uint8_t)tab[6]);
+            commande_charge = ((uint8_t)tab[7]);
+            commande_dribble = ((uint8_t)tab[8]);
+            commande_tir = ((uint8_t)tab[9]);
+            commande_id = ((uint8_t)tab[10]);
+            commande_option2 = ((uint8_t)tab[11]);
+
+
+            if (commande_id == (1)) {
+
+                if (commande_charge == 1) {
+                    charge = 1;
+                    thread_sleep_for(100);
+                    charge = 0;
+                }
+                if (commande_tir == 1) {
+                    thread_sleep_for(1000);
+                    tir= 1;
+                    thread_sleep_for(10);
+                    tir = 0;
+                }
+                if (commande_dribble == 1) {
+                    d.SetSpeed(50);
+                } else {
+                    d.SetSpeed(0);
+                }
+                if (commande_arret == (1)) {
+                    bus.eteindre_moteurs();
+                    myled2 =! myled2;
+
+                } else if ((abs(Vavance_mm_s) < 1) && (abs(Vlat_mm_s) < 1) && (abs(Vrot_mrad_s) < 1)) {
+                    bus.eteindre_moteurs();
+
+                } else {
+                    bus.cmd_moteur(Vavance_mm_s/1000.0,Vlat_mm_s/1000.0,Vrot_mrad_s/1000.0);
+                }
+            }
+        }
     }
+
+
 }
+
--- a/mbed_app.json	Fri May 20 09:53:16 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-{
-    "requires": ["bare-metal"],
-    "target_overrides": {
-      "*": {
-        "target.c_lib": "small",
-        "target.printf_lib": "minimal-printf",
-        "platform.minimal-printf-enable-floating-point": true,
-        "platform.stdio-minimal-console-only": true
-      }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF24L01P.lib	Wed Jun 15 13:06:30 2022 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Owen/code/nRF24L01P/#8ae48233b4e4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/servomotor_MX12_Lorenzo.lib	Wed Jun 15 13:06:30 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/PSL_2021/code/servomotor_MX12_Lorenzo/#67e5482f83dd