Skip to content

Commit

Permalink
Added docstrings and const qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauch committed Aug 29, 2023
1 parent 0cc60f9 commit 62260b4
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
14 changes: 13 additions & 1 deletion include/ur_client_library/comm/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,13 @@ class IProducer
public:
/*!
* \brief Set-up functionality of the producers.
*
* \param max_num_tries Maximum number of connection attempts before counting the connection as
* failed. Unlimited number of attempts when set to 0.
* \param reconnection_time time in between connection attempts to the server
*/
virtual void setupProducer(size_t max_num_tries = 0, std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
virtual void setupProducer(const size_t max_num_tries = 0,
const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
{
}
/*!
Expand Down Expand Up @@ -287,6 +292,13 @@ class Pipeline
stop();
}

/*!
* \brief Initialize the pipeline. Internally calls setup of producer and consumer.
*
* \param max_num_tries Maximum number of connection attempts before counting the connection as
* failed. Unlimited number of attempts when set to 0.
* \param reconnection_time time in between connection attempts to the server
*/
void init(size_t max_num_tries = 0, std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
{
producer_.setupProducer(max_num_tries, reconnection_time);
Expand Down
7 changes: 6 additions & 1 deletion include/ur_client_library/comm/producer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ class URProducer : public IProducer<T>

/*!
* \brief Triggers the stream to connect to the robot.
*
* \param max_num_tries Maximum number of connection attempts before counting the connection as
* failed. Unlimited number of attempts when set to 0.
* \param reconnection_time time in between connection attempts to the server
*/
void setupProducer(size_t max_num_tries = 0, std::chrono::milliseconds reconnection_time = std::chrono::seconds(10)) override
void setupProducer(const size_t max_num_tries = 0,
const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10)) override
{
stream_.setReconnectionTime(reconnection_time);
timeval tv;
Expand Down
5 changes: 4 additions & 1 deletion include/ur_client_library/comm/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ class URStream : public TCPSocket
/*!
* \brief Connects to the configured socket.
*
* \param max_num_tries Maximum number of connection attempts before counting the connection as
* failed. Unlimited number of attempts when set to 0.
*
* \returns True on success, false if connection could not be established
*/
bool connect(size_t max_num_tries = 0)
bool connect(const size_t max_num_tries = 0)
{
return TCPSocket::setup(host_, port_, max_num_tries);
}
Expand Down
2 changes: 1 addition & 1 deletion include/ur_client_library/comm/tcp_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TCPSocket
*
* \param reconnection_time time in between connection attempts to the server
*/
void setReconnectionTime(std::chrono::milliseconds reconnection_time)
void setReconnectionTime(const std::chrono::milliseconds reconnection_time)
{
reconnection_time_ = reconnection_time;
}
Expand Down
10 changes: 8 additions & 2 deletions include/ur_client_library/rtde/rtde_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ class RTDEClient
* \brief Sets up RTDE communication with the robot. The handshake includes negotiation of the
* used protocol version and setting of input and output recipes.
*
* \param max_num_tries Maximum number of connection attempts before counting the connection as
* failed. Unlimited number of attempts when set to 0.
* \param reconnection_time time in between connection attempts to the server
*
* \returns Success of the handshake
*/
bool init(size_t max_num_tries = 0, std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));
bool init(const size_t max_num_tries = 0,
const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));
/*!
* \brief Triggers the robot to start sending RTDE data packages in the negotiated format.
*
Expand Down Expand Up @@ -228,7 +233,8 @@ class RTDEClient
// the robot is booted.
std::vector<std::string> ensureTimestampIsPresent(const std::vector<std::string>& output_recipe) const;

void setupCommunication(size_t max_num_tries = 0, std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));
void setupCommunication(size_t max_num_tries = 0,
std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));
bool negotiateProtocolVersion(const uint16_t protocol_version);
void queryURControlVersion();
void setupOutputs(const uint16_t protocol_version);
Expand Down
9 changes: 7 additions & 2 deletions include/ur_client_library/ur/dashboard_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ class DashboardClient : public comm::TCPSocket
/*!
* \brief Opens a connection to the dashboard server on the host as specified in the constructor.
*
* \param max_num_tries Maximum number of connection attempts before counting the connection as
* failed. Unlimited number of attempts when set to 0.
* \param reconnection_time time in between connection attempts to the server
*
* \returns True on successful connection, false otherwise.
*/
bool connect(size_t max_num_tries = 0, std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));

bool connect(const size_t max_num_tries = 0,
const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));

/*!
* \brief Makes sure no connection to the dashboard server is held inside the object.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/rtde/rtde_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ RTDEClient::~RTDEClient()
disconnect();
}

bool RTDEClient::init(size_t max_num_tries, std::chrono::milliseconds reconnection_time)
bool RTDEClient::init(const size_t max_num_tries, const std::chrono::milliseconds reconnection_time)
{
if (client_state_ > ClientState::UNINITIALIZED)
{
Expand All @@ -92,7 +92,7 @@ bool RTDEClient::init(size_t max_num_tries, std::chrono::milliseconds reconnecti
throw UrException(ss.str());
}

void RTDEClient::setupCommunication(size_t max_num_tries, std::chrono::milliseconds reconnection_time)
void RTDEClient::setupCommunication(const size_t max_num_tries, const std::chrono::milliseconds reconnection_time)
{
client_state_ = ClientState::INITIALIZING;
// A running pipeline is needed inside setup
Expand Down
2 changes: 1 addition & 1 deletion src/ur/dashboard_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void DashboardClient::rtrim(std::string& str, const std::string& chars)
str.erase(str.find_last_not_of(chars) + 1);
}

bool DashboardClient::connect(size_t max_num_tries, std::chrono::milliseconds reconnection_time)
bool DashboardClient::connect(const size_t max_num_tries, const std::chrono::milliseconds reconnection_time)
{
if (getState() == comm::SocketState::Connected)
{
Expand Down

0 comments on commit 62260b4

Please sign in to comment.