mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2024-12-22 05:30:37 +01:00
Travail inachevé avec Arduino
This commit is contained in:
parent
5c1ccbce93
commit
af080ac4bf
15
Connexions.md
Normal file
15
Connexions.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Connexions
|
||||
|
||||
Ce document a pour but de recenser les connexions entre les différents composants du robot.
|
||||
|
||||
## Liste des composants
|
||||
|
||||
- Raspberry Pi 3 (RPi)
|
||||
- Arduino Mega 2560 (Ard)
|
||||
- Micronova Mercury FPGA (FPGA)
|
||||
- HEDM-550X Encodeur moteur gauche
|
||||
- HEDM-550X Encodeur moteur droit
|
||||
|
||||
## Connexions de puissance
|
||||
|
||||
## Connexions d'information
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef __ACSIGNALS_H_
|
||||
#define __ACSIGNALS_H_
|
||||
|
||||
#include "AFsignals.h"
|
||||
|
||||
#define AC_BAUDRATE 9600UL
|
||||
|
||||
// Structures used everywhere
|
||||
|
@ -62,6 +64,8 @@ struct __attribute__ ((packed)) A2CI_DBGs {
|
|||
struct position actuel;
|
||||
struct position destination;
|
||||
unsigned char movement;
|
||||
struct F2AI_CODERs deltaCoder;
|
||||
uint16_t nbCalcPos;
|
||||
// ...
|
||||
};
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ struct __attribute__ ((packed)) F2AD_ERRs {
|
|||
// Récupère les valeur des encodeurs
|
||||
#define F2AI_CODER 'D'
|
||||
struct __attribute__ ((packed)) F2AI_CODERs {
|
||||
int16_t left;
|
||||
int16_t right;
|
||||
int16_t dL;
|
||||
int16_t dR;
|
||||
};
|
||||
|
||||
// Récupère les valeur des capteurs de distance
|
||||
|
|
|
@ -13,7 +13,10 @@ void TaskDebug(void *pvParameters) {
|
|||
// Copie des valeurs à envoyer en debug
|
||||
memcpy((void*) &debug.actuel, (const void*) &actuel, (unsigned long) sizeof(actuel));
|
||||
memcpy((void*) &debug.destination, (const void*) &destination, (unsigned long) sizeof(destination));
|
||||
memcpy((void*) &debug.deltaCoder, (const void*) &deltaCoder, (unsigned long) sizeof(deltaCoder));
|
||||
debug.movement = movement;
|
||||
debug.nbCalcPos = nbCalcPos;
|
||||
nbCalcPos = 0;
|
||||
|
||||
// Envoi des valeurs
|
||||
sendAC(A2CI_DBG, &debug, sizeof(debug));
|
||||
|
|
|
@ -1,25 +1,51 @@
|
|||
#include "position.h"
|
||||
#include "AC.h"
|
||||
#include "AF.h"
|
||||
#include "dimensions.h"
|
||||
|
||||
void TaskPosition(void *pvParameters) {
|
||||
(void) pvParameters;
|
||||
TickType_t xLastWakeTime;
|
||||
TickType_t xFrequency = 100 / portTICK_PERIOD_MS;
|
||||
void TaskPosition(void* pvParameters)
|
||||
{
|
||||
(void)pvParameters;
|
||||
|
||||
const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
|
||||
|
||||
ulTaskNotifyTake(pdFALSE, portMAX_DELAY); // TODO Dummy
|
||||
xLastWakeTime = xTaskGetTickCount();
|
||||
for (;;) {
|
||||
vTaskDelayUntil(&xLastWakeTime, xFrequency);
|
||||
sendAF(F2AI_CODER, NULL, 0);
|
||||
|
||||
ulTaskNotifyTake(pdFALSE, portMAX_DELAY); // Wait until new information has arrived
|
||||
|
||||
nbCalcPos++;
|
||||
|
||||
float adjacent = DISTANCE_BETWEEN_WHEELS;
|
||||
float opposite = deltaCoder.dR - deltaCoder.dL;
|
||||
float deltaO = atan(opposite / adjacent);
|
||||
|
||||
float deltaD = (deltaCoder.dL + deltaCoder.dR) / 2;
|
||||
|
||||
actuel.o += deltaO;
|
||||
float deltaX = deltaD * cos(actuel.o);
|
||||
float deltaY = deltaD * sin(actuel.o);
|
||||
actuel.x += deltaX;
|
||||
actuel.y += deltaY;
|
||||
|
||||
vTaskDelay(xDelay);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void configurePosition() {
|
||||
actuel.x = 0;
|
||||
actuel.y = 0;
|
||||
actuel.o = 90;
|
||||
|
||||
xTaskCreate(TaskPosition, "Position", 128, NULL, 2, &tPosition);;
|
||||
void onF2AI_CODER()
|
||||
{
|
||||
readAF(&deltaCoder, sizeof(struct F2AI_CODERs));
|
||||
vTaskNotifyGiveFromISR(tPosition, NULL);
|
||||
}
|
||||
|
||||
void configurePosition()
|
||||
{
|
||||
actuel.x = 0;
|
||||
actuel.y = 0;
|
||||
actuel.o = 0;
|
||||
|
||||
registerRxHandlerAF(F2AI_CODER, onF2AI_CODER);
|
||||
|
||||
xTaskCreate(TaskPosition, "Position", 128, NULL, 2, &tPosition);
|
||||
;
|
||||
}
|
||||
|
|
|
@ -9,11 +9,15 @@
|
|||
#include <task.h>
|
||||
|
||||
#include "ACsignals.h"
|
||||
#include "AFsignals.h"
|
||||
|
||||
struct position actuel;
|
||||
struct F2AI_CODERs deltaCoder;
|
||||
|
||||
TaskHandle_t tPosition;
|
||||
|
||||
uint16_t nbCalcPos;
|
||||
|
||||
void TaskPosition();
|
||||
void configurePosition();
|
||||
|
||||
|
|
1
chef/src/AFsignals.h
Symbolic link
1
chef/src/AFsignals.h
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../arduino/AFsignals.h
|
|
@ -21,14 +21,20 @@ void* TaskDebug(void* pdata)
|
|||
|
||||
void printDebugInfos(struct A2CI_DBGs* debug)
|
||||
{
|
||||
printf("← Position actuelle (%f; %f) (%f°)", debug->actuel.x, debug->actuel.y, debug->actuel.o);
|
||||
printf(", destination : ");
|
||||
// Position
|
||||
printf("← + % .6g; % .6g % .6g°", debug->actuel.x, debug->actuel.y, debug->actuel.o);
|
||||
// Frequence de calcul de la position
|
||||
printf(" % 5d☼", debug->nbCalcPos);
|
||||
// Delta codeuses
|
||||
printf(", %5d↿↾%-5d", debug->deltaCoder.dL, debug->deltaCoder.dR);
|
||||
// Destination
|
||||
printf(", ");
|
||||
if (debug->movement == C2AD_BRAKE) {
|
||||
printf("ne pas bouger\n");
|
||||
printf("⇞ \n");
|
||||
} else if (debug->movement == C2AD_FREE) {
|
||||
printf("là où le vent l'emporte\n");
|
||||
printf("↕ \n");
|
||||
} else {
|
||||
printf("(%f; %f) (%f°)\n", debug->destination.x, debug->destination.y, debug->destination.o);
|
||||
printf("↑ % .6g; % .6g % .6g°\n", debug->destination.x, debug->destination.y, debug->destination.o);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "movement.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define TEMPSMAX 10
|
||||
#define TEMPSMAX 60
|
||||
|
||||
void* TaskParcours(void *pdata)
|
||||
{
|
||||
|
@ -42,8 +42,8 @@ int main()
|
|||
/* printf("En attente de la tirette...\n"); // TODO */
|
||||
printf("C'est parti !\n");
|
||||
|
||||
pthread_t tParcours;
|
||||
pthread_create(&tParcours, NULL, TaskParcours, NULL);
|
||||
/* pthread_t tParcours; */
|
||||
/* pthread_create(&tParcours, NULL, TaskParcours, NULL); */
|
||||
|
||||
sleep(TEMPSMAX);
|
||||
|
||||
|
|
Loading…
Reference in a new issue