mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2024-12-03 13:36:07 +01:00
Fix codeuses
This commit is contained in:
parent
678b7e939b
commit
e758218dca
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
-- Process signals from HEDM-550X encoder
|
||||
-- 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;
|
||||
use IEEE.STD_LOGIC_1164.ALL;
|
||||
use ieee.numeric_std.all;
|
||||
|
@ -20,59 +17,63 @@ entity hedm is
|
|||
end hedm;
|
||||
|
||||
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
|
||||
begin
|
||||
processInput : process(clk, reset)
|
||||
variable counter : integer := 0;
|
||||
begin
|
||||
if reset = '1' then
|
||||
counter := 0;
|
||||
counts <= 0;
|
||||
counter <= 0;
|
||||
An <= '0';
|
||||
Bn <= '0';
|
||||
Ap <= '0';
|
||||
Bp <= '0';
|
||||
elsif rising_edge(clk) then
|
||||
|
||||
if zero = '1' then
|
||||
counter := 0;
|
||||
end if;
|
||||
Ap <= An;
|
||||
Bp <= Bn;
|
||||
|
||||
An <= chA;
|
||||
Bn <= chB;
|
||||
|
||||
-- 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
|
||||
-- tout aussi bon travail, on garde donc le code suivant pour la lisibilité
|
||||
|
||||
if (Ap = '0' and chA = '1') then -- Front montant A
|
||||
if (chB = '0') then
|
||||
counter := counter + 1;
|
||||
if (Ap = '0' and An = '1') then -- Front montant A
|
||||
if (Bn = '0') then
|
||||
counter <= oldCounter + 1;
|
||||
else
|
||||
counter := counter - 1;
|
||||
counter <= oldCounter - 1;
|
||||
end if;
|
||||
elsif (Ap = '1' and chA = '0') then -- Front descendant A
|
||||
if (chB = '1') then
|
||||
counter := counter + 1;
|
||||
elsif (Ap = '1' and An = '0') then -- Front descendant A
|
||||
if (Bn = '1') then
|
||||
counter <= oldCounter + 1;
|
||||
else
|
||||
counter := counter - 1;
|
||||
counter <= oldCounter - 1;
|
||||
end if;
|
||||
elsif (Bp = '0' and chB = '1') then -- Front montant B
|
||||
if (chA = '1') then
|
||||
counter := counter + 1;
|
||||
elsif (Bp = '0' and Bn = '1') then -- Front montant B
|
||||
if (An = '1') then
|
||||
counter <= oldCounter + 1;
|
||||
else
|
||||
counter := counter - 1;
|
||||
counter <= oldCounter - 1;
|
||||
end if;
|
||||
elsif (Bp = '1' and chB = '0') then -- Front descendant B
|
||||
if (chA = '0') then
|
||||
counter := counter + 1;
|
||||
elsif (Bp = '1' and Bn = '0') then -- Front descendant B
|
||||
if (An = '0') then
|
||||
counter <= oldCounter + 1;
|
||||
else
|
||||
counter := counter - 1;
|
||||
counter <= oldCounter - 1;
|
||||
end if;
|
||||
else
|
||||
counter <= oldCounter;
|
||||
end if;
|
||||
|
||||
Ap <= chA;
|
||||
Bp <= chB;
|
||||
|
||||
counts <= counter;
|
||||
|
||||
end if;
|
||||
end process;
|
||||
|
||||
oldCounter <= 0 when zero = '1' else counter;
|
||||
counts <= counter;
|
||||
|
||||
end Behavioral;
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
[*]
|
||||
[*] GTKWave Analyzer v3.3.86 (w)1999-2017 BSI
|
||||
[*] Tue Feb 27 08:32:01 2018
|
||||
[*] GTKWave Analyzer v3.3.89 (w)1999-2018 BSI
|
||||
[*] Sat May 5 22:58:30 2018
|
||||
[*]
|
||||
[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_size] 4287
|
||||
[dumpfile_mtime] "Sat May 5 22:57:01 2018"
|
||||
[dumpfile_size] 5011
|
||||
[savefile] "/home/geoffrey/Documents/Polytech/Robotech/2017-2018/CdF/cdf2018-principal/fpga/hedm_tb.gtkw"
|
||||
[timestart] 0
|
||||
[size] 1600 862
|
||||
|
@ -13,7 +13,7 @@
|
|||
[treeopen] top.
|
||||
[treeopen] top.hedm_tb.
|
||||
[sst_width] 213
|
||||
[signals_width] 78
|
||||
[signals_width] 110
|
||||
[sst_expanded] 1
|
||||
[sst_vpaned_height] 244
|
||||
@28
|
||||
|
@ -33,10 +33,13 @@ top.hedm_tb.dut.bp
|
|||
top.hedm_tb.dut.an
|
||||
[color] 2
|
||||
top.hedm_tb.dut.bn
|
||||
@421
|
||||
[color] 7
|
||||
top.hedm_tb.dut.oldcounter
|
||||
@420
|
||||
[color] 1
|
||||
top.hedm_tb.dut.counts
|
||||
@8421
|
||||
@8420
|
||||
[color] 1
|
||||
top.hedm_tb.dut.counts
|
||||
[pattern_trace] 1
|
||||
|
|
|
@ -112,7 +112,7 @@ begin
|
|||
wait for 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';
|
||||
wait for TbPeriod;
|
||||
|
|
|
@ -10,7 +10,8 @@ then
|
|||
# Le ifup de Busybox ne supporte pas les options wpa-*, donc on utilisera les wpa_supplicant en direct
|
||||
|
||||
# Network configuration
|
||||
echo -e "
|
||||
echo -e "# Interface configuration generated by raspberrypi/board/robotech/cdfprincipal/post-build.sh
|
||||
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
|
@ -25,7 +26,7 @@ auto wlan0
|
|||
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-down start-stop-daemon -K -q -p /var/run/wpa_supplicant.pid
|
||||
" >> ${TARGET_DIR}/etc/network/interfaces
|
||||
" > ${TARGET_DIR}/etc/network/interfaces
|
||||
|
||||
# SSH configuration
|
||||
rm ${TARGET_DIR}/etc/dropbear &> /dev/null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
alias la='ls -al'
|
||||
alias ll='ls -l'
|
||||
|
@ -15,4 +15,7 @@ export PS4="- "
|
|||
alias r="/etc/init.d/S50chef restart"
|
||||
alias s="/etc/init.d/S50chef stop"
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ BR2_PACKAGE_HTOP=y
|
|||
|
||||
# Pour debugguer
|
||||
BR2_PACKAGE_GDB=y
|
||||
BR2_PACKAGE_MINICOM=y
|
||||
|
||||
# Pour uploader sur le Arduino
|
||||
BR2_TOOLCHAIN_BUILDROOT_WCHAR=y
|
||||
|
|
Loading…
Reference in a new issue