Skip to content

Commit 67b8b7c

Browse files
author
Jonan CM
committed
Initial commit of MarkCommander.
This is the source code for the MarkCommander application as it was handed in for the Robotics course at ULPGC. This version is the full GUI with icons, and provides the following functionality: * Terminal for sending raw commands to the Mark IV controller. * Direct kinematics solving, for positioning the end effector by providing the joint angles. * Inverse kinematics solving, for positioning the end effector by providing the coordinates of the TCP (Tool Center Point) and a rotation matrix that expreses the orientation of the end effector. * Configuration dialog for configuring the Mark IV controller. This version of the application may still have some errors, particularly in the inverse kinematics, but does a fairly good job and is quite usable. The code has been licensed under the terms of the Apache License.
0 parents  commit 67b8b7c

File tree

101 files changed

+5822
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+5822
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pro.user
2+
*.sh

CHANGELOG

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Initial commit of MarkCommander.
2+
3+
This is the source code for the MarkCommander application as it was handed
4+
in for the Robotics course at ULPGC. This version is the full GUI with
5+
icons, and provides the following functionality:
6+
7+
* Terminal for sending raw commands to the Mark IV controller.
8+
* Direct kinematics solving, for positioning the end effector by providing
9+
the joint angles.
10+
* Inverse kinematics solving, for positioning the end effector by
11+
providing the coordinates of the TCP (Tool Center Point) and a rotation
12+
matrix that expreses the orientation of the end effector.
13+
* Configuration dialog for configuring the Mark IV controller.
14+
15+
This version of the application may still have some errors, particularly
16+
in the inverse kinematics, but does a fairly good job and is quite usable.
17+
18+
The code has been licensed under the terms of the Apache License.
19+

ERRORS

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* En la configuraci�n del controlador, la opci�n para habilitar/deshabilitar la pinza no sirve, y la de joint/XYZ mode tampoco. [La de la pinza ahora s� deber�a servir. En cualquier caso, hay que comprobar ambas, pero ahora s� deber�an servir las dos.]
2+
* Hay problemas al conectar signals y slots:
3+
QMetaObject::connectSlotsByName: No matching signal for on_actionApplyConfiguration_triggered()
4+
QMetaObject::connectSlotsByName: No matching signal for on_actionRevertConfiguration_triggered()
5+
QMetaObject::connectSlotsByName: No matching signal for on_actionCloseConfiguration_triggered()
6+
* El programa se queda colgado cuando se intenta salir, y la �nica forma de cerrarlo es matar el proceso (pero s�lo pasa a veces).
7+
* Las funciones "moveMotor" tienen un error: hay que convertir los �ngulos a pasos y los pasos a grados [est� corregido, pero conviene revisar que est� bien hecho].

INFO

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* Tras la revisi�n 20, se volvi� a la revisi�n 19 para eliminar el Segmentation Fault, pero parece ser que el Segmentation Fault no se deb�a a los cambios hechos para implementar el editor, sino a alg�n problema con el puerto serie (por ejemplo, la ausencia de un controlador Mark IV). [Al menos en Windows 7 y en la m�quina de Windows XP. En el laboratorio la revisi�n 20 tambi�n daba un Segmentation Fault, pero no pude probar la revisi�n 19.]
2+
Ayer me funcionaba esta revisi�n (con lo de la configuraci�n y todo), y hoy me da el segmentation fault (>.<) Da cuando se abre el puerto serie en la clase 'Terminal' (en el m�todo de QextSerialPort), as� que parece que no es problema m�o, sino de QextSerialport (o del SO), porque en el programa de la entrega 1 (revisi�n 19) no da el segmentation fault.
3+
Me he pasado a un port�til, y ya no da el segmentation fault. Deb�a ser por culpa del puerto serie en el PC host.
4+
Ahora en Windows 7 tampoco peta. �Puede que fuera que en la versi�n "debug" de MarkCommander se estaba usando la compilaci�n "release" de QextSerialPort?

LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2011 Jonan Cruz-Martin
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

MarkCommander.pro

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#-------------------------------------------------
2+
#
3+
# Project created by QtCreator 2011-03-16T22:14:07
4+
#
5+
#-------------------------------------------------
6+
7+
QT += core gui webkit
8+
9+
TARGET = MarkCommander
10+
TEMPLATE = app
11+
12+
13+
SOURCES += main.cpp\
14+
mainwindow.cpp \
15+
exception.cpp \
16+
errorcodes.cpp \
17+
terminal.cpp \
18+
rhinolang.cpp \
19+
cmdlineedit.cpp \
20+
rhinoprog.cpp \
21+
rhino_xr4.cpp \
22+
matrix.cpp
23+
24+
HEADERS += \
25+
rhino_xr4.hpp \
26+
matrix.hpp \
27+
cmdlineedit.hpp \
28+
errorcodes.hpp \
29+
exception.hpp \
30+
mainwindow.hpp \
31+
rhinolang.hpp \
32+
rhinoprog.hpp \
33+
terminal.hpp
34+
35+
FORMS += mainwindow.ui
36+
37+
RESOURCES += \
38+
icons.qrc \
39+
files.qrc
40+
41+
INCLUDEPATH += ../qextserialport/src
42+
43+
#LIBS += -L../qextserialport/src-build-desktop/build -lqextserialportd1
44+
#LIBS += -L../qextserialport/src-build-desktop/build -lqextserialport1
45+
#macx:LIBS += -L../qextserialport-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Debug/src/build -lqextserialportd
46+
macx:LIBS += -L../qextserialport-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/src/build -lqextserialport
47+
48+
win32:RC_FILE = MarkCommander.rc
49+
macx:ICON = appicon.icns
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+

MarkCommander.rc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IDI_ICON1 ICON DISCARDABLE "appicon.ico"

TODO

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Supuestamente, debería poderse parar el timer de polling una vez se recibe el Carriage Return del controlador.
2+
* Añadir una barra de progreso a la barra de estado para indicar que se está esperando la respuesta del controlador.
3+
* Corregir el control manual en el espacio de las articulaciones para que sea más fluido.

appicon.icns

117 KB
Binary file not shown.

appicon.ico

9.9 KB
Binary file not shown.

cmdlineedit.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2011 Jonán C. Martín
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "cmdlineedit.hpp"
16+
17+
#include <QKeyEvent>
18+
19+
CmdLineEdit::CmdLineEdit(QWidget *parent) : QLineEdit(parent)
20+
{
21+
historyIndex = 0;
22+
}
23+
24+
void CmdLineEdit::addCmdToHistory(QString cmd)
25+
{
26+
_cmdHistory.append(cmd);
27+
historyIndex++;
28+
}
29+
30+
QStringList CmdLineEdit::cmdHistory()
31+
{
32+
return _cmdHistory;
33+
}
34+
35+
void CmdLineEdit::keyPressEvent(QKeyEvent *event)
36+
{
37+
if (event->key() == Qt::Key_Up)
38+
{
39+
if (!_cmdHistory.isEmpty() && historyIndex > 0)
40+
{
41+
historyIndex--;
42+
setText(_cmdHistory.at(historyIndex));
43+
}
44+
}
45+
else if (event->key() == Qt::Key_Down)
46+
{
47+
if (!_cmdHistory.isEmpty())
48+
{
49+
if (++historyIndex < _cmdHistory.size())
50+
setText(_cmdHistory.at(historyIndex));
51+
else
52+
{
53+
historyIndex = _cmdHistory.size();
54+
setText(currentCmd);
55+
}
56+
}
57+
}
58+
else
59+
QLineEdit::keyPressEvent(event);
60+
}

cmdlineedit.hpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2011 Jonán C. Martín
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef CMDLINEEDIT_H
16+
#define CMDLINEEDIT_H
17+
18+
#include <QLineEdit>
19+
20+
class CmdLineEdit : public QLineEdit
21+
{
22+
Q_OBJECT
23+
24+
public:
25+
CmdLineEdit(QWidget *parent=0);
26+
void addCmdToHistory(QString cmd);
27+
QStringList cmdHistory();
28+
29+
protected:
30+
void keyPressEvent(QKeyEvent *event);
31+
32+
private:
33+
QStringList _cmdHistory;
34+
int historyIndex;
35+
QString currentCmd;
36+
};
37+
38+
#endif // CMDLINEEDIT_H

errorcodes.cpp

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Copyright 2011 Jonán C. Martín
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "errorcodes.hpp"
16+
17+
// Reg exp for Notepad++'s Ctrl-H (Search & Replace):
18+
// >>(\#define)( )([A-Z\_]+)([ ]+[0-9]+[ ]+//[ ])([A-Za-z0-9 \'\(\)\,\.=]+)<<
19+
// >> case \3: return "\5";<<
20+
21+
const char * errcode_meaning(int errorno)
22+
{
23+
switch (errorno)
24+
{
25+
/***********************************************************************
26+
* COMMAND ERRORS
27+
***********************************************************************/
28+
29+
case INV_CMD: return "Invalid command";
30+
case PAR_OUT: return "Parameter out of bounds";
31+
case MIS_PAR: return "Missing parameter";
32+
case NO_DLIM: return "Expected delimiter not seen";
33+
case TOO_MNY: return "Command string too long";
34+
case TP_ACTV: return "The teach pendant is active or busy";
35+
36+
/***********************************************************************
37+
* COMMUNICATION ERRORS
38+
***********************************************************************/
39+
40+
case HST_OVF: return "Host input buffer overflow";
41+
case HST_TMO: return "Host USART timed out";
42+
case HST_ERR: return "Host USART error (framing, parity, etc.)";
43+
case TP_OVF: return "Teach pendant input buffer overflow";
44+
case TP_TMO: return "Teach pendant USART timed out";
45+
case TP_ERRO: return "Teach pendant USART error (framing, parity, etc.)";
46+
case TP_OVRN: return "Teach pendant USART overrun";
47+
case HST_OVR: return "Host USART overrun";
48+
49+
/***********************************************************************
50+
* DIAGNOSTIC ERRORS
51+
***********************************************************************/
52+
53+
case BAD_RAM: return "Bad RAM location";
54+
case TP_ERR: return "Teach pendant returned diagnostic error";
55+
case NO_TP: return "Teach pendant not present";
56+
57+
/***********************************************************************
58+
* TEACH PENDANT PROGRAM ERRORS
59+
***********************************************************************/
60+
61+
case LAB_ERR: return "Missing label";
62+
case NO_PGRM: return "No program in memory";
63+
case MEM_FUL: return "Insufficient teach pendant memory";
64+
case EPM_FUL: return "Insufficient EEPROM memory";
65+
case RPL_ERR: return "Can't replace first record";
66+
case PROGRAM: return "A pendant program already exists";
67+
68+
/***********************************************************************
69+
* EXECUTION ERRORS
70+
***********************************************************************/
71+
72+
case HRD_ERR: return "Hard home routine failed";
73+
case NO_HARD: return "Hard home not set";
74+
case NO_SOFT: return "Soft home not set";
75+
case AR_OVFL: return "Arithmetic overflow";
76+
case TRG_ERR: return "Trig function return error";
77+
case STK_ERR: return "Error stack overflow";
78+
case BUSY: return "Still executing a trapezoidal move";
79+
case NO_MOTR: return "Inactive motor referenced";
80+
case MOV_DAT: return "Insufficient move data (velocity or acceleration = 0)";
81+
case BAD_MOD: return "Improper motor mode for command";
82+
case NO_A_SW: return "Limit switch A not found";
83+
case NO_B_SW: return "Limit switch B not found";
84+
case NO_C_SW: return "Limit switch C not found";
85+
case NO_D_SW: return "Limit switch D not found";
86+
case NO_E_SW: return "Limit switch E not found";
87+
case NO_F_SW: return "Limit switch F not found";
88+
case NO_G_SW: return "Limit switch G not found";
89+
case NO_H_SW: return "Limit switch H not found";
90+
case IMODE: return "Interpolation move out of bounds";
91+
case POS_OUT: return "XYZ position out of bounds";
92+
case STK_A_S: return "Limit switch A stuck";
93+
case STK_B_S: return "Limit switch B stuck";
94+
case STK_C_S: return "Limit switch C stuck";
95+
case STK_D_S: return "Limit switch D stuck";
96+
case STK_E_S: return "Limit switch E stuck";
97+
case STK_F_S: return "Limit switch F stuck";
98+
case STK_G_S: return "Limit switch G stuck";
99+
case STK_H_S: return "Limit switch H stuck";
100+
case INV_RBT: return "Invalid robot type specifier";
101+
case INV_MOT: return "Invalid motor specifier";
102+
case INV_CTL: return "Invalid controller type";
103+
case INV_PND: return "Invalid pendant mode";
104+
case STOP: return "Emergency stop";
105+
case INV_XYZ: return "Invalid xyz specifier";
106+
case XYZ_PAR: return "Invalid xyz parameter";
107+
108+
/***********************************************************************
109+
* MOTOR ERRORS
110+
***********************************************************************/
111+
112+
case A_STALL: return "Motor A stalled";
113+
case B_STALL: return "Motor B stalled";
114+
case C_STALL: return "Motor C stalled";
115+
case D_STALL: return "Motor D stalled";
116+
case E_STALL: return "Motor E stalled";
117+
case F_STALL: return "Motor F stalled";
118+
case G_STALL: return "Motor G stalled";
119+
case H_STALL: return "Motor H stalled";
120+
case A_CURLIM: return "Motor A's current limit circuit was activated";
121+
case B_CURLIM: return "Motor B's current limit circuit was activated";
122+
case C_CURLIM: return "Motor C's current limit circuit was activated";
123+
case D_CURLIM: return "Motor D's current limit circuit was activated";
124+
case E_CURLIM: return "Motor E's current limit circuit was activated";
125+
case F_CURLIM: return "Motor F's current limit circuit was activated";
126+
case G_CURLIM: return "Motor G's current limit circuit was activated";
127+
case H_CURLIM: return "Motor H's current limit circuit was activated";
128+
case I_CURLIM: return "Aux Port 1's current limit circuit was activated";
129+
case J_CURLIM: return "Aux Port 2's current limit circuit was activated";
130+
131+
default: return "Unknown error code";
132+
}
133+
}

0 commit comments

Comments
 (0)