Skip to content

Commit 2b1197e

Browse files
committed
Change function name to negotiateProtocolVersion and return only protocol version
1 parent 676797b commit 2b1197e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

include/ur_client_library/rtde/rtde_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class RTDEClient
255255

256256
bool setupCommunication(const size_t max_num_tries = 0,
257257
const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10));
258-
std::pair<bool, uint16_t> setProtocolVersion();
258+
uint16_t negotiateProtocolVersion();
259259
bool queryURControlVersion();
260260
void setTargetFrequency();
261261
bool setupOutputs(const uint16_t protocol_version);

src/rtde/rtde_client.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ bool RTDEClient::setupCommunication(const size_t max_num_tries, const std::chron
146146
}
147147
pipeline_->run();
148148

149-
std::pair<bool, uint16_t> protocol_version = setProtocolVersion();
149+
uint16_t protocol_version = negotiateProtocolVersion();
150150
// Protocol version must be above zero
151-
if (protocol_version.first == false)
151+
if (protocol_version == 0)
152152
{
153153
return false;
154154
}
@@ -161,7 +161,7 @@ bool RTDEClient::setupCommunication(const size_t max_num_tries, const std::chron
161161
setTargetFrequency();
162162
}
163163

164-
is_rtde_comm_setup = is_rtde_comm_setup && setupOutputs(protocol_version.second);
164+
is_rtde_comm_setup = is_rtde_comm_setup && setupOutputs(protocol_version);
165165

166166
is_rtde_comm_setup = is_rtde_comm_setup && isRobotBooted();
167167

@@ -172,7 +172,7 @@ bool RTDEClient::setupCommunication(const size_t max_num_tries, const std::chron
172172
return is_rtde_comm_setup;
173173
}
174174

175-
std::pair<bool, uint16_t> RTDEClient::setProtocolVersion()
175+
uint16_t RTDEClient::negotiateProtocolVersion()
176176
{
177177
uint16_t protocol_version = MAX_RTDE_PROTOCOL_VERSION;
178178
while (protocol_version > 0)
@@ -187,7 +187,7 @@ std::pair<bool, uint16_t> RTDEClient::setProtocolVersion()
187187
if (!stream_.write(buffer, size, written))
188188
{
189189
URCL_LOG_ERROR("Sending protocol version query to robot failed");
190-
return { false, 0 };
190+
return 0;
191191
}
192192

193193
while (num_retries < MAX_REQUEST_RETRIES)
@@ -196,7 +196,7 @@ std::pair<bool, uint16_t> RTDEClient::setProtocolVersion()
196196
if (!pipeline_->getLatestProduct(package, std::chrono::milliseconds(1000)))
197197
{
198198
URCL_LOG_ERROR("failed to get package from RTDE interface");
199-
return { false, 0 };
199+
return 0;
200200
}
201201
if (rtde_interface::RequestProtocolVersion* tmp_version =
202202
dynamic_cast<rtde_interface::RequestProtocolVersion*>(package.get()))
@@ -205,7 +205,7 @@ std::pair<bool, uint16_t> RTDEClient::setProtocolVersion()
205205
{
206206
URCL_LOG_INFO("Negotiated RTDE protocol version to %hu.", protocol_version);
207207
parser_.setProtocolVersion(protocol_version);
208-
return { true, protocol_version };
208+
return protocol_version;
209209
}
210210
break;
211211
}
@@ -224,7 +224,7 @@ std::pair<bool, uint16_t> RTDEClient::setProtocolVersion()
224224
}
225225
URCL_LOG_ERROR("Protocol version for RTDE communication could not be established. Robot didn't accept any of "
226226
"the suggested versions.");
227-
return { false, 0 };
227+
return 0;
228228
}
229229

230230
bool RTDEClient::queryURControlVersion()

0 commit comments

Comments
 (0)