idk.
This commit is contained in:
parent
1ba1c7fc7b
commit
6b650fe594
@ -253,7 +253,7 @@
|
|||||||
<animation name="walk">
|
<animation name="walk">
|
||||||
<filename>https://fuel.ignitionrobotics.org/1.0/Mingfei/models/actor/tip/files/meshes/walk.dae</filename>
|
<filename>https://fuel.ignitionrobotics.org/1.0/Mingfei/models/actor/tip/files/meshes/walk.dae</filename>
|
||||||
</animation>
|
</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>2 2 1</target>
|
||||||
<target_weight>1.15</target_weight>
|
<target_weight>1.15</target_weight>
|
||||||
<obstacle_weight>1.8</obstacle_weight>
|
<obstacle_weight>1.8</obstacle_weight>
|
||||||
@ -261,7 +261,7 @@
|
|||||||
<ignore_obstacles>
|
<ignore_obstacles>
|
||||||
<model>ground_plane</model>
|
<model>ground_plane</model>
|
||||||
</ignore_obstacles>
|
</ignore_obstacles>
|
||||||
</plugin>-->
|
</plugin>
|
||||||
</actor>
|
</actor>
|
||||||
<gravity>0 0 -9.8</gravity>
|
<gravity>0 0 -9.8</gravity>
|
||||||
<magnetic_field>6e-06 2.3e-05 -4.2e-05</magnetic_field>
|
<magnetic_field>6e-06 2.3e-05 -4.2e-05</magnetic_field>
|
||||||
|
|||||||
@ -31,6 +31,8 @@ rosidl_target_interfaces(ActorPlugin
|
|||||||
target_link_libraries(ActorPlugin
|
target_link_libraries(ActorPlugin
|
||||||
ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
|
ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
|
||||||
ignition-gazebo5::ignition-gazebo5
|
ignition-gazebo5::ignition-gazebo5
|
||||||
|
${rclcpp_LIBRARIES}
|
||||||
|
${rclcpp_action_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
ament_package()
|
ament_package()
|
||||||
|
|||||||
@ -5,41 +5,74 @@
|
|||||||
#include <rclcpp_action/create_server.hpp>
|
#include <rclcpp_action/create_server.hpp>
|
||||||
#include "ActorSystem.h"
|
#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(
|
IGNITION_ADD_PLUGIN(
|
||||||
ActorSystem,
|
ActorSystem,
|
||||||
ignition::gazebo::System,
|
ignition::gazebo::System,
|
||||||
ActorSystem::ISystemPreUpdate)
|
ActorSystem::ISystemPreUpdate,
|
||||||
|
ActorSystem::ISystemConfigure)
|
||||||
|
|
||||||
ActorSystem::ActorSystem() = default;
|
ActorSystem::ActorSystem() = default;
|
||||||
|
|
||||||
ActorSystem::~ActorSystem() = default;
|
ActorSystem::~ActorSystem() = default;
|
||||||
|
|
||||||
void ActorSystem::PreUpdate(const ignition::gazebo::UpdateInfo &_info, ignition::gazebo::EntityComponentManager &_ecm) {
|
void ActorSystem::PreUpdate(const ignition::gazebo::UpdateInfo &_info, ignition::gazebo::EntityComponentManager &_ecm) {
|
||||||
|
|
||||||
//_ecm.EachNew<>()
|
//_ecm.EachNew<>()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Found too late: https://github.com/AlanSixth/gazebo_ros_action_tutorial/blob/master/src/gazebo_ros_action_tutorial.cc
|
// Found too late: https://github.com/AlanSixth/gazebo_ros_action_tutorial/blob/master/src/gazebo_ros_action_tutorial.cc
|
||||||
|
|
||||||
void ActorSystem::Configure(const ignition::gazebo::Entity &_entity, const std::shared_ptr<const sdf::Element> &_sdf,
|
void ActorSystem::Configure(const ignition::gazebo::Entity &_entity, const std::shared_ptr<const sdf::Element> &_sdf,
|
||||||
ignition::gazebo::EntityComponentManager &_ecm, ignition::gazebo::EventManager &) {
|
ignition::gazebo::EntityComponentManager &_ecm, ignition::gazebo::EventManager &) {
|
||||||
|
printf("Plugin configuring...\n");
|
||||||
|
|
||||||
rclcpp::init(0, {});
|
rclcpp::init(0, {});
|
||||||
|
|
||||||
std::string topic = "ActorPlugin";
|
std::string topic = "ActorPlugin";
|
||||||
if(_sdf->HasElement("topic")){
|
if (_sdf->HasElement("topic")) {
|
||||||
topic = _sdf->Get<std::string>("topic");
|
topic = _sdf->Get<std::string>("topic");
|
||||||
}
|
}
|
||||||
std::string name = "Actor";
|
std::string name = "Actor";
|
||||||
if(_sdf->HasElement("actor_name")){
|
if (_sdf->HasElement("actor_name")) {
|
||||||
name = _sdf->Get<std::string>("actor_name");
|
name = _sdf->Get<std::string>("actor_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
node = rclcpp::Node::make_shared("moveService",topic);
|
node = rclcpp::Node::make_shared("moveService", topic);
|
||||||
|
|
||||||
rclcpp_action::create_server<ign_actor_plugin::action::Animation>(node,"animation",
|
#pragma clang diagnostic push
|
||||||
std::bind(&ActorSystem::handle_animation_goal,this,std::placeholders::_1,std::placeholders::_2),
|
#pragma ide diagnostic ignored "UnusedValue"
|
||||||
std::bind(&ActorSystem::handle_animation_cancel,this,std::placeholders::_1),
|
animationServer = rclcpp_action::create_server<ign_actor_plugin::action::Animation>(
|
||||||
std::bind(&ActorSystem::handle_animation_accepted,this,std::placeholders::_1)
|
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,15 +10,17 @@
|
|||||||
#include <rclcpp/node.hpp>
|
#include <rclcpp/node.hpp>
|
||||||
#include "rclcpp/rclcpp.hpp"
|
#include "rclcpp/rclcpp.hpp"
|
||||||
#include "ign_actor_plugin/action/animation.hpp"
|
#include "ign_actor_plugin/action/animation.hpp"
|
||||||
|
#include "ign_actor_plugin/action/movement.hpp"
|
||||||
|
|
||||||
class ActorSystem:
|
class ActorSystem:
|
||||||
public ignition::gazebo::System,
|
public ignition::gazebo::System,
|
||||||
public ignition::gazebo::ISystemPreUpdate,
|
public ignition::gazebo::ISystemPreUpdate,
|
||||||
public ignition::gazebo::ISystemConfigure{
|
public ignition::gazebo::ISystemConfigure {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<rclcpp::Node> node;
|
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:
|
public:
|
||||||
ActorSystem();
|
ActorSystem();
|
||||||
@ -26,26 +28,17 @@ public:
|
|||||||
public:
|
public:
|
||||||
~ActorSystem() override;
|
~ActorSystem() override;
|
||||||
|
|
||||||
public: void PreUpdate(const ignition::gazebo::UpdateInfo &_info,
|
public:
|
||||||
ignition::gazebo::EntityComponentManager &_ecm) override;
|
void PreUpdate(const ignition::gazebo::UpdateInfo &_info,
|
||||||
|
ignition::gazebo::EntityComponentManager &_ecm) override;
|
||||||
|
|
||||||
public: void Configure(const ignition::gazebo::Entity &_entity,
|
public:
|
||||||
const std::shared_ptr<const sdf::Element> &_sdf,
|
void Configure(const ignition::gazebo::Entity &_entity,
|
||||||
ignition::gazebo::EntityComponentManager &_ecm,
|
const std::shared_ptr<const sdf::Element> &_sdf,
|
||||||
ignition::gazebo::EventManager &/*_eventMgr*/) override;
|
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
|
#endif //BUILD_ACTORSYSTEM_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user