1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-14 04:16:05 +01:00
This commit is contained in:
Geoffrey Frogeye 2018-05-02 05:51:14 +02:00
parent 1ef117c0ad
commit 48b2901da4
10 changed files with 99 additions and 14 deletions

View file

@ -5,7 +5,7 @@ CC=gcc
# Bibliothèques
LIBS=
## Drapeaux pour le linker
LDFLAGS_CUSTOM += -lpthread -lwiringPi
LDFLAGS_CUSTOM += -lpthread -lwiringPi -lm
## Drapeaux pour le compilateur
CFLAGS_CUSTOM += -g
## Générateurs de drapeaux pour les bibliothèques

View file

@ -10,7 +10,7 @@
#define FPGA_PORTNAME "/dev/ttyUSB0"
#define CF_BAUDRATE B115200
// #define PRINTRAWDATA
#define PRINTRAWDATA
int fpga;
pthread_mutex_t sSendCF;

View file

@ -26,7 +26,7 @@ int nextId()
if (d) {
while ((dir = readdir(d)) != NULL) {
ret = sscanf(dir->d_name, "%d", &id);
ret = sscanf(dir->d_name, "%06d", &id);
if (ret == 1 && id > maxId) {
maxId = id;
}
@ -101,7 +101,7 @@ void configureDebug()
// Génération du nom de fichier
char path[256];
sprintf(path, "log/%d.csv", nextId());
sprintf(path, "log/%06d.csv", nextId());
// Open file
debugFd = fopen(path, "w");

View file

@ -34,12 +34,11 @@ int setMoteurTension(float lVolt, float rVolt)
msg.in = 0x00;
// TODO Protections
// Gauche
bool lFor = lVolt < 0;
lVolt = fabs(lVolt);
if (lVolt > MOT_MAX_V) {
lVolt = MOT_MAX_V;
}
msg.in |= 1 << (lFor ? IN1 : IN2);
msg.ena = tensionToPWM(lVolt);

View file

@ -3,12 +3,14 @@
*/
#include <stdio.h>
#include <math.h>
#include "debug.h"
#include "position.h"
#include "dimensions.h"
// Globales
struct position actuel;
struct position connu;
struct F2CI_CODERs deltaCoders;
pthread_mutex_t posPolling;
pthread_t tPosition;
@ -42,6 +44,15 @@ void* TaskPosition(void* pData)
nbCalcPos++;
lCodTot += deltaCoders.dL;
rCodTot += deltaCoders.dR;
float deltaO = atan2(deltaCoders.dR - deltaCoders.dL, DISTANCE_BETWEEN_WHEELS);
float deltaD = (deltaCoders.dL + deltaCoders.dR) / 2;
connu.o += deltaO;
float deltaX = deltaD * cos(connu.o);
float deltaY = deltaD * sin(connu.o);
connu.x += deltaX;
connu.y += deltaY;
}
return NULL;
@ -58,6 +69,12 @@ void configurePosition()
registerRxHandler(F2CI_CODER, onF2CI_CODER);
registerDebugVar("lCodTot", ld, &lCodTot);
registerDebugVar("rCodTot", ld, &rCodTot);
connu.x = 0;
connu.y = 0;
connu.o = 0;
registerDebugVar("xConnu", f, &connu.x);
registerDebugVar("yConnu", f, &connu.y);
registerDebugVar("oConnu", f, &connu.o);
registerDebugVar("nbCalcPos", d, &nbCalcPos);
pthread_create(&tPosition, NULL, TaskPosition, NULL);
}

View file

@ -12,6 +12,8 @@
#include "movement.h"
#include "buttons.h"
#define PATATE 3.3/2
int main(int argc, char* argv[])
{
@ -29,22 +31,22 @@ int main(int argc, char* argv[])
for (;;) {
clearLCD();
printToLCD(LCD_LINE_1, "Forward");
changerMoteurs(3.3, 3.3);
changerMoteurs(PATATE, PATATE);
pressedButton(BUT_BLOCK);
clearLCD();
printToLCD(LCD_LINE_1, "Right");
changerMoteurs(-3.3, 3.3);
changerMoteurs(-PATATE, PATATE);
pressedButton(BUT_BLOCK);
clearLCD();
printToLCD(LCD_LINE_1, "Left");
changerMoteurs(-3.3, -3.3);
changerMoteurs(-PATATE, -PATATE);
pressedButton(BUT_BLOCK);
clearLCD();
printToLCD(LCD_LINE_1, "Backward");
changerMoteurs(3.3, -3.3);
changerMoteurs(PATATE, -PATATE);
pressedButton(BUT_BLOCK);
clearLCD();

62
chef/src/testUpDown.c Normal file
View file

@ -0,0 +1,62 @@
/* Teste si une broche est connecté à une autre */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include "lcd.h"
#include "CF.h"
#include "movement.h"
#include "buttons.h"
#define UP_TIME 1000
#define HIGH_TIME 3000
#define DOWN_TIME 1000
#define LOW_TIME 2000
#define MAXI 3.3
#define INTERVAL 10
void changerMoteursWrapper(float l, float r) {
/* clearLCD(); */
printfToLCD(LCD_LINE_1, "L: %f", l);
printfToLCD(LCD_LINE_2, "R: %f", r);
changerMoteurs(l, r);
}
int main(int argc, char* argv[])
{
(void)argc;
(void)argv;
wiringPiSetup();
initI2C();
initLCD();
configureCF();
configureButtons();
configureMovement();
for (;;) {
for (int i = 0; i < UP_TIME; i += INTERVAL) {
float p = (float)i / (float)UP_TIME;
changerMoteursWrapper(p * MOT_MAX_V, p * MOT_MAX_V);
delay(INTERVAL);
}
changerMoteursWrapper(MOT_MAX_V, MOT_MAX_V);
delay(HIGH_TIME);
for (int i = 0; i < DOWN_TIME; i += INTERVAL) {
float p = (float)i / (float)DOWN_TIME;
p = 1 - p;
changerMoteursWrapper(p * MOT_MAX_V, p * MOT_MAX_V);
delay(INTERVAL);
}
changerMoteursWrapper(0, 0);
delay(LOW_TIME);
}
}

2
log/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

View file

@ -125,6 +125,10 @@ restart:
ssh -F sshconf principal true
ssh -F sshconf principal /etc/init.d/S50chef restart
getlogs:
ssh -F sshconf principal true
rsync --rsh 'ssh -F sshconf' --archive principal:/opt/chef/log/* ../log/
gdbcommands:
echo "set sysroot $(TARGET_DIR)" > "$@"
echo "exec-file $(TARGET_DIR)$(EXECDIR)$(EXECPATH)" >> "$@"

View file

@ -7,6 +7,7 @@ start() {
printf "Starting Wi-Fi connection: "
# modprobe brcmfmac
modprobe r8188eu
modprobe 8192cu
ifup wlan0
echo "OK"
}
@ -14,8 +15,6 @@ start() {
stop() {
printf "Stopping Wi-Fi connection: "
ifdown wlan0
# rmmod brcmfmac
rmmod r8188eu
echo "OK"
}