mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2025-09-04 01:05:56 +02:00
Fix codeuses
This commit is contained in:
parent
678b7e939b
commit
e758218dca
14 changed files with 200 additions and 86 deletions
|
@ -40,8 +40,8 @@ bin/premier: obj/premier.o $(OBJS_O)
|
|||
bin/test%: obj/test%.o $(OBJS_O)
|
||||
|
||||
# Programme de test sur PC, n'embarquant pas wiringPi
|
||||
bin/local: obj/local.o
|
||||
$(CC) $(CFLAGS) $(CFLAGS_CUSTOM) -lpthread $^ -o $@
|
||||
bin/local: obj/local.o obj/CF.o obj/debug.o obj/position.o
|
||||
$(CC) $(CFLAGS) $(CFLAGS_CUSTOM) -lpthread -lm $^ -o $@
|
||||
|
||||
# Génération des fichiers objets
|
||||
obj/%.o: src/%.c src/%.h
|
||||
|
|
|
@ -111,7 +111,7 @@ void configureDebug()
|
|||
debugFd = fopen(path, "w");
|
||||
if (debugFd == NULL) {
|
||||
perror("fopen debug file");
|
||||
return;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(debugFd, "time");
|
||||
|
|
|
@ -30,6 +30,7 @@ bool diagFPGA(void* arg)
|
|||
}
|
||||
usleep(DIAGNOSTIC_POLL_INTERVAL * 1000);
|
||||
}
|
||||
registerRxHandler(C2FD_PING, NULL);
|
||||
return recu;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,35 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
// TODO None of that is verified
|
||||
// Dimensions pistes
|
||||
#define M_PISTE_WIDTH 3000
|
||||
#define M_PISTE_HEIGHT 2000
|
||||
#define M_PISTE_ORIG_X 0
|
||||
#define M_PISTE_ORIG_Y 0
|
||||
|
||||
// [mm]
|
||||
#define WHEEL_DIAMETER 80.0
|
||||
// [mm]
|
||||
#define WHEEL_PERIMETER WHEEL_DIAMETER * M_PI
|
||||
// [cycles/revolution]
|
||||
#define CODER_RESOLUTION 100
|
||||
// [increments/revolution]
|
||||
#define CODER_DATA_RESOLUTION CODER_RESOLUTION * 4
|
||||
// [mm]
|
||||
#define CODER_DELTA_DISTANCE WHEEL_PERIMETER / CODER_DATA_RESOLUTION
|
||||
// [mm]
|
||||
#define DISTANCE_BETWEEN_WHEELS 250.0
|
||||
// Dimensions robot
|
||||
#define WIDTH 250 // mm (from meca)
|
||||
#define HEIGHT 100 // mm (from random);
|
||||
#define DISTANCE_BETWEEN_WHEELS WIDTH // mm (from meca)
|
||||
#define WHEEL_DIAMETER 80 // mm (from meca)
|
||||
#define WHEEL_PERIMETER WHEEL_DIAMETER * M_PI // mm
|
||||
#define MOTOR_SPEED_GAIN_RPMP_V 233 // rpm/V (from datasheet)
|
||||
#define MOTOR_SPEED_GAIN MOTOR_SPEED_GAIN_RPMP_V / 60 // rev/s/V
|
||||
#define MOTOR_NOMINAL_TENSION 24 // V (from datasheet)
|
||||
#define CODER_RESOLUTION 100 // cycles/rev
|
||||
#define CODER_DATA_FACTOR 4 // increments/cycles
|
||||
#define CODER_DATA_RESOLUTION CODER_RESOLUTION * CODER_DATA_FACTOR // cycles/rev
|
||||
#define CRAN_REDUC_OUT 48 // nb crans (from meca)
|
||||
#define CRAN_REDUC_IN 12 // nb crans (from meca)
|
||||
#define REDUC_RATIO CRAN_REDUC_IN / CRAN_REDUC_OUT // reduction ratio
|
||||
|
||||
// Constantes asservissement
|
||||
#define D_DIR_ECART_MIN 1 // mm
|
||||
#define D_DIR_ECART_MAX 5 // mm
|
||||
#define O_DIR_ECART_MIN 1 / 360 * 2 * M_PI // rad
|
||||
#define O_DIR_ECART_MAX 3 / 360 * 2 * M_PI // rad
|
||||
#define P 2
|
||||
#define I 0
|
||||
#define D 0
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,36 +1,35 @@
|
|||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <time.h> // random seed
|
||||
#include <unistd.h> // sleep
|
||||
|
||||
#define TEMPS_PARCOURS 10
|
||||
#include "CF.h"
|
||||
#include "debug.h"
|
||||
#include "movement.h"
|
||||
|
||||
// t1 - t2
|
||||
void diffTimespec(const struct timespec* t1, const struct timespec* t2, struct timespec* td)
|
||||
pthread_mutex_t sRunning;
|
||||
|
||||
void endRunning(int signal)
|
||||
{
|
||||
if ((t1->tv_nsec - t2->tv_nsec) < 0) {
|
||||
td->tv_sec = t1->tv_sec - t2->tv_sec - 1;
|
||||
td->tv_nsec = t1->tv_nsec - t2->tv_nsec + 1000000000UL;
|
||||
} else {
|
||||
td->tv_sec = t1->tv_sec - t2->tv_sec;
|
||||
td->tv_nsec = t1->tv_nsec - t2->tv_nsec;
|
||||
}
|
||||
(void)signal;
|
||||
pthread_mutex_unlock(&sRunning);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
struct timespec start, now, diff;
|
||||
clock_gettime(CLOCK_REALTIME, &start);
|
||||
|
||||
configureDebug();
|
||||
configureCF();
|
||||
configurePosition();
|
||||
|
||||
/* long lCod, rCod; */
|
||||
for (;;) {
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
diffTimespec(&now, &start, &diff);
|
||||
if (diff.tv_sec > TEMPS_PARCOURS) {
|
||||
break;
|
||||
}
|
||||
printf("32 %ld %ld\n", diff.tv_sec, diff.tv_nsec);
|
||||
sleep(1);
|
||||
/* getCoders(&lCod, &rCod); */
|
||||
/* printf("%ld %ld\n", lCod, rCod); */
|
||||
/* usleep(100*1000); */
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <wiringPi.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "lcd.h"
|
||||
#include "movement.h"
|
||||
#include "parcours.h"
|
||||
#include "points.h"
|
||||
#include "position.h"
|
||||
#include "debug.h"
|
||||
|
||||
pthread_t tParcours;
|
||||
bool isOrange;
|
||||
struct timespec tempsStart;
|
||||
struct timespec tempsNow;
|
||||
struct timespec tempsEcoule = {0, 0};
|
||||
struct timespec tempsEcoule = { 0, 0 };
|
||||
|
||||
void configureParcours()
|
||||
{
|
||||
|
@ -93,24 +92,23 @@ void* TaskParcours(void* pdata)
|
|||
for (int i = 0; i < UP_TIME; i++) {
|
||||
float p = (float)i / (float)UP_TIME;
|
||||
changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V);
|
||||
delay(1);
|
||||
usleep(1000 * 1);
|
||||
}
|
||||
addPoints(1);
|
||||
changerMoteurs(MOT_MAX_V, MOT_MAX_V);
|
||||
delay(HIGH_TIME);
|
||||
usleep(1000 * HIGH_TIME);
|
||||
|
||||
addPoints(1);
|
||||
for (int i = 0; i < DOWN_TIME; i++) {
|
||||
float p = (float)i / (float)DOWN_TIME;
|
||||
p = 1 - p;
|
||||
changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V);
|
||||
delay(1);
|
||||
usleep(1000 * 1);
|
||||
}
|
||||
addPoints(1);
|
||||
changerMoteurs(0, 0);
|
||||
delay(LOW_TIME);
|
||||
usleep(1000 * LOW_TIME);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
43
chef/src/testCodeuse.c
Normal file
43
chef/src/testCodeuse.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h> // random seed
|
||||
#include <unistd.h> // sleep
|
||||
#include <wiringPi.h>
|
||||
|
||||
#include "CF.h"
|
||||
#include "debug.h"
|
||||
#include "i2c.h"
|
||||
#include "ihm.h"
|
||||
#include "imu.h"
|
||||
#include "movement.h"
|
||||
#include "position.h"
|
||||
|
||||
pthread_mutex_t sRunning;
|
||||
|
||||
#define VIT 1
|
||||
|
||||
void endRunning(int signal)
|
||||
{
|
||||
(void)signal;
|
||||
pthread_mutex_unlock(&sRunning);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
configureDebug();
|
||||
configureCF();
|
||||
configurePosition();
|
||||
|
||||
changerMoteurs(VIT, VIT);
|
||||
|
||||
long lCod, rCod;
|
||||
for (;;) {
|
||||
getCoders(&lCod, &rCod);
|
||||
printf("%10ld %10ld\n", lCod, rCod);
|
||||
usleep(100*1000);
|
||||
}
|
||||
|
||||
}
|
48
chef/src/testSlow.c
Normal file
48
chef/src/testSlow.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* 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 VIT 0.40
|
||||
|
||||
|
||||
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();
|
||||
|
||||
changerMoteursWrapper(VIT, VIT);
|
||||
|
||||
for (;;) {
|
||||
changerMoteursWrapper(VIT, VIT);
|
||||
pressedButton(BUT_BLOCK);
|
||||
brake();
|
||||
pressedButton(BUT_BLOCK);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue