idk.
This commit is contained in:
parent
1ba1c7fc7b
commit
6b650fe594
@ -253,7 +253,7 @@
|
||||
<animation name="walk">
|
||||
<filename>https://fuel.ignitionrobotics.org/1.0/Mingfei/models/actor/tip/files/meshes/walk.dae</filename>
|
||||
</animation>
|
||||
<!--<plugin name="actor1_plugin" filename="/home/bastian/dev_ws/build/gazebo_ros_actor/libRosActorPlugin.so">
|
||||
<plugin name="ActorSystem" filename="/home/ros/workspace/build/ign_actor_plugin/libActorPlugin.so">
|
||||
<target>2 2 1</target>
|
||||
<target_weight>1.15</target_weight>
|
||||
<obstacle_weight>1.8</obstacle_weight>
|
||||
@ -261,7 +261,7 @@
|
||||
<ignore_obstacles>
|
||||
<model>ground_plane</model>
|
||||
</ignore_obstacles>
|
||||
</plugin>-->
|
||||
</plugin>
|
||||
</actor>
|
||||
<gravity>0 0 -9.8</gravity>
|
||||
<magnetic_field>6e-06 2.3e-05 -4.2e-05</magnetic_field>
|
||||
|
||||
@ -31,6 +31,8 @@ rosidl_target_interfaces(ActorPlugin
|
||||
target_link_libraries(ActorPlugin
|
||||
ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
|
||||
ignition-gazebo5::ignition-gazebo5
|
||||
${rclcpp_LIBRARIES}
|
||||
${rclcpp_action_LIBRARIES}
|
||||
)
|
||||
|
||||
ament_package()
|
||||
|
||||
@ -5,17 +5,20 @@
|
||||
#include <rclcpp_action/create_server.hpp>
|
||||
#include "ActorSystem.h"
|
||||
|
||||
#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>>&
|
||||
|
||||
IGNITION_ADD_PLUGIN(
|
||||
ActorSystem,
|
||||
ignition::gazebo::System,
|
||||
ActorSystem::ISystemPreUpdate)
|
||||
ActorSystem::ISystemPreUpdate,
|
||||
ActorSystem::ISystemConfigure)
|
||||
|
||||
ActorSystem::ActorSystem() = default;
|
||||
|
||||
ActorSystem::~ActorSystem() = default;
|
||||
|
||||
void ActorSystem::PreUpdate(const ignition::gazebo::UpdateInfo &_info, ignition::gazebo::EntityComponentManager &_ecm) {
|
||||
|
||||
//_ecm.EachNew<>()
|
||||
}
|
||||
|
||||
@ -23,7 +26,10 @@ 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");
|
||||
|
||||
rclcpp::init(0, {});
|
||||
|
||||
std::string topic = "ActorPlugin";
|
||||
if (_sdf->HasElement("topic")) {
|
||||
topic = _sdf->Get<std::string>("topic");
|
||||
@ -35,11 +41,38 @@ void ActorSystem::Configure(const ignition::gazebo::Entity &_entity, const std::
|
||||
|
||||
node = rclcpp::Node::make_shared("moveService", topic);
|
||||
|
||||
rclcpp_action::create_server<ign_actor_plugin::action::Animation>(node,"animation",
|
||||
std::bind(&ActorSystem::handle_animation_goal,this,std::placeholders::_1,std::placeholders::_2),
|
||||
std::bind(&ActorSystem::handle_animation_cancel,this,std::placeholders::_1),
|
||||
std::bind(&ActorSystem::handle_animation_accepted,this,std::placeholders::_1)
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "UnusedValue"
|
||||
animationServer = rclcpp_action::create_server<ign_actor_plugin::action::Animation>(
|
||||
node,
|
||||
"animation",
|
||||
[](rclcpp_action::GoalUUID goalUuid,
|
||||
AnimationGoalPtr &animationGoal) {
|
||||
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
|
||||
},
|
||||
[](AnimationServerGoalPtr PH1) {
|
||||
return rclcpp_action::CancelResponse::ACCEPT;
|
||||
},
|
||||
[](AnimationServerGoalPtr PH1) {
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
movementServer rclcpp_action::create_server<ign_actor_plugin::action::Movement>(
|
||||
node,
|
||||
"movement",
|
||||
[](rclcpp_action::GoalUUID goalUuid, )
|
||||
)
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
printf("Spinning node...\n");
|
||||
std::thread spinThread([this]() {
|
||||
while (true) {
|
||||
printf("Wheee...\n");
|
||||
rclcpp::spin(node);
|
||||
}
|
||||
});
|
||||
spinThread.detach();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#include <rclcpp/node.hpp>
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
#include "ign_actor_plugin/action/animation.hpp"
|
||||
|
||||
#include "ign_actor_plugin/action/movement.hpp"
|
||||
|
||||
class ActorSystem:
|
||||
public ignition::gazebo::System,
|
||||
@ -19,6 +19,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;
|
||||
|
||||
public:
|
||||
ActorSystem();
|
||||
@ -26,26 +28,17 @@ public:
|
||||
public:
|
||||
~ActorSystem() override;
|
||||
|
||||
public: void PreUpdate(const ignition::gazebo::UpdateInfo &_info,
|
||||
public:
|
||||
void PreUpdate(const ignition::gazebo::UpdateInfo &_info,
|
||||
ignition::gazebo::EntityComponentManager &_ecm) override;
|
||||
|
||||
public: void Configure(const ignition::gazebo::Entity &_entity,
|
||||
public:
|
||||
void Configure(const ignition::gazebo::Entity &_entity,
|
||||
const std::shared_ptr<const sdf::Element> &_sdf,
|
||||
ignition::gazebo::EntityComponentManager &_ecm,
|
||||
ignition::gazebo::EventManager &/*_eventMgr*/) override;
|
||||
|
||||
private: rclcpp_action::GoalResponse handle_animation_goal(const rclcpp_action::GoalUUID & uuid,
|
||||
std::shared_ptr<const ign_actor_plugin::action::Animation::Goal> goal);
|
||||
|
||||
private: rclcpp_action::CancelResponse handle_animation_cancel(
|
||||
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ign_actor_plugin::action::Animation>> goal_handle);
|
||||
|
||||
private: void handle_animation_accepted(
|
||||
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ign_actor_plugin::action::Animation>> goal_handle);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //BUILD_ACTORSYSTEM_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user