fix SEER stop mapping response handling
This commit is contained in:
parent
55c978dbdd
commit
44dc81db28
@ -31,6 +31,9 @@ constexpr std::uint16_t kRobotConfigUploadMap = 4010;
|
||||
constexpr std::uint16_t kRobotConfigDownloadMap = 4011;
|
||||
constexpr std::uint16_t kRobotOtherStartMapping = 6100;
|
||||
constexpr std::uint16_t kRobotOtherStopMapping = 6101;
|
||||
// The controller can emit this asynchronous mapping event on port 19210
|
||||
// while a mapping session is active. It is not the reply to the next command.
|
||||
constexpr std::uint16_t kRobotOtherMappingEventResponse = 17002;
|
||||
constexpr std::uint16_t kRobotPushConfigReq = 9300;
|
||||
constexpr std::uint16_t kRobotPushConfigRes = 19300;
|
||||
constexpr std::uint16_t kRobotPush = 19301;
|
||||
|
||||
@ -133,25 +133,40 @@ AgvResult SeerRobokitAgv::sendCommandRaw_(
|
||||
"SEER Robokit send command failed: " + systemError());
|
||||
}
|
||||
|
||||
std::uint16_t response_command = 0;
|
||||
std::string payload_text_response;
|
||||
const auto result = receiveFrame_(sock, response_command, payload_text_response);
|
||||
if (!result.ok()) {
|
||||
return result;
|
||||
}
|
||||
const auto expected_response_command = static_cast<std::uint16_t>(
|
||||
command + 10000U);
|
||||
if (response_command != expected_response_command) {
|
||||
return AgvResult::failure(
|
||||
AgvErrorCode::CommandFailed,
|
||||
"SEER Robokit response command mismatch: expected="
|
||||
+ std::to_string(expected_response_command)
|
||||
+ ", actual=" + std::to_string(response_command));
|
||||
constexpr int kMaximumSkippedMappingEvents = 16;
|
||||
for (int attempt = 0; attempt <= kMaximumSkippedMappingEvents; ++attempt) {
|
||||
std::uint16_t response_command = 0;
|
||||
std::string payload_text_response;
|
||||
const auto result = receiveFrame_(
|
||||
sock, response_command, payload_text_response);
|
||||
if (!result.ok()) {
|
||||
return result;
|
||||
}
|
||||
if (response_command == expected_response_command) {
|
||||
if (response_payload) {
|
||||
*response_payload = std::move(payload_text_response);
|
||||
}
|
||||
return AgvResult::success();
|
||||
}
|
||||
|
||||
const bool is_mapping_event =
|
||||
sock == sock_other_
|
||||
&& response_command == kRobotOtherMappingEventResponse;
|
||||
if (!is_mapping_event) {
|
||||
return AgvResult::failure(
|
||||
AgvErrorCode::CommandFailed,
|
||||
"SEER Robokit response command mismatch: expected="
|
||||
+ std::to_string(expected_response_command)
|
||||
+ ", actual=" + std::to_string(response_command));
|
||||
}
|
||||
}
|
||||
if (response_payload) {
|
||||
*response_payload = std::move(payload_text_response);
|
||||
}
|
||||
return AgvResult::success();
|
||||
return AgvResult::failure(
|
||||
AgvErrorCode::Timeout,
|
||||
"SEER Robokit timed out waiting for response command "
|
||||
+ std::to_string(expected_response_command)
|
||||
+ " after repeated asynchronous mapping events");
|
||||
};
|
||||
const auto close_matching_socket_locked = [this, sock]() {
|
||||
if (sock == sock_status_) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user