Skip to content

Commit

Permalink
same types for gen/sim/prog
Browse files Browse the repository at this point in the history
  • Loading branch information
grunenwald committed Nov 29, 2016
1 parent 68c6f03 commit a47a1ee
Show file tree
Hide file tree
Showing 14 changed files with 1,682 additions and 1,572 deletions.
Binary file modified doc/gabarit/calibrage.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/generateur/drawbot.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
######################################################################
QT += widgets
TEMPLATE = app
TARGET = drawbot
TARGET = generateur
DEPENDPATH += .
INCLUDEPATH += .

Expand Down
24 changes: 5 additions & 19 deletions src/generateur/mainwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
}
void MainWin::writeSettings()
{
QSettings settings("./mainwindow.ini", QSettings::IniFormat);
QSettings settings("./prefs.ini", QSettings::IniFormat);

settings.clear();
settings.beginGroup("MainWindow");
settings.setValue("size", size());
settings.setValue("pos", pos());
settings.setValue("maximized", isMaximized());
settings.setValue("pos", pos());
settings.endGroup();

settings.beginGroup("Fichiers");
Expand All @@ -52,20 +50,10 @@ void MainWin::writeSettings()

void MainWin::readSettings()
{
QSettings settings("./mainwindow.ini", QSettings::IniFormat);
QSettings settings("./prefs.ini", QSettings::IniFormat);

settings.beginGroup("MainWindow");
if(settings.value("maximized").toBool())
{
resize(800,400);
move(200, 200);
showMaximized ();
}
else
{
resize(settings.value("size", QSize(800, 400)).toSize());
move(settings.value("pos", QPoint(200, 200)).toPoint());
}
settings.endGroup();

settings.beginGroup("Fichiers");
Expand Down Expand Up @@ -191,14 +179,12 @@ void MainWin::setTitle(const QString &fileName)
else
shownName = QFileInfo(fileName).absoluteFilePath();

setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Tableau Blanc")));
// qDebug() << "setTitle";
setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Générateur de points")));
}

void MainWin::setStatus(const QString &msg){
// statusBar()->showMessage(msg);
infoStatus->setText(msg);
}

void MainWin::about()
{ QMessageBox::information(this, tr("A Propos"), tr("Tableau Blanc\nDessin à main levée\nAvec sérialisation")); }
{ QMessageBox::information(this, tr("A Propos"), tr("Point List Generator\nDrawbot\nhttps://github.com/HE-Arc/drawbot")); }
14 changes: 7 additions & 7 deletions src/generateur/sheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Sheet::Sheet(QWidget *parent) : QWidget(parent)
{
fileNew();
mag = 3; // 3px for 1mm on the robot
setWindowTitle("Sans Titre[*] - Dessin pour drawbot Arc");
setWindowTitle("Sans Titre[*] - Generateur de points");
setFixedSize(297*mag,210*mag);
}

Expand Down Expand Up @@ -113,8 +113,8 @@ void Sheet::readFile()
x = c[0].toDouble();
y = c[1].toDouble();

x = x*mag + 148.5*mag;
y = -y*mag + 210*mag;
x = (x*mag/100 + 148.5*mag);
y = (-y*mag/100 + 210*mag);

This comment has been minimized.

Copy link
@greut

greut Nov 29, 2016

Member

j'imagine que 148.5, 210, 297 sont liés au format du papier utilisé. Il n'y a pas moyen de créer des noms plus lisibles et de factoriser le code ?

x = (PAPIER_A6 + x / 100.) * mag;
y = (PAPIER_A5 - y / 100.) * mag;

This comment has been minimized.

Copy link
@grunenwald

grunenwald Nov 30, 2016

Author Member

Yes ! => #3


p = QPoint(x, y);
qDebug() << p;
Expand Down Expand Up @@ -161,12 +161,12 @@ void Sheet::save()
}

QTextStream sout(&fileDest);
double x, y;
sout << "double liste[] = {" << endl;
int x, y;
sout << " const int liste[] PROGMEM = {" << endl;
foreach(QPoint p, liste) {
// Chgt coordonnées widget -> feuille
x = (p.x() - 148.5*mag)/mag;
y = (210*mag - p.y())/mag;
x = 100*(p.x() - 148.5*mag)/mag;
y = 100*(210*mag - p.y())/mag;
sout << QString::number(x) << ", " << QString::number(y) << ", " << endl;
}
sout << "};" << endl;
Expand Down
4 changes: 0 additions & 4 deletions src/generateur/sheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class Sheet : public QWidget
Q_OBJECT
public:
Sheet(QWidget *parent = 0);
// ~Sheet();
// QString getFileName();
// QStringList getFileNames();

public slots:
void fileNew();
Expand Down Expand Up @@ -43,7 +40,6 @@ class Sheet : public QWidget
QStack<int> pileUndo;
double zoom, mag;
QString fileName;
//MainWin* mw;
void updateStatus();

signals:
Expand Down
16 changes: 8 additions & 8 deletions src/programme/cinematique.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

bool isInside(double x, double y){
bool isInside(float x, float y){
if( x<MIN_X+COR_X ){
Serial.print("OUT X");
Serial.print(x);
Expand Down Expand Up @@ -38,9 +38,9 @@ bool isInside(double x, double y){
else return false;
}

bool toAngle(double x, double y){
bool toAngle(float x, float y){
// Merci Julien Marchand et François Tièche !!!
double r, t, alpha, beta, gamma, halfPerimeter, angleR1, angleR2;
float r, t, alpha, beta, gamma, halfPerimeter, angleR1, angleR2;
bool lefty = false; // pas utile avec la config mécanique choisie

old1 = angle1;
Expand Down Expand Up @@ -92,18 +92,18 @@ bool toAngle(double x, double y){
void moveServos()
{
// Si grande distance ralentir mouvement
/* double delta =3;
/* float delta =3;
int inc;
if (abs(angle1-old1)>delta) {
if (angle1 > old1) {
for (double i=old1; i<angle1; i+=1) {
for (float i=old1; i<angle1; i+=1) {
s1.write(i);
delay(VITESSE);
}
}
else {
for (double i=angle1; i<old1; i-=1) {
for (float i=angle1; i<old1; i-=1) {
s1.write(i);
delay(VITESSE);
}
Expand All @@ -112,13 +112,13 @@ void moveServos()
if (abs(angle2-old2)>delta) {
if (angle2 > old2) {
for (double i=old2; i<angle2; i+=1) {
for (float i=old2; i<angle2; i+=1) {
s2.write(i);
delay(VITESSE);
}
}
else {
for (double i=angle2; i<old2; i-=1) {
for (float i=angle2; i<old2; i-=1) {
s2.write(i);
delay(VITESSE);
}
Expand Down
30 changes: 15 additions & 15 deletions src/programme/declarations.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <avr/pgmspace.h>
#include <Servo.h>
#include <EEPROM.h>
#include <math.h>
Expand All @@ -8,29 +9,29 @@ const int VITESSE=0; // Pause en ms après un mouvement
const int ANGLE_MIN=5; // si angle2 < ANGLE_MIN collision avant-bras avec bras
const int MIN_US=550, MAX_US=2350; // Commande servo en us (tester 700-2300)
const int COR_X=5, COR_Y=12; // Corrections x,y
double COR_S1=16.8, COR_S2=-3.4; // Correction angle servos en degrés
const double SHIFT_S1_ANGLE=7.5;
const double MIN_X=-130;
const double MAX_X=130;
const double MIN_Y=10;
const double MAX_Y=205;
float COR_S1=16.8, COR_S2=-3.4; // Correction angle servos en degrés
const float SHIFT_S1_ANGLE=7.5;
const float MIN_X=-130;
const float MAX_X=130;
const float MIN_Y=10;
const float MAX_Y=205;

// VARIABLES
Servo s1, s2; // s1: épaule (en A), s2: coude (en B)
double lg1=149, lg2=130; // longueur des bras (mm) lg1 = AB (bras), lg2 = BC (avant-bras)
double angle1, angle2; // position servos en degrés de s1 et s2
double old1, old2; // position précédente des angles
double pas = 0.5; // distance souhaitée en mm entre 2 points
double par = M_PI/180; // angle en radians entre deux calculs de points (1°)
float lg1=149, lg2=130; // longueur des bras (mm) lg1 = AB (bras), lg2 = BC (avant-bras)
float angle1, angle2; // position servos en degrés de s1 et s2
float old1, old2; // position précédente des angles
float pas = 0.5; // distance souhaitée en mm entre 2 points
float par = M_PI/180; // angle en radians entre deux calculs de points (1°)
bool microsec = true; // Mode précis (0.1°) si true
bool debug = true; // Affiche les déplacements dans le moniteur série

void log(char msg[], double t, double x, double y){
void log(char msg[], float t, float x, float y){
Serial.print(msg);Serial.print(" - t:");Serial.print(t);Serial.print(":(");Serial.print(x);
Serial.print(","); Serial.print(y);Serial.println(")");
}

void log(double x, double y){
void log(float x, float y){
Serial.print("angles: S1:");Serial.print(angle1);Serial.print(" S2:");Serial.println(angle2);
Serial.print(" (x,y) : (");Serial.print(x);Serial.print(",");Serial.print(y);Serial.println(")\n");
}
Expand All @@ -55,7 +56,6 @@ void lectureCorrectif(){
Serial.print("EEPROM:Epaule=");Serial.print(epaule);Serial.print(", Coude=");Serial.print(coude);
Serial.print(", Cor en us : (");Serial.print(cor_epaule);Serial.print(",");Serial.print(cor_coude);
Serial.print("), Cor en degrés : (");Serial.print(COR_S1);Serial.print(",");Serial.print(COR_S2); Serial.print(")");
Serial.println("ok");Serial.println("ok");Serial.println("ok");Serial.println("ok");Serial.println("ok");Serial.println("ok");

// Serial.println("ok");Serial.println("ok");Serial.println("ok");Serial.println("ok");Serial.println("ok");Serial.println("ok");
}

Loading

0 comments on commit a47a1ee

Please sign in to comment.