Compare commits
7 Commits
master
...
9483e265f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 9483e265f3 | |||
| 117cf20765 | |||
| b843b8439e | |||
| b5566594b6 | |||
| a2b5557357 | |||
| 9f0074b534 | |||
| bf0ec30e16 |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.8.2, 2019-07-10T11:42:03. -->
|
||||
<!-- Written by QtCreator 4.8.2, 2019-10-29T10:42:37. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#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
|
||||
cli_=cli;
|
||||
log_=log;
|
||||
mem_= mem;
|
||||
}
|
||||
|
||||
void mqtt_callback::connected(const mqtt::string &cause) {
|
||||
@@ -17,6 +18,17 @@ void mqtt_callback::connection_lost(const mqtt::string &cause) {
|
||||
void mqtt_callback::message_arrived(mqtt::const_message_ptr msg) {
|
||||
log_->debug("Message Arrived: topic->{} - message->{}",
|
||||
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());
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
||||
void mqtt_callback::delivery_complete(mqtt::delivery_token_ptr tok) {
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
#include <mqtt/client.h>
|
||||
#include <mqtt/callback.h>
|
||||
#include <spdlog/logger.h>
|
||||
#include <shared/roboglue_shared.h>
|
||||
|
||||
class mqtt_callback : public virtual mqtt::callback {
|
||||
|
||||
private:
|
||||
RoboGlue_SHARED *mem_;
|
||||
mqtt::async_client *cli_ = nullptr;
|
||||
std::shared_ptr<spdlog::logger> log_;
|
||||
|
||||
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 connection_lost(const mqtt::string &cause) override;
|
||||
|
||||
@@ -5,8 +5,8 @@ RoboGlue_COM::RoboGlue_COM (RoboGlue_SHARED *mem): m(mem) {
|
||||
//////// SETUP LOGGER //////////
|
||||
liblog = spdlog::stdout_logger_mt("URcom_liblog");
|
||||
modlog = spdlog::stdout_logger_mt("RoboGlue_comlog");
|
||||
liblog->set_level(spdlog::level::info);
|
||||
modlog->set_level(spdlog::level::debug);
|
||||
liblog->set_level(spdlog::level::warn);
|
||||
modlog->set_level(spdlog::level::info);
|
||||
|
||||
///////// INITIALIZE TCP SERVER ///////////
|
||||
server = new QTcpServer(this);
|
||||
@@ -16,7 +16,7 @@ RoboGlue_COM::RoboGlue_COM (RoboGlue_SHARED *mem): m(mem) {
|
||||
|
||||
//////// INITIALIZE MQTT CONNECTOR ///////
|
||||
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 /////////////
|
||||
////////////////////////////////////////////////
|
||||
baseMsg = m->commonSettings.baseMessage;
|
||||
@@ -35,9 +35,8 @@ void RoboGlue_COM::run() {
|
||||
client->set_callback(*callback);
|
||||
client->connect()->wait();
|
||||
// subscrbe to mqtt topics
|
||||
std::vector<std::string> subList = m->comSettings.subList;
|
||||
for (uint i=0; i < subList.size(); i++){
|
||||
client->subscribe(subList[i],0);
|
||||
for (auto it=m->comSettings.subMap.begin(); it != m->comSettings.subMap.end(); ++it){
|
||||
client->subscribe(it->second,0);
|
||||
}
|
||||
client->start_consuming();
|
||||
|
||||
@@ -270,7 +269,7 @@ void RoboGlue_COM::timed_sendCoordinates(){
|
||||
baseMsg["value"]["rx"] = sp[3];
|
||||
baseMsg["value"]["ry"] = sp[4];
|
||||
baseMsg["value"]["rz"] = sp[5];
|
||||
MQTTpublish(baseMsg, m->comSettings.pubList[m->comSettings.COORD]);
|
||||
MQTTpublish(baseMsg, m->comSettings.pubMap.find("coordinates")->second);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
@@ -329,7 +328,7 @@ void RoboGlue_COM::on_sendROScommand(QString command, QVariantMap params) {
|
||||
baseMsg["command"] = command.toStdString();
|
||||
QJsonDocument jparam = QJsonDocument(QJsonObject::fromVariantMap(params));
|
||||
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) {
|
||||
@@ -350,41 +349,3 @@ void RoboGlue_COM::on_sendROSstate(QMap<std::string,bool> digital, QMap<std::str
|
||||
////////////////////////////////////////////////
|
||||
//////// 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();
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
* della coda di destinazione.
|
||||
* 20190311 - La pubblicazione dei messaggi di coordinate verso ros deve essere a rateo costante
|
||||
* indipendentemente dalla frequenza di ingresso
|
||||
*/
|
||||
* 20191030 - Spostata la documentazione su GIT
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
|
||||
@@ -196,6 +196,7 @@ void RoboGlue_GUI::on_btn_record_clicked() {
|
||||
param["metadata"] = metadata;
|
||||
ui->btn_play->setEnabled(false);
|
||||
ui->btn_realtime->setEnabled(false);
|
||||
ui->btn_home->setEnabled(false);
|
||||
disableLockAxes();
|
||||
} else {
|
||||
m->commonStatus.isRecording = false;
|
||||
@@ -203,6 +204,7 @@ void RoboGlue_GUI::on_btn_record_clicked() {
|
||||
param["action"]="stop";
|
||||
ui->btn_play->setEnabled(true);
|
||||
ui->btn_realtime->setEnabled(true);
|
||||
ui->btn_home->setEnabled(true);
|
||||
enableLockAxes();
|
||||
}
|
||||
emit m->commonStatusChange();
|
||||
@@ -223,6 +225,7 @@ void RoboGlue_GUI::on_btn_play_clicked() {
|
||||
param["lock"] = getLockAxes();
|
||||
ui->btn_record->setEnabled(false);
|
||||
ui->btn_realtime->setEnabled(false);
|
||||
ui->btn_home->setEnabled(false);
|
||||
ui->btn_play->setText("Stop");
|
||||
ui->txt_fileName->setEnabled(false);
|
||||
disableLockAxes();
|
||||
@@ -232,6 +235,7 @@ void RoboGlue_GUI::on_btn_play_clicked() {
|
||||
param["action"] = "stop";
|
||||
ui->btn_record->setEnabled(true);
|
||||
ui->btn_realtime->setEnabled(true);
|
||||
ui->btn_home->setEnabled(true);
|
||||
ui->btn_play->setText("Play");
|
||||
ui->txt_fileName->setEnabled(true);
|
||||
enableLockAxes();
|
||||
@@ -254,6 +258,7 @@ void RoboGlue_GUI::on_btn_open_clicked() {
|
||||
param["metadata"] = metadata;
|
||||
ui->btn_record->setEnabled(false);
|
||||
ui->btn_realtime->setEnabled(false);
|
||||
ui->btn_home->setEnabled(false);
|
||||
ui->btn_open->setText("Close");
|
||||
ui->txt_fileName->setEnabled(false);
|
||||
} else {
|
||||
@@ -262,6 +267,7 @@ void RoboGlue_GUI::on_btn_open_clicked() {
|
||||
param["action"] = "close";
|
||||
ui->btn_record->setEnabled(true);
|
||||
ui->btn_realtime->setEnabled(true);
|
||||
ui->btn_home->setEnabled(true);
|
||||
ui->btn_open->setText("Open");
|
||||
ui->txt_fileName->setEnabled(true);
|
||||
}
|
||||
@@ -295,6 +301,16 @@ void RoboGlue_GUI::on_btn_realtime_clicked() {
|
||||
emit m->commonStatusChange();
|
||||
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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
////////END INTERNAL PRIVATE SLOTS//////////////
|
||||
////////////////////////////////////////////////
|
||||
@@ -339,5 +355,4 @@ void RoboGlue_GUI::on_newRobotData() {
|
||||
////////////////////////////////////////////////
|
||||
//////// END EXTERNAL PUBLIC SLOTS /////////////
|
||||
////////////////////////////////////////////////
|
||||
|
||||
|
||||
///
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
* 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
|
||||
* file dei metadati per la pianificazione dei persorsi salvati
|
||||
* 20191023 - Spostati i commenti in GIT
|
||||
*/
|
||||
|
||||
#include <QMainWindow>
|
||||
@@ -91,7 +92,7 @@ private slots:
|
||||
void on_btn_record_clicked();
|
||||
void on_btn_play_clicked();
|
||||
void on_btn_realtime_clicked();
|
||||
|
||||
void on_btn_home_clicked();
|
||||
void on_btn_open_clicked();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>945</width>
|
||||
<height>750</height>
|
||||
<width>1108</width>
|
||||
<height>760</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
@@ -17,7 +17,7 @@
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tab_mainWindow">
|
||||
<property name="currentIndex">
|
||||
@@ -438,7 +438,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -457,7 +457,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -476,7 +476,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -498,7 +498,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -517,7 +517,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -536,7 +536,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -588,7 +588,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -607,7 +607,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -626,7 +626,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -645,7 +645,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -664,7 +664,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -683,7 +683,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
@@ -976,21 +976,21 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_posX">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_posY">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_posZ">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -1050,36 +1050,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="rad_pos">
|
||||
<property name="text">
|
||||
<string>POS</string>
|
||||
@@ -1092,7 +1065,7 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="rad_vel">
|
||||
<property name="text">
|
||||
<string>VEL</string>
|
||||
@@ -1102,6 +1075,59 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
<item>
|
||||
@@ -1290,7 +1316,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>945</width>
|
||||
<width>1108</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -1312,8 +1338,8 @@
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="grp_mod"/>
|
||||
<buttongroup name="grp_hilo"/>
|
||||
<buttongroup name="grp_mod"/>
|
||||
<buttongroup name="gpr_lock">
|
||||
<property name="exclusive">
|
||||
<bool>false</bool>
|
||||
|
||||
@@ -51,7 +51,7 @@ bool UR_CLinterface::connect(const char* ip, uint16_t port) {
|
||||
try {
|
||||
rsocket->connect(
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void UR_CLinterface::sendCommand(std::string command) {
|
||||
char* dataOut=NULL;
|
||||
if (rsocket->is_open()){
|
||||
command = command + '\n';
|
||||
dataOut = (char*)malloc(command.size());
|
||||
dataOut = static_cast<char*>(malloc(command.size()));
|
||||
strncpy(dataOut, command.c_str(), command.size());
|
||||
log->debug("Sending: {}, s:{}",dataOut,command.size());
|
||||
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->parse();
|
||||
firstMessage=false;
|
||||
long t=(long)clientData.versonMessage.timestamp;
|
||||
long t=static_cast<long>(clientData.versonMessage.timestamp);
|
||||
std::string timestr=std::string(asctime(gmtime(&t)));
|
||||
timestr.pop_back();
|
||||
log->info("Connection Time: {}", timestr);
|
||||
@@ -185,7 +185,7 @@ void UR_CLinterface::parseData(void){
|
||||
subP = new toolModeSub(&lastData[currIndex], &clientData);
|
||||
break;
|
||||
case SAFETY_DATA:
|
||||
//not yet implemented
|
||||
//TODO: not yet implemented
|
||||
break;
|
||||
default:
|
||||
log->error("Unknown Subpackage: {}", subPackageType);
|
||||
@@ -194,7 +194,7 @@ void UR_CLinterface::parseData(void){
|
||||
if (subP != NULL) subP->parse();
|
||||
currIndex+=subPackageSize;
|
||||
} catch (long sizediff){
|
||||
log->error("Package Length Mismatch: {}",sizediff);
|
||||
log->error("Package Length Mismatch: type_{:d}, diff_{:d}",subPackageType,sizediff);
|
||||
currIndex+=subPackageSize;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void UR_CLinterface::readData(void) {
|
||||
// all number are represented in network byte order, conversion required
|
||||
packlen = ntohl(packlen);
|
||||
// allocate memory for incoming package
|
||||
lastData = (unsigned char*)malloc(packlen);
|
||||
lastData = static_cast<unsigned char*>(malloc(packlen));
|
||||
// blocking read of exactly packlen bytes
|
||||
readata += boost::asio::read(*rsocket, receive_buffer,boost::asio::transfer_exactly(packlen), error);
|
||||
//retreive all data from buffer
|
||||
|
||||
@@ -366,6 +366,7 @@ namespace subpackage {
|
||||
v->feedriveButtonPressed = this->getUChar(&dataIn);
|
||||
v->feedriveButtonEnabled = this->getUChar(&dataIn);
|
||||
v->ioEnableFeedrive = this->getUChar(&dataIn);
|
||||
v->foo = this->getUChar(&dataIn);
|
||||
|
||||
// check if read data is aligned with package size
|
||||
if (dataIn-begin != size) throw dataIn-begin-size;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace subpackage {
|
||||
robotModeSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~robotModeSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -51,7 +51,7 @@ namespace subpackage {
|
||||
jointDataSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~jointDataSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -62,7 +62,7 @@ namespace subpackage {
|
||||
cartesianInfoSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~cartesianInfoSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -73,7 +73,7 @@ namespace subpackage {
|
||||
masterBoardSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~masterBoardSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -84,7 +84,7 @@ namespace subpackage {
|
||||
toolDataSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~toolDataSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -95,7 +95,7 @@ namespace subpackage {
|
||||
kineInfoSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~kineInfoSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -106,7 +106,7 @@ namespace subpackage {
|
||||
configurationSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~configurationSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -117,7 +117,7 @@ namespace subpackage {
|
||||
forceModeSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~forceModeSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -128,7 +128,7 @@ namespace subpackage {
|
||||
additionalInfoSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~additionalInfoSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -139,7 +139,7 @@ namespace subpackage {
|
||||
calibrationSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~calibrationSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -150,7 +150,7 @@ namespace subpackage {
|
||||
toolComSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~toolComSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -161,7 +161,7 @@ namespace subpackage {
|
||||
toolModeSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout;
|
||||
};
|
||||
}
|
||||
virtual ~toolModeSub();
|
||||
|
||||
uint32_t parse();
|
||||
@@ -171,7 +171,8 @@ namespace subpackage {
|
||||
public:
|
||||
versionSub(unsigned char* din, clientData_t* dout) {
|
||||
dataIn=din;
|
||||
dataOut=dout; };
|
||||
dataOut=dout;
|
||||
}
|
||||
virtual ~versionSub();
|
||||
|
||||
uint32_t parse();
|
||||
|
||||
@@ -273,6 +273,7 @@ typedef struct {
|
||||
unsigned char feedriveButtonPressed;
|
||||
unsigned char feedriveButtonEnabled;
|
||||
unsigned char ioEnableFeedrive;
|
||||
unsigned char foo;
|
||||
} additionalInfo_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -8,7 +8,7 @@ automain=false
|
||||
autotrack=false
|
||||
|
||||
[robot]
|
||||
connection\autoconnect=false
|
||||
connection\autoconnect=true
|
||||
connection\robotip=10.0.0.5
|
||||
connection\robotport=30002
|
||||
connection\robotretry=5
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
RoboGlue_SHARED::RoboGlue_SHARED(QSettings *set){
|
||||
settings=set;
|
||||
|
||||
//FIXME: inserire la lettura di quesste informazioni da un file
|
||||
robotVariables.insert(std::pair<std::string, int>("RDY",1));
|
||||
comSettings.subMap["commands"] = "roboglue_com/ros2com/commands";
|
||||
comSettings.subMap["coordinates"] = "roboglue_com/ros2com/coordinates";
|
||||
comSettings.subMap["state"] = "roboglue_com/ros2com/state";
|
||||
comSettings.subMap["interface"] = "roboglue_com/ros2com/interface";
|
||||
|
||||
|
||||
comSettings.pubMap["commands"] = "roboglue_com/com2ros/commands";
|
||||
comSettings.pubMap["coordinates"] = "roboglue_com/com2ros/coordinates";
|
||||
comSettings.pubMap["state"] = "roboglue_com/com2ros/state";
|
||||
comSettings.pubMap["interface"] = "roboglue_com/com2ros/interface";
|
||||
}
|
||||
////////////////////////////////////////////////////////////////
|
||||
/////////////////////// RESTORE FUNCTIONS /////////////////////
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* QUESTA COSA VA GIÀ CAMBIATA PERCHÈ È TROPPO CONFUSIONARIA!!
|
||||
* 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.
|
||||
*
|
||||
* 20191030 - Documentazione spostata in GIT
|
||||
*/
|
||||
|
||||
#include <QMutex>
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
struct {
|
||||
struct {
|
||||
std::string robotIp = std::string("192.168.0.31");
|
||||
std::string robotIp = std::string("localhost");
|
||||
uint robotPort = 30002;
|
||||
unsigned char retry = 5;
|
||||
bool autoConnect = false;
|
||||
@@ -77,16 +77,9 @@ public:
|
||||
kineDH_t DHtable;
|
||||
float maxReach = 1.2;
|
||||
} kine;
|
||||
std::vector<std::string> subList {
|
||||
{"roboglue_com/ros2com/commands"},
|
||||
{"roboglue_com/ros2com/coordinates"},
|
||||
{"roboglue_com/ros2com/state"}
|
||||
};
|
||||
std::vector<std::string> pubList {
|
||||
{"roboglue_com/com2ros/commands"},
|
||||
{"roboglue_com/com2ros/coordinates"},
|
||||
{"roboglue_com/com2ros/state"}
|
||||
};
|
||||
std::map<std::string, std::string> subMap;
|
||||
std::map<std::string, std::string> pubMap;
|
||||
//FIXME: riempire la mappa dinamicamente da un file, eliminare l'assegnazione manuale
|
||||
enum {
|
||||
COMM, COORD, STAT
|
||||
} tList;
|
||||
|
||||
Reference in New Issue
Block a user