Skip to content

Commit

Permalink
Initial commit of MarkCommander.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jonan CM committed Oct 9, 2013
0 parents commit 67b8b7c
Show file tree
Hide file tree
Showing 101 changed files with 5,822 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pro.user
*.sh
19 changes: 19 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.

7 changes: 7 additions & 0 deletions ERRORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* 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.]
* Hay problemas al conectar signals y slots:
QMetaObject::connectSlotsByName: No matching signal for on_actionApplyConfiguration_triggered()
QMetaObject::connectSlotsByName: No matching signal for on_actionRevertConfiguration_triggered()
QMetaObject::connectSlotsByName: No matching signal for on_actionCloseConfiguration_triggered()
* 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).
* 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].
4 changes: 4 additions & 0 deletions INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* 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.]
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.
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.
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?
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2011 Jonan Cruz-Martin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
63 changes: 63 additions & 0 deletions MarkCommander.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#-------------------------------------------------
#
# Project created by QtCreator 2011-03-16T22:14:07
#
#-------------------------------------------------

QT += core gui webkit

TARGET = MarkCommander
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp \
exception.cpp \
errorcodes.cpp \
terminal.cpp \
rhinolang.cpp \
cmdlineedit.cpp \
rhinoprog.cpp \
rhino_xr4.cpp \
matrix.cpp

HEADERS += \
rhino_xr4.hpp \
matrix.hpp \
cmdlineedit.hpp \
errorcodes.hpp \
exception.hpp \
mainwindow.hpp \
rhinolang.hpp \
rhinoprog.hpp \
terminal.hpp

FORMS += mainwindow.ui

RESOURCES += \
icons.qrc \
files.qrc

INCLUDEPATH += ../qextserialport/src

#LIBS += -L../qextserialport/src-build-desktop/build -lqextserialportd1
#LIBS += -L../qextserialport/src-build-desktop/build -lqextserialport1
#macx:LIBS += -L../qextserialport-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Debug/src/build -lqextserialportd
macx:LIBS += -L../qextserialport-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/src/build -lqextserialport

win32:RC_FILE = MarkCommander.rc
macx:ICON = appicon.icns














1 change: 1 addition & 0 deletions MarkCommander.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "appicon.ico"
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Supuestamente, debería poderse parar el timer de polling una vez se recibe el Carriage Return del controlador.
* Añadir una barra de progreso a la barra de estado para indicar que se está esperando la respuesta del controlador.
* Corregir el control manual en el espacio de las articulaciones para que sea más fluido.
Binary file added appicon.icns
Binary file not shown.
Binary file added appicon.ico
Binary file not shown.
60 changes: 60 additions & 0 deletions cmdlineedit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2011 Jonán C. Martín
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "cmdlineedit.hpp"

#include <QKeyEvent>

CmdLineEdit::CmdLineEdit(QWidget *parent) : QLineEdit(parent)
{
historyIndex = 0;
}

void CmdLineEdit::addCmdToHistory(QString cmd)
{
_cmdHistory.append(cmd);
historyIndex++;
}

QStringList CmdLineEdit::cmdHistory()
{
return _cmdHistory;
}

void CmdLineEdit::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Up)
{
if (!_cmdHistory.isEmpty() && historyIndex > 0)
{
historyIndex--;
setText(_cmdHistory.at(historyIndex));
}
}
else if (event->key() == Qt::Key_Down)
{
if (!_cmdHistory.isEmpty())
{
if (++historyIndex < _cmdHistory.size())
setText(_cmdHistory.at(historyIndex));
else
{
historyIndex = _cmdHistory.size();
setText(currentCmd);
}
}
}
else
QLineEdit::keyPressEvent(event);
}
38 changes: 38 additions & 0 deletions cmdlineedit.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2011 Jonán C. Martín
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef CMDLINEEDIT_H
#define CMDLINEEDIT_H

#include <QLineEdit>

class CmdLineEdit : public QLineEdit
{
Q_OBJECT

public:
CmdLineEdit(QWidget *parent=0);
void addCmdToHistory(QString cmd);
QStringList cmdHistory();

protected:
void keyPressEvent(QKeyEvent *event);

private:
QStringList _cmdHistory;
int historyIndex;
QString currentCmd;
};

#endif // CMDLINEEDIT_H
133 changes: 133 additions & 0 deletions errorcodes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Copyright 2011 Jonán C. Martín
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "errorcodes.hpp"

// Reg exp for Notepad++'s Ctrl-H (Search & Replace):
// >>(\#define)( )([A-Z\_]+)([ ]+[0-9]+[ ]+//[ ])([A-Za-z0-9 \'\(\)\,\.=]+)<<
// >> case \3: return "\5";<<

const char * errcode_meaning(int errorno)
{
switch (errorno)
{
/***********************************************************************
* COMMAND ERRORS
***********************************************************************/

case INV_CMD: return "Invalid command";
case PAR_OUT: return "Parameter out of bounds";
case MIS_PAR: return "Missing parameter";
case NO_DLIM: return "Expected delimiter not seen";
case TOO_MNY: return "Command string too long";
case TP_ACTV: return "The teach pendant is active or busy";

/***********************************************************************
* COMMUNICATION ERRORS
***********************************************************************/

case HST_OVF: return "Host input buffer overflow";
case HST_TMO: return "Host USART timed out";
case HST_ERR: return "Host USART error (framing, parity, etc.)";
case TP_OVF: return "Teach pendant input buffer overflow";
case TP_TMO: return "Teach pendant USART timed out";
case TP_ERRO: return "Teach pendant USART error (framing, parity, etc.)";
case TP_OVRN: return "Teach pendant USART overrun";
case HST_OVR: return "Host USART overrun";

/***********************************************************************
* DIAGNOSTIC ERRORS
***********************************************************************/

case BAD_RAM: return "Bad RAM location";
case TP_ERR: return "Teach pendant returned diagnostic error";
case NO_TP: return "Teach pendant not present";

/***********************************************************************
* TEACH PENDANT PROGRAM ERRORS
***********************************************************************/

case LAB_ERR: return "Missing label";
case NO_PGRM: return "No program in memory";
case MEM_FUL: return "Insufficient teach pendant memory";
case EPM_FUL: return "Insufficient EEPROM memory";
case RPL_ERR: return "Can't replace first record";
case PROGRAM: return "A pendant program already exists";

/***********************************************************************
* EXECUTION ERRORS
***********************************************************************/

case HRD_ERR: return "Hard home routine failed";
case NO_HARD: return "Hard home not set";
case NO_SOFT: return "Soft home not set";
case AR_OVFL: return "Arithmetic overflow";
case TRG_ERR: return "Trig function return error";
case STK_ERR: return "Error stack overflow";
case BUSY: return "Still executing a trapezoidal move";
case NO_MOTR: return "Inactive motor referenced";
case MOV_DAT: return "Insufficient move data (velocity or acceleration = 0)";
case BAD_MOD: return "Improper motor mode for command";
case NO_A_SW: return "Limit switch A not found";
case NO_B_SW: return "Limit switch B not found";
case NO_C_SW: return "Limit switch C not found";
case NO_D_SW: return "Limit switch D not found";
case NO_E_SW: return "Limit switch E not found";
case NO_F_SW: return "Limit switch F not found";
case NO_G_SW: return "Limit switch G not found";
case NO_H_SW: return "Limit switch H not found";
case IMODE: return "Interpolation move out of bounds";
case POS_OUT: return "XYZ position out of bounds";
case STK_A_S: return "Limit switch A stuck";
case STK_B_S: return "Limit switch B stuck";
case STK_C_S: return "Limit switch C stuck";
case STK_D_S: return "Limit switch D stuck";
case STK_E_S: return "Limit switch E stuck";
case STK_F_S: return "Limit switch F stuck";
case STK_G_S: return "Limit switch G stuck";
case STK_H_S: return "Limit switch H stuck";
case INV_RBT: return "Invalid robot type specifier";
case INV_MOT: return "Invalid motor specifier";
case INV_CTL: return "Invalid controller type";
case INV_PND: return "Invalid pendant mode";
case STOP: return "Emergency stop";
case INV_XYZ: return "Invalid xyz specifier";
case XYZ_PAR: return "Invalid xyz parameter";

/***********************************************************************
* MOTOR ERRORS
***********************************************************************/

case A_STALL: return "Motor A stalled";
case B_STALL: return "Motor B stalled";
case C_STALL: return "Motor C stalled";
case D_STALL: return "Motor D stalled";
case E_STALL: return "Motor E stalled";
case F_STALL: return "Motor F stalled";
case G_STALL: return "Motor G stalled";
case H_STALL: return "Motor H stalled";
case A_CURLIM: return "Motor A's current limit circuit was activated";
case B_CURLIM: return "Motor B's current limit circuit was activated";
case C_CURLIM: return "Motor C's current limit circuit was activated";
case D_CURLIM: return "Motor D's current limit circuit was activated";
case E_CURLIM: return "Motor E's current limit circuit was activated";
case F_CURLIM: return "Motor F's current limit circuit was activated";
case G_CURLIM: return "Motor G's current limit circuit was activated";
case H_CURLIM: return "Motor H's current limit circuit was activated";
case I_CURLIM: return "Aux Port 1's current limit circuit was activated";
case J_CURLIM: return "Aux Port 2's current limit circuit was activated";

default: return "Unknown error code";
}
}
Loading

0 comments on commit 67b8b7c

Please sign in to comment.