05Robot 3.0

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

UR3Intermediator.h
Go to the documentation of this file.
1
7 #ifndef UR3INTERMEDIATOR_H
8 #define UR3INTERMEDIATOR_H
9
10 #pragma once
11 #include "UR3Message.h"
12 #include <QObject>
13 #include <QTcpSocket>
14 #include <QTcpServer>
15 #include <QMutex>
16 #include <QFile>
17 #include <QTextStream>
18 #include <QElapsedTimer>
19 #include <QNetworkInterface>
20
21
28 class UR3Intermediator: public QObject
29 {
30 Q_OBJECT
31
32 public:
39 UR3Intermediator(QString ipAddress = "192.168.0.109", int port = 30002, int ackServerPort = 9090);
40
41
46 bool ConnectToRobot();
51 void DisconnectFromRobot();
52
62 QString MoveJ(QVector<double> Position, bool isBaseCS, double Acceleration= 2.0, double Speed = 4, double blendRadius = 0);
72 QString MoveL(QVector<double> TargetPose,double toolAcceleration=1.2,double toolSpeed=.25,double time=0, double blendRadius=0);
78 QString setTCP(QVector<double> pose);
84 QString robotSleep(float seconds);
91 QString setToolOutput(int output, bool state);
92
99 void addCommandToExecuteList(QString cmd);
100
104 int Port;
108 QString IpAddress;
112 int ackServerPort;
113
114 QString setOutput(int output, bool state);
115 signals:
121 void newPose(QVector<double> x, char flag);
126 void ConnectionAction(QString,bool Result);
130 void DisconnectionAction();
134 void CommandExecutionStart();
138 void CommandFinished();
142 void robotEmergancyStoped();
143
144
145 private:
146 //Fields
147 int current_timestamp; //< Licznik slużący do rysowania koła
148 QElapsedTimer timerrr;
149 bool _running = false;
150 QVector<double> _moveJTargetPos;//< opis pola
151 QVector<double> _moveLTargetPose;
152 QVector<double> _lastJointPos;
153 QVector<double> _lastPolozenie;
154 QVector<double> _lastForceValue;
155 QString SaveFileName; //< Ścieżka do pliku
156 QVector<double> rotationVector;
157
158 UR3Message ActualRobotInfo;
159 char * _data;
160 QByteArray _DataFlow;
161 QTcpSocket* _socket;
162 bool _connected = false;
163
164 QString getAckServerIp(QString UR3IP);
165 QTcpServer* _ackServer;
166 QTcpSocket* _ackServerSocket = NULL;
167 QString _ackServerIP;
168 bool _ackLock = false;
169
170 //Methods
171 void Execute(QString command);
172 void GetRobotData();
173 void GetRobotMessage(char * data, unsigned int &offset, int size);
174 void ReadDataFlow();
175
176 void RealTime(unsigned int &offset);
177
178 void timerEvent(QTimerEvent *event);
179
180 bool CheckIfRunning();
181 UR3Message GetActualUR3State() { return ActualRobotInfo; }
182
183 private slots:
184 void OnSocketNewBytesWritten();
185 void onSlotDisconnect();
186
187 void ackServerSetup();
188 void ackServerNewConnection();
189 void ackServerNewMsg();
190
191 private:
192 QMutex mutex;
193 QVector<QString> cmds;
194 //Macierz *M;
195 };
198 #endif // UR3INTERMEDIATOR_H
UR3Intermediator::addCommandToExecuteList
void addCommandToExecuteList(QString cmd)
main method for sending commands to robot. addCommandToExecuteList adds commands generated by MoveJ...
UR3Intermediator::Port
int Port
Robot TCP/IP interface port. Default 30002.
Definition: UR3Intermediator.h:104
UR3Intermediator::IpAddress
QString IpAddress
Robot TCP/IP interface IP.
Definition: UR3Intermediator.h:108
UR3Intermediator::ConnectionAction
void ConnectionAction(QString, bool Result)
emitted on ConnectToRobot()
UR3Intermediator::robotSleep
QString robotSleep(float seconds)
Generates command string for robot to sleep an amount of time.
UR3Intermediator::setTCP
QString setTCP(QVector< double > pose)
Generates command string for setting Tool Center Point.
UR3Intermediator
Base class for communication with UR robot using TCP/IP interface.
Definition: UR3Intermediator.h:28
UR3Intermediator::UR3Intermediator
UR3Intermediator(QString ipAddress="192.168.0.109", int port=30002, int ackServerPort=9090)
default constructor, initializes class with starting properties
UR3Intermediator::robotEmergancyStoped
void robotEmergancyStoped()
emiited when robot is in emergancy or protective stop state
UR3Intermediator::CommandFinished
void CommandFinished()
emiited on command execution confirmation/acknowledgment reception
UR3Intermediator::newPose
void newPose(QVector< double > x, char flag)
emitted when a new pose/data information has been received from robot
UR3Intermediator::MoveJ
QString MoveJ(QVector< double > Position, bool isBaseCS, double Acceleration=2.0, double Speed=4, double blendRadius=0)
Generates command string for MoveJ command - move in robot joint space.
UR3Intermediator::ackServerPort
int ackServerPort
Port for acknowledgment messages of command execution.
Definition: UR3Intermediator.h:112
UR3Intermediator::DisconnectionAction
void DisconnectionAction()
emitted on robot disconnection
UR3Intermediator::DisconnectFromRobot
void DisconnectFromRobot()
Disconnects from robot.
UR3Intermediator::setToolOutput
QString setToolOutput(int output, bool state)
Generates command string to set tool digital output signal level.
UR3Intermediator::CommandExecutionStart
void CommandExecutionStart()
emmited when new command from command list has been send to robot for execution
UR3Intermediator::MoveL
QString MoveL(QVector< double > TargetPose, double toolAcceleration=1.2, double toolSpeed=.25, double time=0, double blendRadius=0)
Generates command string for MoveL command - linear move in TCP space.
UR3Intermediator::ConnectToRobot
bool ConnectToRobot()
Connects to a robot based on IpAddress and Port. Establishes acknowledgment server on port ackServerP...
UR3Intermediator::setOutput
QString setOutput(int output, bool state)