Skip to content

Commit

Permalink
Merge branch 'humble' of https://github.com/robosoft-ai/SMACC2 into h…
Browse files Browse the repository at this point in the history
…umble
  • Loading branch information
pabloinigoblasco committed Sep 11, 2024
2 parents b1cfb1f + 8c0de46 commit a88ed93
Show file tree
Hide file tree
Showing 802 changed files with 5,137 additions and 277,200 deletions.
Empty file modified .clang-format
100644 → 100755
Empty file.
4 changes: 0 additions & 4 deletions .github/SMACC2.humble.repos
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
4 changes: 2 additions & 2 deletions .github/workflows/ci-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install clang-format-12
- name: Install clang-format
run: |
apt update
apt install -y python3-pip clang-format-12 ros-humble-ament-cppcheck
apt install -y python3-pip clang-format ros-humble-ament-cppcheck
git config --global --add safe.directory `pwd`
pip install pre-commit
- name: pre-commit
Expand Down
59 changes: 0 additions & 59 deletions .github/workflows/ci-ros-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ repos:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: clang-format-12
entry: clang-format
language: system
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
args: ['-fallback-style=none', '-i']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class SmaccActionClientBase : public ISmaccActionClient

std::optional<std::shared_future<typename GoalHandle::SharedPtr>> lastRequest_;
// typename GoalHandle::SharedPtr goalHandle_;
std::optional<std::shared_future<typename CancelResponse::SharedPtr>> lastCancelResponse_;

SmaccActionResultSignal onSucceeded_;
SmaccActionResultSignal onAborted_;
Expand Down Expand Up @@ -217,8 +218,7 @@ class SmaccActionClientBase : public ISmaccActionClient

virtual bool cancelGoal() override
{
auto fut = this->client_->async_cancel_all_goals();
fut.wait();
lastCancelResponse_ = this->client_->async_cancel_all_goals();

// if (lastRequest_ && lastRequest_->valid())
// {
Expand Down
50 changes: 50 additions & 0 deletions smacc2_client_library/http_client/CMakeLists.txt
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()
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 RobosoftAI Inc.
// 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.
Expand All @@ -14,14 +14,21 @@

/*****************************************************************************************************************
*
* Authors: Pablo Inigo Blasco, Brett Aldrich
* Authors: Jaycee Lock
*
******************************************************************************************************************/

#include <sm_dance_bot_warehouse_4/sm_dance_bot_warehouse_4.hpp>
#pragma once

int main(int argc, char ** argv)
#include <http_client/cl_http_client.hpp>
#include <http_client/client_behaviors/cb_http_request.hpp>
#include <smacc2/smacc.hpp>

namespace cl_http
{
class CbHttpGetRequest : public CbHttpRequestBase
{
rclcpp::init(argc, argv);
smacc2::run<SmDanceBotWarehouse4>();
}
public:
CbHttpGetRequest() : CbHttpRequestBase(ClHttp::kHttpRequestMethod::GET) {}
};
} // namespace cl_http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 RobosoftAI Inc.
// 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.
Expand All @@ -14,24 +14,21 @@

/*****************************************************************************************************************
*
* Authors: Pablo Inigo Blasco, Brett Aldrich
* Authors: Jaycee Lock
*
******************************************************************************************************************/

#pragma once

#include <http_client/cl_http_client.hpp>
#include <http_client/client_behaviors/cb_http_request.hpp>
#include <smacc2/smacc.hpp>
namespace sm_dancebot_ue

namespace cl_http
{
// STATE DECLARATION
class MsDanceBotRunMode : public smacc2::SmaccState<MsDanceBotRunMode, SmDanceBotUE, StAcquireSensors>
class CbHttpPostRequest : public CbHttpRequestBase
{
public:
using SmaccState::SmaccState;

// TRANSITION TABLE
typedef mpl::list<

Transition<EvGlobalError, MsDanceBotRecoveryMode>

>reactions;
CbHttpPostRequest() : CbHttpRequestBase(ClHttp::kHttpRequestMethod::POST) {}
};
} // namespace sm_dancebot_ue
} // namespace cl_http
Loading

0 comments on commit a88ed93

Please sign in to comment.