Compare commits

24 Commits

Author SHA1 Message Date
13a4942562 Modifiche interfaccia 2019-11-19 17:54:09 +01:00
5942c9b21a Corretta logica colorazione etichette stato nodi ROS 2019-11-18 11:37:04 +01:00
57c2b4ed3a Collegato bottone per spegnimento graceful nod ROS 2019-11-18 11:29:48 +01:00
2f59630197 Modificato il modo di colorare le label per nodi ROS 2019-11-18 11:25:51 +01:00
069fa97b40 Aggiornamento callback MQTT per nodo broadcaster 2019-11-15 16:44:21 +01:00
66bf6d5710 aggiunto broadcaster a interfaccia e configurazione 2019-11-15 14:50:07 +01:00
5c7caa3259 Aggiunto nodo broadcaster a interfaccia e shared memory 2019-11-15 14:49:45 +01:00
623ae0bedb Aggiunto checkbox per il plot del percorso caricato 2019-11-14 15:45:18 +01:00
04ae933f6e Modifiche interfaccia per frame riferimento 2019-11-13 15:55:55 +01:00
4970162ed5 correzioni interfaccia 2019-11-12 11:37:31 +01:00
e1e80d16c7 Inizia implementazione setPlanning Frame 2019-11-12 10:49:52 +01:00
cb2b5fdcbd Correzioni alla gui, riportato livello di log di com a warn 2019-11-12 09:57:55 +01:00
bf368d6ac6 Corretta gestione Heartbeat 2019-11-05 16:47:55 +01:00
64a4b9b122 Corretto calcolo del tempo heartbeat 2019-11-05 16:15:53 +01:00
187c3ed9fc Aggiunta parametrizzazione topic mqtt e nomi dei nodi ros 2019-11-05 15:49:12 +01:00
6b1012348c Aggiunte label status ROS ad interfaccia 2019-11-05 13:53:57 +01:00
29db06e3c4 Aggiunte funzioni di lettura di Startup/Heartbeat
funzioni aggiunte nelle callback mqtt che segnalano il cambiamento con
l'emit di commonStatusChange
2019-11-04 15:40:22 +01:00
9483e265f3 aggiunto topic interface, cambiato modo di subscribe mqtt 2019-10-30 16:33:36 +01:00
117cf20765 Modifiche interfaccia 2019-10-30 12:06:26 +01:00
b843b8439e Risolto problema in libURcom
package lenght mismatch per il pacchetto tipo 8 AdditionalInfo,
aggiunto uchar foo alla fine per far sparire l'errore.. chi sa perchè?
2019-10-29 10:39:35 +01:00
b5566594b6 Aggiornati offset assi (Simulazione) 2019-10-29 10:38:29 +01:00
a2b5557357 Aggiornate calibrazioni, interfaccia e progetto 2019-10-23 17:50:35 +02:00
9f0074b534 Aggiunto checkbox execute per l'homing 2019-10-23 17:49:26 +02:00
bf0ec30e16 Aggiunto pulsante per Homing Robot e relativo messaggio 2019-10-23 11:46:15 +02:00
16 changed files with 531 additions and 182 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2019-07-10T11:42:03. --> <!-- Written by QtCreator 4.8.2, 2019-11-18T18:58:05. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@@ -1,9 +1,10 @@
#include "mqtt_callback.h" #include "mqtt_callback.h"
mqtt_callback::mqtt_callback(mqtt::async_client *cli, std::shared_ptr<spdlog::logger> log) { mqtt_callback::mqtt_callback(mqtt::async_client *cli, std::shared_ptr<spdlog::logger> log, RoboGlue_SHARED *mem) {
//initialize client pointer //initialize client pointer
cli_=cli; cli_=cli;
log_=log; log_=log;
mem_= mem;
} }
void mqtt_callback::connected(const mqtt::string &cause) { void mqtt_callback::connected(const mqtt::string &cause) {
@@ -17,6 +18,47 @@ void mqtt_callback::connection_lost(const mqtt::string &cause) {
void mqtt_callback::message_arrived(mqtt::const_message_ptr msg) { void mqtt_callback::message_arrived(mqtt::const_message_ptr msg) {
log_->debug("Message Arrived: topic->{} - message->{}", log_->debug("Message Arrived: topic->{} - message->{}",
msg->get_topic(), msg->to_string()); msg->get_topic(), msg->to_string());
if(msg->get_topic() == mem_->comSettings.subMap.find("interface")->second) {
log_->debug("MQTT: Interface Message: {}", msg->get_payload().c_str());
// Gestione dei messaggi di interfaccia
std::vector<std::string> intMsg;
boost::split(intMsg, static_cast<const std::string>(msg->to_string()), boost::is_any_of(":"));
if (!intMsg[mem_->comSettings.TYPE].compare("STARTUP") ||
!intMsg[mem_->comSettings.TYPE].compare("HB")){
// Received Startup Message
log_->debug("Startup/Heartbeat from node, ts: {},[{}]",
intMsg[mem_->comSettings.NODE].c_str(),
intMsg[mem_->comSettings.TS]);
if (!intMsg[mem_->comSettings.NODE].compare(mem_->comSettings.nodeNames["relay"])){
mem_->commonStatus.relayRunning = true;
mem_->commonStatus.relayLast = std::stod(intMsg[mem_->comSettings.TS]);
log_->trace("HB RELAY time: [{}]", mem_->commonStatus.relayLast);
} else if (!intMsg[mem_->comSettings.NODE].compare(mem_->comSettings.nodeNames["follower"])) {
mem_->commonStatus.followerRunning = true;
mem_->commonStatus.followerLast = std::stod(intMsg[mem_->comSettings.TS]);
log_->trace("HB FOLLOWER time: [{}]", mem_->commonStatus.followerLast);
} else if (!intMsg[mem_->comSettings.NODE].compare(mem_->comSettings.nodeNames["recorder"])) {
mem_->commonStatus.recorderRunning = true;
mem_->commonStatus.recorderLast = std::stod(intMsg[mem_->comSettings.TS]);
log_->trace("HB RECORDER time: [{}]", mem_->commonStatus.recorderLast);
} else if (!intMsg[mem_->comSettings.NODE].compare(mem_->comSettings.nodeNames["broadcaster"])) {
mem_->commonStatus.broadcasterRunning = true;
mem_->commonStatus.broadcasterLast = std::stod(intMsg[mem_->comSettings.TS]);
log_->trace("HB BROADCASTER time: [{}]", mem_->commonStatus.broadcasterLast);
} else {
log_->error("Node {} unknown", intMsg[mem_->comSettings.NODE].c_str());
}
//emit mem_->commonStatusChange();
}
} else if (msg->get_topic() == mem_->comSettings.subMap.find("state")->second){
log_->debug("MQTT: State Message: {}", msg->get_payload().c_str());
} else if (msg->get_topic() == mem_->comSettings.subMap.find("commands")->second){
log_->debug("MQTT: Command Message: {}", msg->get_payload().c_str());
} else if (msg->get_topic() == mem_->comSettings.subMap.find("coordinates")->second){
log_->debug("MQTT: Coordinate Message: {}", msg->get_payload().c_str());
} else {
log_->error("Unrecognized topic: {}", msg->get_topic().c_str());
}
} }
void mqtt_callback::delivery_complete(mqtt::delivery_token_ptr tok) { void mqtt_callback::delivery_complete(mqtt::delivery_token_ptr tok) {

View File

@@ -4,15 +4,17 @@
#include <mqtt/client.h> #include <mqtt/client.h>
#include <mqtt/callback.h> #include <mqtt/callback.h>
#include <spdlog/logger.h> #include <spdlog/logger.h>
#include <shared/roboglue_shared.h>
class mqtt_callback : public virtual mqtt::callback { class mqtt_callback : public virtual mqtt::callback {
private: private:
RoboGlue_SHARED *mem_;
mqtt::async_client *cli_ = nullptr; mqtt::async_client *cli_ = nullptr;
std::shared_ptr<spdlog::logger> log_; std::shared_ptr<spdlog::logger> log_;
public: public:
mqtt_callback(mqtt::async_client *cli, std::shared_ptr<spdlog::logger> log); mqtt_callback(mqtt::async_client *cli, std::shared_ptr<spdlog::logger> log,RoboGlue_SHARED *m);
void connected(const mqtt::string &cause) override; void connected(const mqtt::string &cause) override;
void connection_lost(const mqtt::string &cause) override; void connection_lost(const mqtt::string &cause) override;

View File

@@ -5,8 +5,8 @@ RoboGlue_COM::RoboGlue_COM (RoboGlue_SHARED *mem): m(mem) {
//////// SETUP LOGGER ////////// //////// SETUP LOGGER //////////
liblog = spdlog::stdout_logger_mt("URcom_liblog"); liblog = spdlog::stdout_logger_mt("URcom_liblog");
modlog = spdlog::stdout_logger_mt("RoboGlue_comlog"); modlog = spdlog::stdout_logger_mt("RoboGlue_comlog");
liblog->set_level(spdlog::level::info); liblog->set_level(spdlog::level::warn);
modlog->set_level(spdlog::level::debug); modlog->set_level(spdlog::level::warn);
///////// INITIALIZE TCP SERVER /////////// ///////// INITIALIZE TCP SERVER ///////////
server = new QTcpServer(this); server = new QTcpServer(this);
@@ -16,7 +16,7 @@ RoboGlue_COM::RoboGlue_COM (RoboGlue_SHARED *mem): m(mem) {
//////// INITIALIZE MQTT CONNECTOR /////// //////// INITIALIZE MQTT CONNECTOR ///////
client = new mqtt::async_client(std::string("tcp://localhost:1883"),""); client = new mqtt::async_client(std::string("tcp://localhost:1883"),"");
callback = new mqtt_callback(client,modlog);//////////////////////////////////////////////// callback = new mqtt_callback(client,modlog,m);////////////////////////////////////////////////
//////// END EXTERNAL PUBLIC SLOTS ///////////// //////// END EXTERNAL PUBLIC SLOTS /////////////
//////////////////////////////////////////////// ////////////////////////////////////////////////
baseMsg = m->commonSettings.baseMessage; baseMsg = m->commonSettings.baseMessage;
@@ -35,9 +35,12 @@ void RoboGlue_COM::run() {
client->set_callback(*callback); client->set_callback(*callback);
client->connect()->wait(); client->connect()->wait();
// subscrbe to mqtt topics // subscrbe to mqtt topics
std::vector<std::string> subList = m->comSettings.subList; try{
for (uint i=0; i < subList.size(); i++){ for (auto it=m->comSettings.subMap.begin(); it != m->comSettings.subMap.end(); ++it){
client->subscribe(subList[i],0); client->subscribe(it->second,0);
}
} catch (mqtt::exception &e) {
modlog->error("MQTT Error {}", e.what());
} }
client->start_consuming(); client->start_consuming();
@@ -270,7 +273,7 @@ void RoboGlue_COM::timed_sendCoordinates(){
baseMsg["value"]["rx"] = sp[3]; baseMsg["value"]["rx"] = sp[3];
baseMsg["value"]["ry"] = sp[4]; baseMsg["value"]["ry"] = sp[4];
baseMsg["value"]["rz"] = sp[5]; baseMsg["value"]["rz"] = sp[5];
MQTTpublish(baseMsg, m->comSettings.pubList[m->comSettings.COORD]); MQTTpublish(baseMsg, m->comSettings.pubMap.find("coordinates")->second);
} }
} }
//////////////////////////////////////////////// ////////////////////////////////////////////////
@@ -329,7 +332,7 @@ void RoboGlue_COM::on_sendROScommand(QString command, QVariantMap params) {
baseMsg["command"] = command.toStdString(); baseMsg["command"] = command.toStdString();
QJsonDocument jparam = QJsonDocument(QJsonObject::fromVariantMap(params)); QJsonDocument jparam = QJsonDocument(QJsonObject::fromVariantMap(params));
baseMsg["params"] = json::parse(jparam.toJson().data()); baseMsg["params"] = json::parse(jparam.toJson().data());
MQTTpublish(baseMsg, m->comSettings.pubList[m->comSettings.COMM]); MQTTpublish(baseMsg, m->comSettings.pubMap.find("commands")->second);
} }
void RoboGlue_COM::on_sendROScoordinates(QList<double> sp) { void RoboGlue_COM::on_sendROScoordinates(QList<double> sp) {
@@ -350,41 +353,3 @@ void RoboGlue_COM::on_sendROSstate(QMap<std::string,bool> digital, QMap<std::str
//////////////////////////////////////////////// ////////////////////////////////////////////////
//////// END EXTERNAL PUBLIC SLOTS ///////////// //////// END EXTERNAL PUBLIC SLOTS /////////////
//////////////////////////////////////////////// ////////////////////////////////////////////////
//void RoboGlue_COM::on_sendSetpointOLD(QList<double> sp) {
// std::string setpoint;
// struct {
// union{
// struct{
// uint32_t x,y,z,a,b,c,keepalive;
// };
// char bytes[28];
// };
// } setPointBytes;
// setPointBytes.keepalive=1;
// int32_t v;
// setpoint = "(";
// for(uchar i=0; i<JOINT_NUMBER; i++){
// v=static_cast<int32_t>(sp[i]*1000);
// if (i>2) v=boost::algorithm::clamp(v, -2680,2680);
// setpoint.append(std::to_string(v));
// boost::algorithm::replace_all(setpoint, ",",".");
// if(i<JOINT_NUMBER) setpoint.append("|");
// }
// setpoint.append("1");
// boost::algorithm::replace_all(setpoint,"|",",");
// setpoint.append(")");
// setPointBytes.x=htonl(static_cast<uint32_t>(sp[0]*1000));
// setPointBytes.y=htonl(static_cast<uint32_t>(sp[1]*1000));
// setPointBytes.z=htonl(static_cast<uint32_t>(sp[2]*1000));
// setPointBytes.a=htonl(static_cast<uint32_t>(sp[3]*1000));
// setPointBytes.b=htonl(static_cast<uint32_t>(sp[4]*1000));
// setPointBytes.c=htonl(static_cast<uint32_t>(sp[5]*1000));
// setPointBytes.keepalive=htonl(setPointBytes.keepalive);
// if(robotIN->write(setPointBytes.bytes,28))
// modlog->trace("Sent Setpoint {}",setpoint.c_str());
// robotIN->flush();
//}

View File

@@ -44,7 +44,8 @@
* della coda di destinazione. * della coda di destinazione.
* 20190311 - La pubblicazione dei messaggi di coordinate verso ros deve essere a rateo costante * 20190311 - La pubblicazione dei messaggi di coordinate verso ros deve essere a rateo costante
* indipendentemente dalla frequenza di ingresso * indipendentemente dalla frequenza di ingresso
*/ * 20191030 - Spostata la documentazione su GIT
*/
#include <QObject> #include <QObject>
#include <QThread> #include <QThread>

View File

@@ -26,6 +26,8 @@ RoboGlue_GUI::RoboGlue_GUI(RoboGlue_SHARED *mem) : m(mem) {
this, SLOT(deleteLater()), Qt::ConnectionType::QueuedConnection); this, SLOT(deleteLater()), Qt::ConnectionType::QueuedConnection);
connect(this, SIGNAL(pad_hoverEvent(QEvent *)), connect(this, SIGNAL(pad_hoverEvent(QEvent *)),
this, SLOT(on_pad_hoverEvent(QEvent *))); this, SLOT(on_pad_hoverEvent(QEvent *)));
connect(m, SIGNAL(commonStatusChange()),
this, SLOT(on_commonStatusChange()));
/////// READ NAME DEFINITION JSON FILE ////////// /////// READ NAME DEFINITION JSON FILE //////////
try { try {
@@ -89,6 +91,18 @@ void RoboGlue_GUI::disableLockAxes(){
//////////////////////////////////////////////// ////////////////////////////////////////////////
void RoboGlue_GUI::on_commonStatusChange() { void RoboGlue_GUI::on_commonStatusChange() {
modlog->trace("on_commonStatusChange Received"); modlog->trace("on_commonStatusChange Received");
this->ui->lbl_relay->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("relay")->second+": "+std::to_string(static_cast<uint>(m->commonStatus.relayTime))));
this->ui->lbl_follower->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("follower")->second+": "+std::to_string(static_cast<uint>(m->commonStatus.followerTime))));
this->ui->lbl_recorder->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("recorder")->second+": "+std::to_string(static_cast<uint>(m->commonStatus.recorderTime))));
this->ui->lbl_broadcaster->setText(QString().fromStdString(this->m->comSettings.nodeNames.find("broadcaster")->second+": "+std::to_string(static_cast<uint>(m->commonStatus.broadcasterTime))));
if (!m->commonStatus.relayRunning) this->ui->lbl_relay->setStyleSheet("QLabel { background-color : red; color : white; }");
else this->ui->lbl_relay->setStyleSheet("QLabel { background-color : green; color : white; }");
if (!m->commonStatus.recorderRunning) this->ui->lbl_recorder->setStyleSheet("QLabel { background-color : red; color : white; }");
else this->ui->lbl_recorder->setStyleSheet("QLabel { background-color : green; color : white; }");
if (!m->commonStatus.followerRunning) this->ui->lbl_follower->setStyleSheet("QLabel { background-color : red; color : white; }");
else this->ui->lbl_follower->setStyleSheet("QLabel { background-color : green; color : white; }");
if (!m->commonStatus.broadcasterRunning) this->ui->lbl_broadcaster->setStyleSheet("QLabel { background-color : red; color : white; }");
else this->ui->lbl_broadcaster->setStyleSheet("QLabel { background-color : green; color : white; }");
} }
void RoboGlue_GUI::on_pad_hoverEvent(QEvent* e) { void RoboGlue_GUI::on_pad_hoverEvent(QEvent* e) {
@@ -196,6 +210,7 @@ void RoboGlue_GUI::on_btn_record_clicked() {
param["metadata"] = metadata; param["metadata"] = metadata;
ui->btn_play->setEnabled(false); ui->btn_play->setEnabled(false);
ui->btn_realtime->setEnabled(false); ui->btn_realtime->setEnabled(false);
ui->btn_home->setEnabled(false);
disableLockAxes(); disableLockAxes();
} else { } else {
m->commonStatus.isRecording = false; m->commonStatus.isRecording = false;
@@ -203,6 +218,7 @@ void RoboGlue_GUI::on_btn_record_clicked() {
param["action"]="stop"; param["action"]="stop";
ui->btn_play->setEnabled(true); ui->btn_play->setEnabled(true);
ui->btn_realtime->setEnabled(true); ui->btn_realtime->setEnabled(true);
ui->btn_home->setEnabled(true);
enableLockAxes(); enableLockAxes();
} }
emit m->commonStatusChange(); emit m->commonStatusChange();
@@ -223,6 +239,7 @@ void RoboGlue_GUI::on_btn_play_clicked() {
param["lock"] = getLockAxes(); param["lock"] = getLockAxes();
ui->btn_record->setEnabled(false); ui->btn_record->setEnabled(false);
ui->btn_realtime->setEnabled(false); ui->btn_realtime->setEnabled(false);
ui->btn_home->setEnabled(false);
ui->btn_play->setText("Stop"); ui->btn_play->setText("Stop");
ui->txt_fileName->setEnabled(false); ui->txt_fileName->setEnabled(false);
disableLockAxes(); disableLockAxes();
@@ -232,6 +249,7 @@ void RoboGlue_GUI::on_btn_play_clicked() {
param["action"] = "stop"; param["action"] = "stop";
ui->btn_record->setEnabled(true); ui->btn_record->setEnabled(true);
ui->btn_realtime->setEnabled(true); ui->btn_realtime->setEnabled(true);
ui->btn_home->setEnabled(true);
ui->btn_play->setText("Play"); ui->btn_play->setText("Play");
ui->txt_fileName->setEnabled(true); ui->txt_fileName->setEnabled(true);
enableLockAxes(); enableLockAxes();
@@ -249,11 +267,12 @@ void RoboGlue_GUI::on_btn_open_clicked() {
m->commonStatus.isFileOpen = true; m->commonStatus.isFileOpen = true;
fileOpen = true; fileOpen = true;
metadata["name"] = ui->txt_fileName->text(); metadata["name"] = ui->txt_fileName->text();
metadata["plot"] = true; metadata["plot"] = ui->chk_plot->isChecked();
param["action"] = "open"; param["action"] = "open";
param["metadata"] = metadata; param["metadata"] = metadata;
ui->btn_record->setEnabled(false); ui->btn_record->setEnabled(false);
ui->btn_realtime->setEnabled(false); ui->btn_realtime->setEnabled(false);
ui->btn_home->setEnabled(false);
ui->btn_open->setText("Close"); ui->btn_open->setText("Close");
ui->txt_fileName->setEnabled(false); ui->txt_fileName->setEnabled(false);
} else { } else {
@@ -262,6 +281,7 @@ void RoboGlue_GUI::on_btn_open_clicked() {
param["action"] = "close"; param["action"] = "close";
ui->btn_record->setEnabled(true); ui->btn_record->setEnabled(true);
ui->btn_realtime->setEnabled(true); ui->btn_realtime->setEnabled(true);
ui->btn_home->setEnabled(true);
ui->btn_open->setText("Open"); ui->btn_open->setText("Open");
ui->txt_fileName->setEnabled(true); ui->txt_fileName->setEnabled(true);
} }
@@ -295,6 +315,40 @@ void RoboGlue_GUI::on_btn_realtime_clicked() {
emit m->commonStatusChange(); emit m->commonStatusChange();
emit sendROScommand("REALTIME", param); emit sendROScommand("REALTIME", param);
} }
void RoboGlue_GUI::on_btn_home_clicked() {
QVariantMap param;
modlog->debug("robotHome");
param["action"] = "start";
param["execute"] = ui->chk_execute->isChecked();
emit m->commonStatusChange();
emit sendROScommand("HOME", param);
}
void RoboGlue_GUI::on_btn_setFrame_clicked() {
QVariantMap param, frm;
QList<QString> tempPos, TempOr;
modlog->debug("setFrame");
param["action"]="set";
param["framename"]=ui->txt_frameName->text();
for(auto tp : ui->txt_framePos->text().split(",")){
frm[tp.split(":").first()]=tp.split(":").last().replace(" ", "").toDouble();
}
for(auto tp : ui->txt_frameOr->text().split(",")){
frm[tp.split(":").first()]=tp.split(":").last().replace(" ", "").toDouble();
}
param["frame"]=frm;
emit m->commonStatusChange();
emit sendROScommand("SETFRAME", param);
}
void RoboGlue_GUI::on_btn_stopRos_clicked() {
QVariantMap param;
modlog->debug("stopRos");
param["action"]=false;
emit m->commonStatusChange();
emit sendROScommand("QUIT", param);
}
//////////////////////////////////////////////// ////////////////////////////////////////////////
////////END INTERNAL PRIVATE SLOTS////////////// ////////END INTERNAL PRIVATE SLOTS//////////////
//////////////////////////////////////////////// ////////////////////////////////////////////////
@@ -339,5 +393,4 @@ void RoboGlue_GUI::on_newRobotData() {
//////////////////////////////////////////////// ////////////////////////////////////////////////
//////// END EXTERNAL PUBLIC SLOTS ///////////// //////// END EXTERNAL PUBLIC SLOTS /////////////
//////////////////////////////////////////////// ////////////////////////////////////////////////
///

View File

@@ -39,6 +39,7 @@
* 20190322 - Modifica dei nomi segnali tra questo modulo e com. * 20190322 - Modifica dei nomi segnali tra questo modulo e com.
* 20190402 - Aggiunte due spinbox per il settaggio di delta tempo e delta spazio da salvare nel * 20190402 - Aggiunte due spinbox per il settaggio di delta tempo e delta spazio da salvare nel
* file dei metadati per la pianificazione dei persorsi salvati * file dei metadati per la pianificazione dei persorsi salvati
* 20191023 - Spostati i commenti in GIT
*/ */
#include <QMainWindow> #include <QMainWindow>
@@ -91,9 +92,13 @@ private slots:
void on_btn_record_clicked(); void on_btn_record_clicked();
void on_btn_play_clicked(); void on_btn_play_clicked();
void on_btn_realtime_clicked(); void on_btn_realtime_clicked();
void on_btn_home_clicked();
void on_btn_open_clicked(); void on_btn_open_clicked();
void on_btn_setFrame_clicked();
void on_btn_stopRos_clicked();
signals: signals:
void robotConnect(QString, uint port, uchar retry); void robotConnect(QString, uint port, uchar retry);
void robotDisconnect(); void robotDisconnect();

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>945</width> <width>1018</width>
<height>750</height> <height>826</height>
</rect> </rect>
</property> </property>
<property name="mouseTracking"> <property name="mouseTracking">
@@ -17,7 +17,7 @@
<string>MainWindow</string> <string>MainWindow</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
<widget class="QTabWidget" name="tab_mainWindow"> <widget class="QTabWidget" name="tab_mainWindow">
<property name="currentIndex"> <property name="currentIndex">
@@ -438,10 +438,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -457,10 +457,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -476,10 +476,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -498,10 +498,10 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -517,10 +517,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -536,10 +536,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -588,10 +588,10 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -607,10 +607,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -626,10 +626,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -645,10 +645,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -664,10 +664,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -683,10 +683,10 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set> <set>Qt::TextSelectableByMouse</set>
@@ -920,7 +920,7 @@
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item alignment="Qt::AlignHCenter">
<widget class="QFrame" name="frm_move"> <widget class="QFrame" name="frm_move">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@@ -976,21 +976,30 @@
<item> <item>
<widget class="QLabel" name="lbl_posX"> <widget class="QLabel" name="lbl_posX">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="lbl_posY"> <widget class="QLabel" name="lbl_posY">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="lbl_posZ"> <widget class="QLabel" name="lbl_posZ">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
@@ -1037,7 +1046,21 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="txt_fileName"/> <widget class="QLineEdit" name="txt_fileName">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chk_plot">
<property name="text">
<string>Plot</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@@ -1050,36 +1073,9 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="btn_realtime">
<property name="text">
<string>RealTime</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>MODE:</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0"> <item row="0" column="1">
<widget class="QRadioButton" name="rad_pos"> <widget class="QRadioButton" name="rad_pos">
<property name="text"> <property name="text">
<string>POS</string> <string>POS</string>
@@ -1092,7 +1088,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="1">
<widget class="QRadioButton" name="rad_vel"> <widget class="QRadioButton" name="rad_vel">
<property name="text"> <property name="text">
<string>VEL</string> <string>VEL</string>
@@ -1102,6 +1098,59 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="0" column="0" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPushButton" name="btn_realtime">
<property name="text">
<string>RealTime</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>MODE:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="btn_home">
<property name="text">
<string>GoHOME</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chk_execute">
<property name="text">
<string>Execute</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@@ -1184,34 +1233,18 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="Line" name="line_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="2">
<widget class="QLabel" name="label_18">
<property name="text">
<string>dS</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_19"> <widget class="QLabel" name="label_19">
<property name="text"> <property name="text">
<string>dT</string> <string>dT</string>
@@ -1221,7 +1254,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="spn_ds"> <widget class="QDoubleSpinBox" name="spn_ds">
<property name="maximum"> <property name="maximum">
<double>100.000000000000000</double> <double>100.000000000000000</double>
@@ -1237,7 +1270,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="2">
<widget class="QDoubleSpinBox" name="spn_dt"> <widget class="QDoubleSpinBox" name="spn_dt">
<property name="maximum"> <property name="maximum">
<double>240.000000000000000</double> <double>240.000000000000000</double>
@@ -1250,10 +1283,108 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLabel" name="label_18">
<property name="text">
<string>dS</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Point Record Distance/Time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="Line" name="line_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="2">
<widget class="QLineEdit" name="txt_framePos">
<property name="inputMask">
<string>\x:000,y:000,z:000 </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Orientation</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Position</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="txt_frameOr">
<property name="inputMask">
<string>r\x:#00.0,ry:#00.0,rz:#00.0 </string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="btn_setFrame">
<property name="text">
<string>SetFrame</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_24">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="txt_frameName"/>
</item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
@@ -1283,6 +1414,52 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>ROS Status</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_relay">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_follower">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_recorder">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_broadcaster">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_stopRos">
<property name="text">
<string>Stop_ROS</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
@@ -1290,7 +1467,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>945</width> <width>1018</width>
<height>22</height> <height>22</height>
</rect> </rect>
</property> </property>
@@ -1312,12 +1489,12 @@
<resources/> <resources/>
<connections/> <connections/>
<buttongroups> <buttongroups>
<buttongroup name="grp_mod"/>
<buttongroup name="grp_hilo"/> <buttongroup name="grp_hilo"/>
<buttongroup name="gpr_lock"> <buttongroup name="gpr_lock">
<property name="exclusive"> <property name="exclusive">
<bool>false</bool> <bool>false</bool>
</property> </property>
</buttongroup> </buttongroup>
<buttongroup name="grp_mod"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@@ -5,7 +5,6 @@ RoboGlue_INIT::RoboGlue_INIT(QWidget *parent, const char*) : QMainWindow(parent)
//////// SETUP LOGGER ////////// //////// SETUP LOGGER //////////
inilog = spdlog::stdout_logger_mt("RoboGlue_inilog"); inilog = spdlog::stdout_logger_mt("RoboGlue_inilog");
inilog->info("INIT Started");
//////// SETUP USER INTERFACE /////// //////// SETUP USER INTERFACE ///////
ui = new Ui::RoboGlue_INIT; ui = new Ui::RoboGlue_INIT;
@@ -38,6 +37,9 @@ RoboGlue_INIT::RoboGlue_INIT(QWidget *parent, const char*) : QMainWindow(parent)
//////// CONNECT SIGNALS & SLOTS /////// //////// CONNECT SIGNALS & SLOTS ///////
connect(this, SIGNAL(destroyed()), this, SLOT(deleteLater()), Qt::ConnectionType::QueuedConnection); connect(this, SIGNAL(destroyed()), this, SLOT(deleteLater()), Qt::ConnectionType::QueuedConnection);
//////// SIGNAL STARTED ////////////////
inilog->info("INIT Started");
} }
RoboGlue_INIT::~RoboGlue_INIT() { RoboGlue_INIT::~RoboGlue_INIT() {

View File

@@ -51,7 +51,7 @@ bool UR_CLinterface::connect(const char* ip, uint16_t port) {
try { try {
rsocket->connect( rsocket->connect(
tcp::endpoint(boost::asio::ip::address::from_string(ip), port)); tcp::endpoint(boost::asio::ip::address::from_string(ip), port));
if ((bool) rsocket->is_open()) { if (static_cast<bool>(rsocket->is_open())) {
log->info("Connected to {0} on port {1}", ip, port); log->info("Connected to {0} on port {1}", ip, port);
return true; return true;
} }
@@ -75,7 +75,7 @@ void UR_CLinterface::sendCommand(std::string command) {
char* dataOut=NULL; char* dataOut=NULL;
if (rsocket->is_open()){ if (rsocket->is_open()){
command = command + '\n'; command = command + '\n';
dataOut = (char*)malloc(command.size()); dataOut = static_cast<char*>(malloc(command.size()));
strncpy(dataOut, command.c_str(), command.size()); strncpy(dataOut, command.c_str(), command.size());
log->debug("Sending: {}, s:{}",dataOut,command.size()); log->debug("Sending: {}, s:{}",dataOut,command.size());
boost::asio::write(*rsocket, boost::asio::buffer(dataOut, command.size()), error); boost::asio::write(*rsocket, boost::asio::buffer(dataOut, command.size()), error);
@@ -106,7 +106,7 @@ void UR_CLinterface::parseData(void){
subP = new versionSub(lastData, &clientData); subP = new versionSub(lastData, &clientData);
subP->parse(); subP->parse();
firstMessage=false; firstMessage=false;
long t=(long)clientData.versonMessage.timestamp; long t=static_cast<long>(clientData.versonMessage.timestamp);
std::string timestr=std::string(asctime(gmtime(&t))); std::string timestr=std::string(asctime(gmtime(&t)));
timestr.pop_back(); timestr.pop_back();
log->info("Connection Time: {}", timestr); log->info("Connection Time: {}", timestr);
@@ -185,7 +185,7 @@ void UR_CLinterface::parseData(void){
subP = new toolModeSub(&lastData[currIndex], &clientData); subP = new toolModeSub(&lastData[currIndex], &clientData);
break; break;
case SAFETY_DATA: case SAFETY_DATA:
//not yet implemented //TODO: not yet implemented
break; break;
default: default:
log->error("Unknown Subpackage: {}", subPackageType); log->error("Unknown Subpackage: {}", subPackageType);
@@ -194,7 +194,7 @@ void UR_CLinterface::parseData(void){
if (subP != NULL) subP->parse(); if (subP != NULL) subP->parse();
currIndex+=subPackageSize; currIndex+=subPackageSize;
} catch (long sizediff){ } catch (long sizediff){
log->error("Package Length Mismatch: {}",sizediff); log->error("Package Length Mismatch: type_{:d}, diff_{:d}",subPackageType,sizediff);
currIndex+=subPackageSize; currIndex+=subPackageSize;
} }
} }
@@ -225,7 +225,7 @@ void UR_CLinterface::readData(void) {
// all number are represented in network byte order, conversion required // all number are represented in network byte order, conversion required
packlen = ntohl(packlen); packlen = ntohl(packlen);
// allocate memory for incoming package // allocate memory for incoming package
lastData = (unsigned char*)malloc(packlen); lastData = static_cast<unsigned char*>(malloc(packlen));
// blocking read of exactly packlen bytes // blocking read of exactly packlen bytes
readata += boost::asio::read(*rsocket, receive_buffer,boost::asio::transfer_exactly(packlen), error); readata += boost::asio::read(*rsocket, receive_buffer,boost::asio::transfer_exactly(packlen), error);
//retreive all data from buffer //retreive all data from buffer

View File

@@ -366,6 +366,7 @@ namespace subpackage {
v->feedriveButtonPressed = this->getUChar(&dataIn); v->feedriveButtonPressed = this->getUChar(&dataIn);
v->feedriveButtonEnabled = this->getUChar(&dataIn); v->feedriveButtonEnabled = this->getUChar(&dataIn);
v->ioEnableFeedrive = this->getUChar(&dataIn); v->ioEnableFeedrive = this->getUChar(&dataIn);
v->foo = this->getUChar(&dataIn);
// check if read data is aligned with package size // check if read data is aligned with package size
if (dataIn-begin != size) throw dataIn-begin-size; if (dataIn-begin != size) throw dataIn-begin-size;

View File

@@ -40,7 +40,7 @@ namespace subpackage {
robotModeSub(unsigned char* din, clientData_t* dout) { robotModeSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~robotModeSub(); virtual ~robotModeSub();
uint32_t parse(); uint32_t parse();
@@ -51,7 +51,7 @@ namespace subpackage {
jointDataSub(unsigned char* din, clientData_t* dout) { jointDataSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~jointDataSub(); virtual ~jointDataSub();
uint32_t parse(); uint32_t parse();
@@ -62,7 +62,7 @@ namespace subpackage {
cartesianInfoSub(unsigned char* din, clientData_t* dout) { cartesianInfoSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~cartesianInfoSub(); virtual ~cartesianInfoSub();
uint32_t parse(); uint32_t parse();
@@ -73,7 +73,7 @@ namespace subpackage {
masterBoardSub(unsigned char* din, clientData_t* dout) { masterBoardSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~masterBoardSub(); virtual ~masterBoardSub();
uint32_t parse(); uint32_t parse();
@@ -84,7 +84,7 @@ namespace subpackage {
toolDataSub(unsigned char* din, clientData_t* dout) { toolDataSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~toolDataSub(); virtual ~toolDataSub();
uint32_t parse(); uint32_t parse();
@@ -95,7 +95,7 @@ namespace subpackage {
kineInfoSub(unsigned char* din, clientData_t* dout) { kineInfoSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~kineInfoSub(); virtual ~kineInfoSub();
uint32_t parse(); uint32_t parse();
@@ -106,7 +106,7 @@ namespace subpackage {
configurationSub(unsigned char* din, clientData_t* dout) { configurationSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~configurationSub(); virtual ~configurationSub();
uint32_t parse(); uint32_t parse();
@@ -117,7 +117,7 @@ namespace subpackage {
forceModeSub(unsigned char* din, clientData_t* dout) { forceModeSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~forceModeSub(); virtual ~forceModeSub();
uint32_t parse(); uint32_t parse();
@@ -128,7 +128,7 @@ namespace subpackage {
additionalInfoSub(unsigned char* din, clientData_t* dout) { additionalInfoSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~additionalInfoSub(); virtual ~additionalInfoSub();
uint32_t parse(); uint32_t parse();
@@ -139,7 +139,7 @@ namespace subpackage {
calibrationSub(unsigned char* din, clientData_t* dout) { calibrationSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~calibrationSub(); virtual ~calibrationSub();
uint32_t parse(); uint32_t parse();
@@ -150,7 +150,7 @@ namespace subpackage {
toolComSub(unsigned char* din, clientData_t* dout) { toolComSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~toolComSub(); virtual ~toolComSub();
uint32_t parse(); uint32_t parse();
@@ -161,7 +161,7 @@ namespace subpackage {
toolModeSub(unsigned char* din, clientData_t* dout) { toolModeSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; dataOut=dout;
}; }
virtual ~toolModeSub(); virtual ~toolModeSub();
uint32_t parse(); uint32_t parse();
@@ -171,7 +171,8 @@ namespace subpackage {
public: public:
versionSub(unsigned char* din, clientData_t* dout) { versionSub(unsigned char* din, clientData_t* dout) {
dataIn=din; dataIn=din;
dataOut=dout; }; dataOut=dout;
}
virtual ~versionSub(); virtual ~versionSub();
uint32_t parse(); uint32_t parse();

View File

@@ -273,6 +273,7 @@ typedef struct {
unsigned char feedriveButtonPressed; unsigned char feedriveButtonPressed;
unsigned char feedriveButtonEnabled; unsigned char feedriveButtonEnabled;
unsigned char ioEnableFeedrive; unsigned char ioEnableFeedrive;
unsigned char foo;
} additionalInfo_t; } additionalInfo_t;
typedef struct { typedef struct {

View File

@@ -8,7 +8,7 @@ automain=false
autotrack=false autotrack=false
[robot] [robot]
connection\autoconnect=false connection\autoconnect=true
connection\robotip=10.0.0.5 connection\robotip=10.0.0.5
connection\robotport=30002 connection\robotport=30002
connection\robotretry=5 connection\robotretry=5
@@ -40,3 +40,18 @@ kine\dhtable\size=6
kine\maxreach=@Variant(\0\0\0\x87?\x99\x99\x9a) kine\maxreach=@Variant(\0\0\0\x87?\x99\x99\x9a)
kine\prefix=0 kine\prefix=0
kine\suffix=0 kine\suffix=0
[ros]
deadTime=10
ros_nodes\mqtt_publishers\commands=roboglue_com/com2ros/commands
ros_nodes\mqtt_publishers\coordinates=roboglue_com/com2ros/coordinates
ros_nodes\mqtt_publishers\interface=roboglue_com/com2ros/interface
ros_nodes\mqtt_publishers\state=roboglue_com/com2ros/state
ros_nodes\mqtt_subscribers\commands=roboglue_com/ros2com/commands
ros_nodes\mqtt_subscribers\coordinates=roboglue_com/ros2com/coordinates
ros_nodes\mqtt_subscribers\interface=roboglue_com/ros2com/interface
ros_nodes\mqtt_subscribers\state=roboglue_com/ros2com/state
ros_nodes\node_names\broadcaster=roboglue_ros_broadcaster
ros_nodes\node_names\follower=roboglue_ros_follower
ros_nodes\node_names\recorder=roboglue_ros_recorder
ros_nodes\node_names\relay=roboglue_ros_relay

View File

@@ -2,14 +2,34 @@
RoboGlue_SHARED::RoboGlue_SHARED(QSettings *set){ RoboGlue_SHARED::RoboGlue_SHARED(QSettings *set){
settings=set; settings=set;
//FIXME: inserire la lettura di quesste informazioni da un file
robotVariables.insert(std::pair<std::string, int>("RDY",1)); robotVariables.insert(std::pair<std::string, int>("RDY",1));
statusTimer = new QTimer(this);
connect(statusTimer, SIGNAL(timeout()), this, SLOT(on_statusTimer()));
statusTimer->start(static_cast<int>(comSettings.deadTime*1000));
}
RoboGlue_SHARED::~RoboGlue_SHARED(){
statusTimer->stop();
delete statusTimer;
}
void RoboGlue_SHARED::on_statusTimer(void){
double curTime = static_cast<double>(std::time(NULL));
commonStatus.relayRunning = (commonStatus.relayTime = fabs(commonStatus.relayLast - curTime)) < comSettings.deadTime;
commonStatus.followerRunning = (commonStatus.followerTime = fabs(commonStatus.followerLast - curTime)) < comSettings.deadTime;
commonStatus.recorderRunning = (commonStatus.recorderTime = fabs(commonStatus.recorderLast - curTime)) < comSettings.deadTime;
commonStatus.broadcasterRunning = (commonStatus.broadcasterTime = fabs(commonStatus.broadcasterLast - curTime)) < comSettings.deadTime;
emit this->commonStatusChange();
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
/////////////////////// RESTORE FUNCTIONS ///////////////////// /////////////////////// RESTORE FUNCTIONS /////////////////////
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
void RoboGlue_SHARED::restoreCommonSettings(){
settings->beginGroup("common");
settings->endGroup();
}
void RoboGlue_SHARED::restoreInitSettings(){ void RoboGlue_SHARED::restoreInitSettings(){
settings->beginGroup("init"); settings->beginGroup("init");
initSettings.size=settings->value("size").toSize(); initSettings.size=settings->value("size").toSize();
@@ -50,6 +70,29 @@ void RoboGlue_SHARED::restoreComSettings() {
// TODO something // TODO something
settings->endGroup(); settings->endGroup();
settings->endGroup(); settings->endGroup();
settings->beginGroup("ros");
comSettings.deadTime = settings->value("deadTime").toDouble();
settings->beginGroup("ros_nodes");
settings->beginGroup("mqtt_publishers");
comSettings.pubMap["commands"] = settings->value("commands").toString().toStdString();
comSettings.pubMap["coordinates"] = settings->value("coordinates").toString().toStdString();
comSettings.pubMap["state"] = settings->value("state").toString().toStdString();
comSettings.pubMap["interface"] = settings->value("interface").toString().toStdString();
settings->endGroup();
settings->beginGroup("mqtt_subscribers");
comSettings.subMap["commands"] = settings->value("commands").toString().toStdString();
comSettings.subMap["coordinates"] = settings->value("coordinates").toString().toStdString();
comSettings.subMap["state"] = settings->value("state").toString().toStdString();
comSettings.subMap["interface"] = settings->value("interface").toString().toStdString();
settings->endGroup();
settings->beginGroup("node_names");
comSettings.nodeNames["relay"] = settings->value("relay").toString().toStdString();
comSettings.nodeNames["follower"] = settings->value("follower").toString().toStdString();
comSettings.nodeNames["recorder"] = settings->value("recorder").toString().toStdString();
comSettings.nodeNames["broadcaster"] = settings->value("broadcaster").toString().toStdString();
settings->endGroup();
settings->endGroup();
settings->endGroup();
} }
void RoboGlue_SHARED::restoreGuiSettings() { void RoboGlue_SHARED::restoreGuiSettings() {
@@ -74,7 +117,6 @@ void RoboGlue_SHARED::restoreTrackSettings() {
void RoboGlue_SHARED::saveCommonSettings(){ void RoboGlue_SHARED::saveCommonSettings(){
settings->beginGroup("common"); settings->beginGroup("common");
settings->endGroup(); settings->endGroup();
} }
void RoboGlue_SHARED::saveInitSettings() { void RoboGlue_SHARED::saveInitSettings() {
@@ -88,11 +130,34 @@ void RoboGlue_SHARED::saveInitSettings() {
void RoboGlue_SHARED::saveComSettings() { void RoboGlue_SHARED::saveComSettings() {
settings->beginGroup("robot"); settings->beginGroup("robot");
settings->beginGroup("kine"); settings->beginGroup("kine");
settings->setValue("maxreach", comSettings.kine.maxReach); settings->setValue("maxreach", comSettings.kine.maxReach);
settings->setValue("prefix", comSettings.connection.prefix); settings->setValue("prefix", comSettings.connection.prefix);
settings->setValue("suffix", comSettings.connection.suffix); settings->setValue("suffix", comSettings.connection.suffix);
settings->endGroup();
settings->endGroup(); settings->endGroup();
settings->beginGroup("ros");
settings->setValue("deadTime", comSettings.deadTime);
settings->beginGroup("ros_nodes");
settings->beginGroup("mqtt_publishers");
settings->setValue("commands", QString().fromStdString(comSettings.pubMap.find("commands")->second));
settings->setValue("coordinates", QString().fromStdString(comSettings.pubMap.find("coordinates")->second));
settings->setValue("state", QString().fromStdString(comSettings.pubMap.find("state")->second));
settings->setValue("interface", QString().fromStdString(comSettings.pubMap.find("interface")->second));
settings->endGroup();
settings->beginGroup("mqtt_subscribers");
settings->setValue("commands", QString().fromStdString(comSettings.subMap.find("commands")->second));
settings->setValue("coordinates", QString().fromStdString(comSettings.subMap.find("coordinates")->second));
settings->setValue("state", QString().fromStdString(comSettings.subMap.find("state")->second));
settings->setValue("interface", QString().fromStdString(comSettings.subMap.find("interface")->second));
settings->endGroup();
settings->beginGroup("node_names");
settings->setValue("relay", QString().fromStdString(comSettings.nodeNames.find("relay")->second));
settings->setValue("follower", QString().fromStdString(comSettings.nodeNames.find("follower")->second));
settings->setValue("recorder", QString().fromStdString(comSettings.nodeNames.find("recorder")->second));
settings->setValue("broadcaster", QString().fromStdString(comSettings.nodeNames.find("broadcaster")->second));
settings->endGroup();
settings->endGroup();
settings->endGroup(); settings->endGroup();
} }

View File

@@ -21,16 +21,19 @@
* QUESTA COSA VA GIÀ CAMBIATA PERCHÈ È TROPPO CONFUSIONARIA!! * QUESTA COSA VA GIÀ CAMBIATA PERCHÈ È TROPPO CONFUSIONARIA!!
* 20190124 - Implementati tutti i metodi che salvano e ripristinano le configurazioni. * 20190124 - Implementati tutti i metodi che salvano e ripristinano le configurazioni.
* 20190311 - Aggiunta la struttura che tiene gli stati che devono rimanere comuni ai moduli. * 20190311 - Aggiunta la struttura che tiene gli stati che devono rimanere comuni ai moduli.
* * 20191030 - Documentazione spostata in GIT
*/ */
#include <QMutex> #include <QMutex>
#include <QSettings> #include <QSettings>
#include <QPoint> #include <QPoint>
#include <QSize> #include <QSize>
#include <QTimer>
#include <stdexcept> #include <stdexcept>
#include <ctime>
#include <libJson/json.hpp> #include <libJson/json.hpp>
#include <libURcom/URCLinterface.h> #include <libURcom/URCLinterface.h>
#include <boost/algorithm/string.hpp>
using namespace nlohmann; using namespace nlohmann;
@@ -39,7 +42,9 @@ class RoboGlue_SHARED : public QObject{
public: public:
RoboGlue_SHARED(QSettings *set); RoboGlue_SHARED(QSettings *set);
virtual ~RoboGlue_SHARED();
QMutex mutex; QMutex mutex;
QTimer* statusTimer;
//////////// COMMON MODULES STATUS /////////////// //////////// COMMON MODULES STATUS ///////////////
struct { struct {
@@ -47,6 +52,20 @@ public:
bool isPlaying = false; bool isPlaying = false;
bool isRealtime = false; bool isRealtime = false;
bool isFileOpen = false; bool isFileOpen = false;
// ROS node status
bool relayRunning = false;
bool followerRunning = false;
bool recorderRunning = false;
bool broadcasterRunning = false;
// ROS node last seen
double relayLast = static_cast<double>(time(NULL));
double followerLast = static_cast<double>(time(NULL));
double recorderLast = static_cast<double>(time(NULL));
double broadcasterLast = static_cast<double>(time(NULL));
double relayTime = static_cast<double>(time(NULL));
double followerTime = static_cast<double>(time(NULL));
double recorderTime = static_cast<double>(time(NULL));
double broadcasterTime = static_cast<double>(time(NULL));
} commonStatus; } commonStatus;
/////////// PERMANENT SETTINGS VARIABLES ///////// /////////// PERMANENT SETTINGS VARIABLES /////////
@@ -66,7 +85,7 @@ public:
struct { struct {
struct { struct {
std::string robotIp = std::string("192.168.0.31"); std::string robotIp = std::string("localhost");
uint robotPort = 30002; uint robotPort = 30002;
unsigned char retry = 5; unsigned char retry = 5;
bool autoConnect = false; bool autoConnect = false;
@@ -77,19 +96,16 @@ public:
kineDH_t DHtable; kineDH_t DHtable;
float maxReach = 1.2; float maxReach = 1.2;
} kine; } kine;
std::vector<std::string> subList { double deadTime = 1.0; //default value
{"roboglue_com/ros2com/commands"}, std::map<std::string, std::string> subMap;
{"roboglue_com/ros2com/coordinates"}, std::map<std::string, std::string> pubMap;
{"roboglue_com/ros2com/state"} std::map<std::string, std::string> nodeNames;
};
std::vector<std::string> pubList {
{"roboglue_com/com2ros/commands"},
{"roboglue_com/com2ros/coordinates"},
{"roboglue_com/com2ros/state"}
};
enum { enum {
COMM, COORD, STAT COMM, COORD, STAT
} tList; } tList;
enum {
TYPE, NODE, TS
};
} comSettings; } comSettings;
struct { struct {
@@ -124,6 +140,9 @@ public:
signals: signals:
void commonStatusChange(void); void commonStatusChange(void);
private slots:
void on_statusTimer(void);
}; };
#endif // ROBOGLUE_SHARED_H #endif // ROBOGLUE_SHARED_H