-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'humble' of https://github.com/robosoft-ai/SMACC2 into h…
…umble
- Loading branch information
Showing
802 changed files
with
5,137 additions
and
277,200 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -1,5 +1 @@ | ||
repositories: | ||
ue_msgs: | ||
type: git | ||
url: https://github.com/rapyuta-robotics/UE_msgs.git | ||
version: devel |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,66 +43,7 @@ jobs: | |
sm_atomic | ||
sm_atomic_performance_test | ||
sm_atomic_subscribers_performance_test | ||
sm_dance_bot | ||
sm_dance_bot_strikes_back | ||
sm_ferrari | ||
sm_three_some | ||
|
||
sr_all_events_go | ||
sr_conditional | ||
sr_event_countdown | ||
|
||
#ament_lint_cpplint: | ||
#name: ament_${{ matrix.linter }} | ||
#runs-on: ubuntu-20.04 | ||
#strategy: | ||
#fail-fast: false | ||
#matrix: | ||
#linter: [cpplint] | ||
#steps: | ||
#- uses: actions/checkout@v1 | ||
#- uses: ros-tooling/[email protected] | ||
#- uses: ros-tooling/[email protected] | ||
#with: | ||
#distribution: galactic | ||
#linter: cpplint | ||
#arguments: "--filter=-whitespace/newline" | ||
#package-name: | ||
#smacc2 | ||
|
||
#keyboard_client | ||
|
||
#backward_global_planner | ||
#backward_local_planner | ||
#forward_global_planner | ||
#forward_local_planner | ||
#nav2z_planners_common | ||
#pure_spinning_local_planner | ||
#undo_path_global_planner | ||
#nav2z_client | ||
|
||
#multirole_sensor_client | ||
#ros_publisher_client | ||
#ros_timer_client | ||
|
||
#eg_conditional_generator | ||
#eg_random_generator | ||
|
||
#smacc2_msgs | ||
|
||
#sm_atomic | ||
#sm_atomic_performance_test | ||
#sm_atomic_subscribers_performance_test | ||
#sm_dance_bot | ||
#sm_dance_bot_strikes_back | ||
#sm_three_some | ||
|
||
#sr_all_events_go | ||
#sr_conditional | ||
#sr_event_countdown | ||
|
||
#smacc_client_library | ||
#smacc_event_generators | ||
#smacc_msgs | ||
#smacc_sm_reference_library | ||
#smacc_state_reactor_library |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(http_client) | ||
|
||
# Default to C++17 | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(smacc2 REQUIRED) | ||
|
||
include_directories( | ||
include | ||
${smacc2_INCLUDE_DIRS} | ||
) | ||
|
||
file(GLOB_RECURSE SRC_FILES src *.cpp) | ||
|
||
add_library(http_session | ||
src/http_client/ssl_http_session.cpp | ||
src/http_client/http_session.cpp | ||
) | ||
|
||
add_library(${PROJECT_NAME} | ||
src/http_client/cl_http_client.cpp | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
http_session | ||
${smacc2_LIBRARIES} | ||
) | ||
ament_target_dependencies(${PROJECT_NAME} smacc2) | ||
ament_export_include_directories(include) | ||
ament_export_libraries(${PROJECT_NAME} http_session) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION include) | ||
|
||
install(TARGETS | ||
${PROJECT_NAME} | ||
http_session | ||
DESTINATION lib/) | ||
|
||
ament_package() |
115 changes: 115 additions & 0 deletions
115
smacc2_client_library/http_client/include/http_client/cl_http_client.hpp
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,115 @@ | ||
// Copyright 2023 RobosoftAI Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/***************************************************************************************************************** | ||
* | ||
* Authors: Jaycee Lock | ||
* | ||
******************************************************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <boost/asio/executor_work_guard.hpp> | ||
#include <boost/asio/strand.hpp> | ||
#include <boost/beast/core.hpp> | ||
#include <boost/beast/http.hpp> | ||
#include <boost/beast/ssl.hpp> | ||
#include <boost/beast/version.hpp> | ||
#include <http_client/http_session.hpp> | ||
#include <http_client/ssl_http_session.hpp> | ||
#include <smacc2/smacc.hpp> | ||
#include <smacc2/smacc_client.hpp> | ||
#include <string> | ||
#include <thread> | ||
|
||
namespace cl_http | ||
{ | ||
class ClHttp : public smacc2::ISmaccClient | ||
{ | ||
class Server | ||
{ | ||
public: | ||
explicit Server(const std::string & server_name) : server_name_{server_name}, ssl_{true} | ||
{ | ||
if (!server_name_.substr(0, 7).compare("http://")) | ||
{ | ||
ssl_ = false; | ||
server_name_.erase(0, 7); | ||
} | ||
else if (!server_name_.substr(0, 8).compare("https://")) | ||
{ | ||
server_name_.erase(0, 8); | ||
ssl_ = true; | ||
} | ||
} | ||
|
||
bool isSSL() const { return ssl_; } | ||
|
||
std::string getPort() const { return ssl_ ? "443" : "80"; } | ||
|
||
std::string getServerName() const { return server_name_; } | ||
|
||
private: | ||
std::string server_name_; | ||
bool ssl_; | ||
}; | ||
|
||
public: | ||
enum class kHttpRequestMethod | ||
{ | ||
GET = static_cast<int>(boost::beast::http::verb::get), | ||
POST = static_cast<int>(boost::beast::http::verb::post), | ||
PUT = static_cast<int>(boost::beast::http::verb::put), | ||
}; | ||
|
||
using TResponse = http_session_base::TResponse; | ||
|
||
template <typename T> | ||
boost::signals2::connection onResponseReceived(void (T::*callback)(const TResponse &), T * object) | ||
{ | ||
return this->getStateMachine()->createSignalConnection(onResponseReceived_, callback, object); | ||
} | ||
|
||
explicit ClHttp(const std::string & server, const int & timeout = 1500); | ||
|
||
virtual ~ClHttp(); | ||
|
||
void onInitialize() override; | ||
|
||
void makeRequest( | ||
const kHttpRequestMethod http_method, const std::string & path = "/", | ||
const std::string & body = "", | ||
const std::unordered_map<std::string, std::string> & headers = {}); | ||
|
||
private: | ||
const int HTTP_VERSION = 11; | ||
|
||
bool initialized_; | ||
bool is_ssl_; | ||
int timeout_; | ||
|
||
Server server_; | ||
|
||
boost::asio::io_context io_context_; | ||
boost::asio::executor_work_guard<decltype(io_context_)::executor_type> worker_guard_; | ||
std::thread tcp_connection_runner_; | ||
|
||
boost::asio::ssl::context ssl_context_; | ||
|
||
smacc2::SmaccSignal<void(const TResponse &)> onResponseReceived_; | ||
|
||
std::function<void(TResponse)> callbackHandler = [&](const TResponse & res) | ||
{ onResponseReceived_(res); }; | ||
}; | ||
} // namespace cl_http |
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
Oops, something went wrong.