forked from boston-dynamics/spot-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'boston-dynamics:master' into master
- Loading branch information
Showing
27 changed files
with
1,717 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
cpp/bosdyn/client/error_codes/joint_control_stream_error_code.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved. | ||
* | ||
* Downloading, reproducing, distributing or otherwise using the SDK Software | ||
* is subject to the terms and conditions of the Boston Dynamics Software | ||
* Development Kit License (20191101-BDSDK-SL). | ||
*/ | ||
|
||
|
||
#include "bosdyn/client/error_codes/joint_control_stream_error_code.h" | ||
#include "bosdyn/client/error_codes/error_type_condition.h" | ||
#include "bosdyn/client/error_codes/sdk_error_code.h" | ||
#include "bosdyn/common/success_condition.h" | ||
|
||
namespace { // anonymous namespace | ||
|
||
struct JointControlStreamErrorCodeCategory : std::error_category { | ||
const char* name() const noexcept override; | ||
std::string message(int ev) const override; | ||
bool equivalent(int valcode, const std::error_condition& cond) const noexcept override; | ||
}; | ||
|
||
bool JointControlStreamErrorCodeCategory::equivalent( | ||
int valcode, const std::error_condition& cond) const noexcept { | ||
if (cond == SuccessCondition::Success) return (valcode == 0); | ||
if (cond == ErrorTypeCondition::SDKError) return true; | ||
return false; | ||
} | ||
|
||
const char* JointControlStreamErrorCodeCategory::name() const noexcept { | ||
return "JointControlStreamErrorCode"; | ||
} | ||
|
||
std::string JointControlStreamErrorCodeCategory::message(int value) const { | ||
switch (static_cast<JointControlStreamErrorCode>(value)) { | ||
case JointControlStreamErrorCode::Success: | ||
return "Success"; | ||
case JointControlStreamErrorCode::RequestWriterFailed: | ||
return "Getting request writer failed"; | ||
case JointControlStreamErrorCode::ResponseReaderFailed: | ||
return "Getting response reader failed"; | ||
case JointControlStreamErrorCode::StreamingFailed: | ||
return "Streaming for joint control failed"; | ||
} | ||
return "(JointControlStreamErrorCode: unrecognized error)"; | ||
} | ||
|
||
const JointControlStreamErrorCodeCategory JointControlStreamErrorCodeCategory_category{}; | ||
|
||
} // anonymous namespace | ||
|
||
std::error_code make_error_code(JointControlStreamErrorCode value) { | ||
return {static_cast<int>(value), JointControlStreamErrorCodeCategory_category}; | ||
} |
32 changes: 32 additions & 0 deletions
32
cpp/bosdyn/client/error_codes/joint_control_stream_error_code.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved. | ||
* | ||
* Downloading, reproducing, distributing or otherwise using the SDK Software | ||
* is subject to the terms and conditions of the Boston Dynamics Software | ||
* Development Kit License (20191101-BDSDK-SL). | ||
*/ | ||
|
||
|
||
#pragma once | ||
|
||
#include <system_error> | ||
|
||
// Need to be more specific or removed when streaming client is changed to use general form as we | ||
// did in other clients. | ||
enum class JointControlStreamErrorCode { | ||
// Success | ||
Success = 0, | ||
// Getting request_writer failed | ||
RequestWriterFailed = 1, | ||
// Getting response reader failed | ||
ResponseReaderFailed = 2, | ||
// Streaming for joint control failed | ||
StreamingFailed = 3, | ||
}; | ||
|
||
namespace std { | ||
template <> | ||
struct is_error_code_enum<JointControlStreamErrorCode> : true_type {}; | ||
} // namespace std | ||
|
||
std::error_code make_error_code(JointControlStreamErrorCode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
cpp/bosdyn/client/robot_command/robot_command_streaming_client.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved. | ||
* | ||
* Downloading, reproducing, distributing or otherwise using the SDK Software | ||
* is subject to the terms and conditions of the Boston Dynamics Software | ||
* Development Kit License (20191101-BDSDK-SL). | ||
*/ | ||
|
||
|
||
#include "robot_command_streaming_client.h" | ||
|
||
namespace bosdyn { | ||
|
||
namespace client { | ||
|
||
const char* RobotCommandStreamingClient::s_default_service_name = "robot-command-streaming"; | ||
|
||
const char* RobotCommandStreamingClient::s_service_type = "bosdyn.api.RobotCommandStreamingService"; | ||
|
||
JointControlStreamResultType RobotCommandStreamingClient::JointControlStream( | ||
const ::bosdyn::api::JointControlStreamRequest& request) { | ||
if (!m_request_writer) { | ||
m_request_writer = m_stub->JointControlStream(&m_context, &m_response); | ||
if (!m_request_writer) { | ||
return {::bosdyn::common::Status(JointControlStreamErrorCode::RequestWriterFailed), | ||
std::move(m_response)}; | ||
} | ||
} | ||
|
||
if (!m_request_writer->Write(request)) { | ||
return {::bosdyn::common::Status(JointControlStreamErrorCode::StreamingFailed), | ||
std::move(m_response)}; | ||
} | ||
|
||
return {::bosdyn::common::Status(JointControlStreamErrorCode::Success)}; | ||
} | ||
|
||
ServiceClient::QualityOfService RobotCommandStreamingClient::GetQualityOfService() const { | ||
return QualityOfService::NORMAL; | ||
} | ||
|
||
void RobotCommandStreamingClient::SetComms(const std::shared_ptr<grpc::ChannelInterface>& channel) { | ||
m_stub.reset(new ::bosdyn::api::RobotCommandStreamingService::Stub(channel)); | ||
} | ||
|
||
} // namespace client | ||
|
||
} // namespace bosdyn |
Oops, something went wrong.