1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-14 12:26:06 +01:00

Fix codeuses

This commit is contained in:
Geoffrey Frogeye 2018-05-06 01:14:09 +02:00
parent 678b7e939b
commit e758218dca
14 changed files with 200 additions and 86 deletions

View file

@ -40,8 +40,8 @@ bin/premier: obj/premier.o $(OBJS_O)
bin/test%: obj/test%.o $(OBJS_O) bin/test%: obj/test%.o $(OBJS_O)
# Programme de test sur PC, n'embarquant pas wiringPi # Programme de test sur PC, n'embarquant pas wiringPi
bin/local: obj/local.o bin/local: obj/local.o obj/CF.o obj/debug.o obj/position.o
$(CC) $(CFLAGS) $(CFLAGS_CUSTOM) -lpthread $^ -o $@ $(CC) $(CFLAGS) $(CFLAGS_CUSTOM) -lpthread -lm $^ -o $@
# Génération des fichiers objets # Génération des fichiers objets
obj/%.o: src/%.c src/%.h obj/%.o: src/%.c src/%.h

View file

@ -111,7 +111,7 @@ void configureDebug()
debugFd = fopen(path, "w"); debugFd = fopen(path, "w");
if (debugFd == NULL) { if (debugFd == NULL) {
perror("fopen debug file"); perror("fopen debug file");
return; exit(EXIT_FAILURE);
} }
fprintf(debugFd, "time"); fprintf(debugFd, "time");

View file

@ -30,6 +30,7 @@ bool diagFPGA(void* arg)
} }
usleep(DIAGNOSTIC_POLL_INTERVAL * 1000); usleep(DIAGNOSTIC_POLL_INTERVAL * 1000);
} }
registerRxHandler(C2FD_PING, NULL);
return recu; return recu;
} }

View file

@ -3,19 +3,35 @@
#include <math.h> #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] // Dimensions robot
#define WHEEL_DIAMETER 80.0 #define WIDTH 250 // mm (from meca)
// [mm] #define HEIGHT 100 // mm (from random);
#define WHEEL_PERIMETER WHEEL_DIAMETER * M_PI #define DISTANCE_BETWEEN_WHEELS WIDTH // mm (from meca)
// [cycles/revolution] #define WHEEL_DIAMETER 80 // mm (from meca)
#define CODER_RESOLUTION 100 #define WHEEL_PERIMETER WHEEL_DIAMETER * M_PI // mm
// [increments/revolution] #define MOTOR_SPEED_GAIN_RPMP_V 233 // rpm/V (from datasheet)
#define CODER_DATA_RESOLUTION CODER_RESOLUTION * 4 #define MOTOR_SPEED_GAIN MOTOR_SPEED_GAIN_RPMP_V / 60 // rev/s/V
// [mm] #define MOTOR_NOMINAL_TENSION 24 // V (from datasheet)
#define CODER_DELTA_DISTANCE WHEEL_PERIMETER / CODER_DATA_RESOLUTION #define CODER_RESOLUTION 100 // cycles/rev
// [mm] #define CODER_DATA_FACTOR 4 // increments/cycles
#define DISTANCE_BETWEEN_WHEELS 250.0 #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 #endif

View file

@ -1,36 +1,35 @@
#include <pthread.h> #include <pthread.h>
#include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h> // random seed
#include <unistd.h> // sleep #include <unistd.h> // sleep
#define TEMPS_PARCOURS 10 #include "CF.h"
#include "debug.h"
#include "movement.h"
// t1 - t2 pthread_mutex_t sRunning;
void diffTimespec(const struct timespec* t1, const struct timespec* t2, struct timespec* td)
void endRunning(int signal)
{ {
if ((t1->tv_nsec - t2->tv_nsec) < 0) { (void)signal;
td->tv_sec = t1->tv_sec - t2->tv_sec - 1; pthread_mutex_unlock(&sRunning);
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;
}
} }
int main() int main()
{ {
struct timespec start, now, diff;
clock_gettime(CLOCK_REALTIME, &start);
configureDebug();
configureCF();
configurePosition();
/* long lCod, rCod; */
for (;;) { for (;;) {
clock_gettime(CLOCK_REALTIME, &now); sleep(1);
diffTimespec(&now, &start, &diff); /* getCoders(&lCod, &rCod); */
if (diff.tv_sec > TEMPS_PARCOURS) { /* printf("%ld %ld\n", lCod, rCod); */
break; /* usleep(100*1000); */
}
printf("32 %ld %ld\n", diff.tv_sec, diff.tv_nsec);
} }
return EXIT_SUCCESS;
} }

View file

@ -1,20 +1,19 @@
#include <pthread.h> #include <pthread.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <wiringPi.h>
#include "debug.h"
#include "lcd.h" #include "lcd.h"
#include "movement.h" #include "movement.h"
#include "parcours.h" #include "parcours.h"
#include "points.h" #include "points.h"
#include "position.h" #include "position.h"
#include "debug.h"
pthread_t tParcours; pthread_t tParcours;
bool isOrange; bool isOrange;
struct timespec tempsStart; struct timespec tempsStart;
struct timespec tempsNow; struct timespec tempsNow;
struct timespec tempsEcoule = {0, 0}; struct timespec tempsEcoule = { 0, 0 };
void configureParcours() void configureParcours()
{ {
@ -93,24 +92,23 @@ void* TaskParcours(void* pdata)
for (int i = 0; i < UP_TIME; i++) { for (int i = 0; i < UP_TIME; i++) {
float p = (float)i / (float)UP_TIME; float p = (float)i / (float)UP_TIME;
changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V); changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V);
delay(1); usleep(1000 * 1);
} }
addPoints(1); addPoints(1);
changerMoteurs(MOT_MAX_V, MOT_MAX_V); changerMoteurs(MOT_MAX_V, MOT_MAX_V);
delay(HIGH_TIME); usleep(1000 * HIGH_TIME);
addPoints(1); addPoints(1);
for (int i = 0; i < DOWN_TIME; i++) { for (int i = 0; i < DOWN_TIME; i++) {
float p = (float)i / (float)DOWN_TIME; float p = (float)i / (float)DOWN_TIME;
p = 1 - p; p = 1 - p;
changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V); changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V);
delay(1); usleep(1000 * 1);
} }
addPoints(1); addPoints(1);
changerMoteurs(0, 0); changerMoteurs(0, 0);
delay(LOW_TIME); usleep(1000 * LOW_TIME);
} }
return NULL; return NULL;
} }

43
chef/src/testCodeuse.c Normal file
View 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
View 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);
}
}

View file

@ -1,9 +1,6 @@
-- Process signals from HEDM-550X encoder -- Process signals from HEDM-550X encoder
-- and output the value read -- and output the value read
-- TODO Quelques modifications apportées depuis test avec les vraies codeuses
-- un nouveau test sera nécessaire (vérifier notamment le sens de parcours)
library IEEE; library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all; use ieee.numeric_std.all;
@ -20,59 +17,63 @@ entity hedm is
end hedm; end hedm;
architecture Behavioral of hedm is architecture Behavioral of hedm is
signal counter : integer := 0;
signal oldCounter : integer := 0;
signal An, Bn : STD_LOGIC := '0'; -- Nouvelles valeurs de A et B stockées pour que les entrées soient lues une seule fois en début de cycle
signal Ap, Bp : STD_LOGIC := '0'; -- Précédentes valeurs de A et B pour détecter les front montant signal Ap, Bp : STD_LOGIC := '0'; -- Précédentes valeurs de A et B pour détecter les front montant
begin begin
processInput : process(clk, reset) processInput : process(clk, reset)
variable counter : integer := 0;
begin begin
if reset = '1' then if reset = '1' then
counter := 0; counter <= 0;
counts <= 0; An <= '0';
Bn <= '0';
Ap <= '0'; Ap <= '0';
Bp <= '0'; Bp <= '0';
elsif rising_edge(clk) then elsif rising_edge(clk) then
if zero = '1' then Ap <= An;
counter := 0; Bp <= Bn;
end if;
An <= chA;
Bn <= chB;
-- On pourrait optimiser la logique avec un tableau de Karnaugh ou autres méthodes -- On pourrait optimiser la logique avec un tableau de Karnaugh ou autres méthodes
-- de simplification d'algèbre de Boole, mais le synthétiseur pour FPGA fera un -- de simplification d'algèbre de Boole, mais le synthétiseur pour FPGA fera un
-- tout aussi bon travail, on garde donc le code suivant pour la lisibilité -- tout aussi bon travail, on garde donc le code suivant pour la lisibilité
if (Ap = '0' and chA = '1') then -- Front montant A if (Ap = '0' and An = '1') then -- Front montant A
if (chB = '0') then if (Bn = '0') then
counter := counter + 1; counter <= oldCounter + 1;
else else
counter := counter - 1; counter <= oldCounter - 1;
end if; end if;
elsif (Ap = '1' and chA = '0') then -- Front descendant A elsif (Ap = '1' and An = '0') then -- Front descendant A
if (chB = '1') then if (Bn = '1') then
counter := counter + 1; counter <= oldCounter + 1;
else else
counter := counter - 1; counter <= oldCounter - 1;
end if; end if;
elsif (Bp = '0' and chB = '1') then -- Front montant B elsif (Bp = '0' and Bn = '1') then -- Front montant B
if (chA = '1') then if (An = '1') then
counter := counter + 1; counter <= oldCounter + 1;
else else
counter := counter - 1; counter <= oldCounter - 1;
end if; end if;
elsif (Bp = '1' and chB = '0') then -- Front descendant B elsif (Bp = '1' and Bn = '0') then -- Front descendant B
if (chA = '0') then if (An = '0') then
counter := counter + 1; counter <= oldCounter + 1;
else else
counter := counter - 1; counter <= oldCounter - 1;
end if; end if;
else
counter <= oldCounter;
end if; end if;
Ap <= chA;
Bp <= chB;
counts <= counter;
end if; end if;
end process; end process;
oldCounter <= 0 when zero = '1' else counter;
counts <= counter;
end Behavioral; end Behavioral;

View file

@ -1,10 +1,10 @@
[*] [*]
[*] GTKWave Analyzer v3.3.86 (w)1999-2017 BSI [*] GTKWave Analyzer v3.3.89 (w)1999-2018 BSI
[*] Tue Feb 27 08:32:01 2018 [*] Sat May 5 22:58:30 2018
[*] [*]
[dumpfile] "/home/geoffrey/Documents/Polytech/Robotech/2017-2018/CdF/cdf2018-principal/fpga/build/hedm_tb.ghw" [dumpfile] "/home/geoffrey/Documents/Polytech/Robotech/2017-2018/CdF/cdf2018-principal/fpga/build/hedm_tb.ghw"
[dumpfile_mtime] "Tue Feb 27 08:31:12 2018" [dumpfile_mtime] "Sat May 5 22:57:01 2018"
[dumpfile_size] 4287 [dumpfile_size] 5011
[savefile] "/home/geoffrey/Documents/Polytech/Robotech/2017-2018/CdF/cdf2018-principal/fpga/hedm_tb.gtkw" [savefile] "/home/geoffrey/Documents/Polytech/Robotech/2017-2018/CdF/cdf2018-principal/fpga/hedm_tb.gtkw"
[timestart] 0 [timestart] 0
[size] 1600 862 [size] 1600 862
@ -13,7 +13,7 @@
[treeopen] top. [treeopen] top.
[treeopen] top.hedm_tb. [treeopen] top.hedm_tb.
[sst_width] 213 [sst_width] 213
[signals_width] 78 [signals_width] 110
[sst_expanded] 1 [sst_expanded] 1
[sst_vpaned_height] 244 [sst_vpaned_height] 244
@28 @28
@ -33,10 +33,13 @@ top.hedm_tb.dut.bp
top.hedm_tb.dut.an top.hedm_tb.dut.an
[color] 2 [color] 2
top.hedm_tb.dut.bn top.hedm_tb.dut.bn
@421
[color] 7
top.hedm_tb.dut.oldcounter
@420 @420
[color] 1 [color] 1
top.hedm_tb.dut.counts top.hedm_tb.dut.counts
@8421 @8420
[color] 1 [color] 1
top.hedm_tb.dut.counts top.hedm_tb.dut.counts
[pattern_trace] 1 [pattern_trace] 1

View file

@ -112,7 +112,7 @@ begin
wait for TbPeriod; wait for TbPeriod;
wait for 5 * TbPeriod; wait for 5 * TbPeriod;
assert counts = 2 report "Zero en éxecution faux, reçu " & integer'image(counts) severity error; assert counts = 3 report "Zero en éxecution faux, reçu " & integer'image(counts) severity error;
zero <= '1'; zero <= '1';
wait for TbPeriod; wait for TbPeriod;

View file

@ -10,7 +10,8 @@ then
# Le ifup de Busybox ne supporte pas les options wpa-*, donc on utilisera les wpa_supplicant en direct # Le ifup de Busybox ne supporte pas les options wpa-*, donc on utilisera les wpa_supplicant en direct
# Network configuration # Network configuration
echo -e " echo -e "# Interface configuration generated by raspberrypi/board/robotech/cdfprincipal/post-build.sh
auto lo auto lo
iface lo inet loopback iface lo inet loopback
@ -25,7 +26,7 @@ auto wlan0
iface wlan0 inet dhcp iface wlan0 inet dhcp
pre-up wpa_supplicant -D wext -B -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -P /var/run/wpa_supplicant.pid pre-up wpa_supplicant -D wext -B -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -P /var/run/wpa_supplicant.pid
pre-down start-stop-daemon -K -q -p /var/run/wpa_supplicant.pid pre-down start-stop-daemon -K -q -p /var/run/wpa_supplicant.pid
" >> ${TARGET_DIR}/etc/network/interfaces " > ${TARGET_DIR}/etc/network/interfaces
# SSH configuration # SSH configuration
rm ${TARGET_DIR}/etc/dropbear &> /dev/null rm ${TARGET_DIR}/etc/dropbear &> /dev/null

View file

@ -1,4 +1,4 @@
#/bin/bash #!/bin/sh
alias la='ls -al' alias la='ls -al'
alias ll='ls -l' alias ll='ls -l'
@ -15,4 +15,7 @@ export PS4="- "
alias r="/etc/init.d/S50chef restart" alias r="/etc/init.d/S50chef restart"
alias s="/etc/init.d/S50chef stop" alias s="/etc/init.d/S50chef stop"
alias c="cd /opt/chef/" alias c="cd /opt/chef/"
alias l="tail -f $(find /opt/chef/log | sort | tail -1)" l()
{
tail -f $(find /opt/chef/log | sort | tail -1)
}

View file

@ -76,6 +76,7 @@ BR2_PACKAGE_HTOP=y
# Pour debugguer # Pour debugguer
BR2_PACKAGE_GDB=y BR2_PACKAGE_GDB=y
BR2_PACKAGE_MINICOM=y
# Pour uploader sur le Arduino # Pour uploader sur le Arduino
BR2_TOOLCHAIN_BUILDROOT_WCHAR=y BR2_TOOLCHAIN_BUILDROOT_WCHAR=y