mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
* Re-added UR script - for custom UR Script execution * Restarting the driver when robot closes the connection on script error. The pipelines work in the way that if the connection is is closed by the control PC, it will not be re-established. This happens for example if you use the URScript topic and upload script that does not compile. The robot will then close the connection, the pipeline will close and any subsequent uploads will fail and noone realises there is a problem. While we could re-establish the connection, I think much better solution is to shutdown the driver in such case. This is much more resilient behaviour as it will clean up any inconsistent driver state. We can utilise "respawn" feature of ROS launch and restart such driver automatically (launch files are updated as part of that change). On top of "production" stability, it allows for much nicer development workflow - you can use URScript topic for development of new scripts and have the driver restart every time you make mistake. Without it, any mistake requires restarting the driver manually.
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#pragma once
|
|
#include <array>
|
|
#include <iomanip>
|
|
#include <sstream>
|
|
#include "ur_modern_driver/ur/stream.h"
|
|
|
|
class URCommander
|
|
{
|
|
private:
|
|
URStream &stream_;
|
|
|
|
protected:
|
|
bool write(const std::string &s);
|
|
void formatArray(std::ostringstream &out, std::array<double, 6> &values);
|
|
|
|
public:
|
|
URCommander(URStream &stream) : stream_(stream)
|
|
{
|
|
}
|
|
|
|
virtual bool speedj(std::array<double, 6> &speeds, double acceleration) = 0;
|
|
virtual bool setDigitalOut(uint8_t pin, bool value) = 0;
|
|
virtual bool setAnalogOut(uint8_t pin, double value) = 0;
|
|
|
|
// shared
|
|
bool uploadProg(const std::string &s);
|
|
bool stopj(double a = 10.0);
|
|
bool setToolVoltage(uint8_t voltage);
|
|
bool setFlag(uint8_t pin, bool value);
|
|
bool setPayload(double value);
|
|
};
|
|
|
|
class URCommander_V1_X : public URCommander
|
|
{
|
|
public:
|
|
URCommander_V1_X(URStream &stream) : URCommander(stream)
|
|
{
|
|
}
|
|
|
|
virtual bool speedj(std::array<double, 6> &speeds, double acceleration);
|
|
virtual bool setDigitalOut(uint8_t pin, bool value);
|
|
virtual bool setAnalogOut(uint8_t pin, double value);
|
|
};
|
|
|
|
class URCommander_V3_X : public URCommander
|
|
{
|
|
public:
|
|
URCommander_V3_X(URStream &stream) : URCommander(stream)
|
|
{
|
|
}
|
|
|
|
virtual bool speedj(std::array<double, 6> &speeds, double acceleration);
|
|
virtual bool setDigitalOut(uint8_t pin, bool value);
|
|
virtual bool setAnalogOut(uint8_t pin, double value);
|
|
};
|