Humble merge

This commit is contained in:
Bastian Hofmann
2022-11-22 15:27:05 +01:00
parent 9c0c189a23
commit 36c235b781
13 changed files with 111 additions and 242 deletions

View File

@@ -1,36 +1,31 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ign_actor_plugin)
set(IGN_PLUGIN_VER 0)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(ignition-cmake2 REQUIRED)
find_package(ignition-gazebo5 REQUIRED)
find_package(ignition-gazebo6 REQUIRED)
find_package(ign_actor_plugin_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
ign_find_package(ignition-plugin1 REQUIRED COMPONENTS register)
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
rosidl_generate_interfaces(${PROJECT_NAME}
"action/Animation.action"
"action/Movement.action"
)
ament_export_dependencies(rosidl_default_runtime)
ament_export_dependencies(ActorPlugin
"rosidl_default_runtime"
"ign_actor_plugin_msgs"
"rclcpp"
"rclcpp_action"
"rclcpp_components")
# Add sources for each plugin to be registered.
add_library(ActorPlugin src/ActorSystem.cpp)
ament_target_dependencies(ActorPlugin rclcpp)
add_library(ActorPlugin SHARED src/ActorSystem.cpp)
ament_target_dependencies(ActorPlugin rclcpp rclcpp_action ign_actor_plugin_msgs)
set_property(TARGET ActorPlugin PROPERTY CXX_STANDARD 17)
rosidl_target_interfaces(ActorPlugin
${PROJECT_NAME} "rosidl_typesupport_cpp")
target_link_libraries(ActorPlugin
ignition-gazebo6::ignition-gazebo6
ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
ignition-gazebo5::ignition-gazebo5
${rclcpp_LIBRARIES}
${rclcpp_action_LIBRARIES}
)

View File

@@ -8,20 +8,15 @@
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>rclcpp_components</depend>
<depend>ign_actor_plugin_messages</depend>
<depend>action_msgs</depend>
<depend>ign_actor_plugin_msgs</depend>
<depend>ignition-cmake2</depend>
<depend>ignition-gazebo5</depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<depend>ignition-gazebo6</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
</export>

View File

@@ -2,27 +2,28 @@
// Created by bastian on 31.08.22.
//
#include <ignition/gazebo/Entity.hh>
#include <ignition/gazebo/Types.hh>
#include <rclcpp_action/create_server.hpp>
#include "ActorSystem.h"
#include <rclcpp_action/server.hpp>
#include "ActorSystem.hpp"
#define AnimationGoalPtr const std::shared_ptr<const ign_actor_plugin::action::Animation::Goal>
#define AnimationServerGoalPtr const std::shared_ptr<rclcpp_action::ServerGoalHandle<ign_actor_plugin::action::Animation>>&
#define MovementGoalPtr const std::shared_ptr<const ign_actor_plugin::action::Movement::Goal>
#define MovementServerGoalPtr const std::shared_ptr<rclcpp_action::ServerGoalHandle<ign_actor_plugin::action::Movement>>&
IGNITION_ADD_PLUGIN(
ActorSystem,
ignition::gazebo::System,
ActorSystem::ISystemPreUpdate,
ActorSystem::ISystemConfigure)
ActorSystem::ISystemConfigure);
ActorSystem::ActorSystem() = default;
ActorSystem::~ActorSystem() = default;
void ActorSystem::PreUpdate(const ignition::gazebo::UpdateInfo &_info, ignition::gazebo::EntityComponentManager &_ecm) {
//_ecm.EachNew<>()
}
// Found too late: https://github.com/AlanSixth/gazebo_ros_action_tutorial/blob/master/src/gazebo_ros_action_tutorial.cc
@@ -30,6 +31,14 @@ void ActorSystem::PreUpdate(const ignition::gazebo::UpdateInfo &_info, ignition:
void ActorSystem::Configure(const ignition::gazebo::Entity &_entity, const std::shared_ptr<const sdf::Element> &_sdf,
ignition::gazebo::EntityComponentManager &_ecm, ignition::gazebo::EventManager &) {
printf("Plugin configuring...\n");
/*auto actorComp = _ecm.Component<Actor>(_entity);
if (!actorComp)
{
gzerr << "Entity [" << _entity << "] is not an actor." << std::endl;
return;
}*/
rclcpp::init(0, {});
@@ -44,12 +53,14 @@ void ActorSystem::Configure(const ignition::gazebo::Entity &_entity, const std::
node = rclcpp::Node::make_shared("moveService", topic);
animationServer = rclcpp_action::create_server<ign_actor_plugin::action::Animation>(
animationServer = rclcpp_action::create_server<ign_actor_plugin_msgs::action::Animation>(
node,
"animation",
[](rclcpp_action::GoalUUID goalUuid,
AnimationGoalPtr &animationGoal) {
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
return rclcpp_action::GoalResponse::REJECT;
},
[](AnimationServerGoalPtr PH1) {
return rclcpp_action::CancelResponse::ACCEPT;
@@ -59,13 +70,15 @@ void ActorSystem::Configure(const ignition::gazebo::Entity &_entity, const std::
}
);
movementServer = rclcpp_action::create_server<ign_actor_plugin::action::Movement>(
movementServer = rclcpp_action::create_server<ign_actor_plugin_msgs::action::Movement>(
node,
"movement",
[](rclcpp_action::GoalUUID goalUuid, MovementGoalPtr &movementGoal ){
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
},
[](MovementServerGoalPtr goalUuid ){
return rclcpp_action::CancelResponse::ACCEPT;
},
[](MovementServerGoalPtr goalUuid ){}

View File

@@ -7,10 +7,18 @@
#include <ignition/gazebo/System.hh>
#include <ignition/plugin/Register.hh>
#include <queue>
#include <rclcpp/node.hpp>
#include "rclcpp/rclcpp.hpp"
#include "ign_actor_plugin/action/animation.hpp"
#include "ign_actor_plugin/action/movement.hpp"
#include <rclcpp/rclcpp.hpp>
#include <rclcpp_action/server.hpp>
#include <ign_actor_plugin_msgs/action/animation.hpp>
#include <ign_actor_plugin_msgs/action/movement.hpp>
#define AnimationGoalPtr const std::shared_ptr<const ign_actor_plugin_msgs::action::Animation::Goal>
#define AnimationServerGoalPtr const std::shared_ptr<rclcpp_action::ServerGoalHandle<ign_actor_plugin_msgs::action::Animation>>&
#define MovementGoalPtr const std::shared_ptr<const ign_actor_plugin_msgs::action::Movement::Goal>
#define MovementServerGoalPtr const std::shared_ptr<rclcpp_action::ServerGoalHandle<ign_actor_plugin_msgs::action::Movement>>&
class ActorSystem:
public ignition::gazebo::System,
@@ -19,8 +27,8 @@ class ActorSystem:
private:
std::shared_ptr<rclcpp::Node> node;
std::shared_ptr<rclcpp_action::Server<ign_actor_plugin::action::Animation>> animationServer;
std::shared_ptr<rclcpp_action::Server<ign_actor_plugin::action::Movement>> movementServer;
std::shared_ptr<rclcpp_action::Server<ign_actor_plugin_msgs::action::Animation>> animationServer;
std::shared_ptr<rclcpp_action::Server<ign_actor_plugin_msgs::action::Movement>> movementServer;
public:
ActorSystem();