1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 10:00:48 +02:00

Clang-format run

This commit is contained in:
Simon Rasmussen
2017-07-09 02:54:49 +02:00
parent 577fcdbf98
commit 3a5fa23f6b
31 changed files with 343 additions and 343 deletions

View File

@@ -1,20 +1,20 @@
#pragma once
#include <array>
#include <sstream>
#include <iomanip>
#include <sstream>
#include "ur_modern_driver/ur/stream.h"
class URCommander
{
private:
URStream& stream_;
URStream &stream_;
protected:
bool write(std::string& s);
bool write(std::string &s);
void formatArray(std::ostringstream &out, std::array<double, 6> &values);
public:
URCommander(URStream& stream) : stream_(stream)
URCommander(URStream &stream) : stream_(stream)
{
}
@@ -22,7 +22,7 @@ public:
virtual bool setDigitalOut(uint8_t pin, bool value) = 0;
virtual bool setAnalogOut(uint8_t pin, double value) = 0;
//shared
// shared
bool uploadProg(std::string &s);
bool stopj(double a = 10.0);
bool setToolVoltage(uint8_t voltage);
@@ -33,7 +33,7 @@ public:
class URCommander_V1_X : public URCommander
{
public:
URCommander_V1_X(URStream& stream) : URCommander(stream)
URCommander_V1_X(URStream &stream) : URCommander(stream)
{
}
@@ -42,11 +42,10 @@ public:
virtual bool setAnalogOut(uint8_t pin, double value);
};
class URCommander_V3_X : public URCommander
{
public:
URCommander_V3_X(URStream& stream) : URCommander(stream)
URCommander_V3_X(URStream &stream) : URCommander(stream)
{
}

View File

@@ -76,12 +76,12 @@ public:
return major_version_ == 3;
}
std::unique_ptr<URCommander> getCommander(URStream &stream)
std::unique_ptr<URCommander> getCommander(URStream& stream)
{
if(major_version_ == 1)
if (major_version_ == 1)
return std::unique_ptr<URCommander>(new URCommander_V1_X(stream));
else
return std::unique_ptr<URCommander>(new URCommander_V3_X(stream));
return std::unique_ptr<URCommander>(new URCommander_V3_X(stream));
}
std::unique_ptr<URParser<StatePacket>> getStateParser()

View File

@@ -1,8 +1,8 @@
#pragma once
#include <inttypes.h>
#include <cstddef>
#include <bitset>
#include <cstddef>
#include "ur_modern_driver/bin_parser.h"
#include "ur_modern_driver/types.h"
#include "ur_modern_driver/ur/state.h"
@@ -42,7 +42,6 @@ public:
virtual bool parseWith(BinParser& bp);
virtual bool consumeWith(URStatePacketConsumer& consumer);
std::bitset<10> digital_input_bits;
std::bitset<10> digital_output_bits;

View File

@@ -35,31 +35,30 @@ public:
// 4KB should be enough to hold any packet received from UR
uint8_t buf[4096];
size_t read = 0;
//expoential backoff reconnects
while(true)
// expoential backoff reconnects
while (true)
{
if(stream_.read(buf, sizeof(buf), read))
if (stream_.read(buf, sizeof(buf), read))
{
//reset sleep amount
// reset sleep amount
timeout_ = std::chrono::seconds(1);
break;
}
if(stream_.closed())
if (stream_.closed())
return false;
LOG_WARN("Failed to read from stream, reconnecting in %ld seconds...", timeout_.count());
std::this_thread::sleep_for(timeout_);
if(stream_.connect())
if (stream_.connect())
continue;
auto next = timeout_ * 2;
if(next <= std::chrono::seconds(120))
if (next <= std::chrono::seconds(120))
timeout_ = next;
}
BinParser bp(buf, read);
return parser_.parse(bp, products);
}

View File

@@ -16,7 +16,7 @@ public:
bool real_robot_enabled;
bool robot_power_on;
bool emergency_stopped;
bool protective_stopped; //AKA security_stopped
bool protective_stopped; // AKA security_stopped
bool program_running;
bool program_paused;
@@ -79,7 +79,6 @@ public:
virtual bool parseWith(BinParser& bp);
virtual bool consumeWith(URStatePacketConsumer& consumer);
robot_mode_V3_X robot_mode;
robot_control_mode_V3_X control_mode;

View File

@@ -2,9 +2,9 @@
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <atomic>
#include <cstdlib>
#include <mutex>
#include <atomic>
#include <string>
#include "ur_modern_driver/tcp_socket.h"
@@ -21,7 +21,6 @@ protected:
}
virtual void setOptions(int socket_fd);
public:
URServer(int port);
~URServer();
@@ -29,5 +28,5 @@ public:
bool bind();
bool accept();
void disconnectClient();
bool write(const uint8_t* buf, size_t buf_len, size_t &written);
bool write(const uint8_t *buf, size_t buf_len, size_t &written);
};

View File

@@ -32,8 +32,12 @@ class URStatePacketConsumer;
class StatePacket
{
public:
StatePacket() {}
virtual ~StatePacket() {}
StatePacket()
{
}
virtual ~StatePacket()
{
}
virtual bool parseWith(BinParser& bp) = 0;
virtual bool consumeWith(URStatePacketConsumer& consumer) = 0;
};

View File

@@ -35,8 +35,8 @@ public:
if (type != message_type::ROBOT_STATE)
{
//quietly ignore the intial version message
if(type != message_type::ROBOT_MESSAGE)
// quietly ignore the intial version message
if (type != message_type::ROBOT_MESSAGE)
{
LOG_WARN("Invalid state message type recieved: %u", static_cast<uint8_t>(type));
}

View File

@@ -2,8 +2,8 @@
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <mutex>
#include <atomic>
#include <mutex>
#include <string>
#include "ur_modern_driver/log.h"
#include "ur_modern_driver/tcp_socket.h"
@@ -16,7 +16,7 @@ private:
std::mutex write_mutex_, read_mutex_;
protected:
virtual bool open(int socket_fd, struct sockaddr *address, size_t address_len)
virtual bool open(int socket_fd, struct sockaddr* address, size_t address_len)
{
return ::connect(socket_fd, address, address_len) == 0;
}
@@ -36,8 +36,11 @@ public:
TCPSocket::close();
}
bool closed() { return getState() == SocketState::Closed; }
bool closed()
{
return getState() == SocketState::Closed;
}
bool read(uint8_t* buf, size_t buf_len, size_t &read);
bool write(const uint8_t* buf, size_t buf_len, size_t &written);
bool read(uint8_t* buf, size_t buf_len, size_t& read);
bool write(const uint8_t* buf, size_t buf_len, size_t& written);
};