Compare commits
No commits in common. "72a37287eb5c07e9bbec29de6eafe6c4e71bd339" and "830667372983ffcc0a4f5ed8dde9ad5a5a056107" have entirely different histories.
72a37287eb
...
8306673729
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,3 +1,3 @@
|
|||||||
[submodule "src/gz_ros2_control"]
|
[submodule "src/Groot"]
|
||||||
path = src/gz_ros2_control
|
path = src/Groot
|
||||||
url = https://github.com/ros-controls/gz_ros2_control.git
|
url = https://github.com/BehaviorTree/Groot.git
|
||||||
|
|||||||
2
build.sh
2
build.sh
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
pushd "$(dirname "$0")" || exit
|
pushd "$(dirname "$0")" || exit
|
||||||
colcon build --event-handlers console_cohesion+ --cmake-args -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja
|
colcon build --event-handlers console_cohesion+ --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja
|
||||||
popd || exit
|
popd || exit
|
||||||
|
|||||||
@ -2,10 +2,11 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
|
|||||||
project(btree)
|
project(btree)
|
||||||
|
|
||||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# find dependencies
|
# find dependencies
|
||||||
|
|
||||||
set(DEPENDENCIES
|
set(DEPENDENCIES
|
||||||
@ -35,6 +36,7 @@ endforeach()
|
|||||||
|
|
||||||
set(CPP_FILES
|
set(CPP_FILES
|
||||||
src/Tree.cpp
|
src/Tree.cpp
|
||||||
|
src/Extensions.cpp
|
||||||
src/nodes/WeightedRandomNode.cpp
|
src/nodes/WeightedRandomNode.cpp
|
||||||
src/nodes/GenerateXYPose.cpp
|
src/nodes/GenerateXYPose.cpp
|
||||||
src/nodes/RobotMove.cpp
|
src/nodes/RobotMove.cpp
|
||||||
@ -47,9 +49,8 @@ set(CPP_FILES
|
|||||||
src/nodes/ActorAnimation.cpp
|
src/nodes/ActorAnimation.cpp
|
||||||
src/nodes/ActorMovement.cpp
|
src/nodes/ActorMovement.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(tree ${CPP_FILES})
|
add_executable(tree ${CPP_FILES})
|
||||||
SET_SOURCE_FILES_PROPERTIES(src/Extensions.hpp PROPERTIES COMPILE_FLAGS -O0)
|
|
||||||
target_include_directories(tree PUBLIC /src /src/nodes)
|
|
||||||
set_property(TARGET tree PROPERTY CXX_STANDARD 17)
|
set_property(TARGET tree PROPERTY CXX_STANDARD 17)
|
||||||
ament_target_dependencies(tree ${DEPENDENCIES})
|
ament_target_dependencies(tree ${DEPENDENCIES})
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
//
|
//
|
||||||
// Created by bastian on 28.02.22.
|
// Created by bastian on 28.02.22.
|
||||||
//
|
//
|
||||||
#ifndef BUILD_EXTENSIONS_H
|
|
||||||
#define BUILD_EXTENSIONS_H
|
|
||||||
|
|
||||||
#include "Area.h"
|
#include "Area.h"
|
||||||
#include <geometry_msgs/msg/pose.hpp>
|
#include <geometry_msgs/msg/pose.hpp>
|
||||||
|
|
||||||
namespace BT {
|
namespace BT {
|
||||||
template<> inline
|
template<>
|
||||||
std::shared_ptr<Position2D> convertFromString(StringView str) {
|
std::shared_ptr<Position2D> convertFromString(StringView str) {
|
||||||
auto split = splitString(str, ',');
|
auto split = splitString(str, ',');
|
||||||
if (split.size() != 2) {
|
if (split.size() != 2) {
|
||||||
@ -21,7 +19,7 @@ namespace BT {
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> inline
|
template<>
|
||||||
std::shared_ptr<Area> convertFromString(StringView str) {
|
std::shared_ptr<Area> convertFromString(StringView str) {
|
||||||
auto parts = splitString(str, '|');
|
auto parts = splitString(str, '|');
|
||||||
if (parts.size() < 3) {
|
if (parts.size() < 3) {
|
||||||
@ -37,7 +35,7 @@ namespace BT {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> inline
|
template<>
|
||||||
std::shared_ptr<geometry_msgs::msg::Pose> convertFromString(StringView str) {
|
std::shared_ptr<geometry_msgs::msg::Pose> convertFromString(StringView str) {
|
||||||
auto parts = splitString(str, ',');
|
auto parts = splitString(str, ',');
|
||||||
if (!(parts.size() == 3 || parts.size() == 7)) {
|
if (!(parts.size() == 3 || parts.size() == 7)) {
|
||||||
@ -63,7 +61,7 @@ namespace BT {
|
|||||||
return pose;
|
return pose;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> inline
|
template<>
|
||||||
std::shared_ptr<geometry_msgs::msg::Point> convertFromString(StringView str) {
|
std::shared_ptr<geometry_msgs::msg::Point> convertFromString(StringView str) {
|
||||||
auto parts = splitString(str, ',');
|
auto parts = splitString(str, ',');
|
||||||
if (parts.size() != 3) {
|
if (parts.size() != 3) {
|
||||||
@ -78,7 +76,7 @@ namespace BT {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> inline
|
template<>
|
||||||
std::shared_ptr<geometry_msgs::msg::Quaternion> convertFromString(StringView str) {
|
std::shared_ptr<geometry_msgs::msg::Quaternion> convertFromString(StringView str) {
|
||||||
auto parts = splitString(str, ',');
|
auto parts = splitString(str, ',');
|
||||||
if (parts.size() != 4) {
|
if (parts.size() != 4) {
|
||||||
@ -94,5 +92,3 @@ namespace BT {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //BUILD_EXTENSIONS_H
|
|
||||||
@ -1,10 +1,7 @@
|
|||||||
#include "Extensions.hpp"
|
|
||||||
#include "Area.h"
|
#include "Area.h"
|
||||||
#include <behaviortree_cpp_v3/basic_types.h>
|
#include <behaviortree_cpp_v3/basic_types.h>
|
||||||
#include <behaviortree_cpp_v3/blackboard.h>
|
#include <behaviortree_cpp_v3/blackboard.h>
|
||||||
#include <behaviortree_cpp_v3/bt_factory.h>
|
#include <behaviortree_cpp_v3/bt_factory.h>
|
||||||
#include <boost/exception/exception.hpp>
|
|
||||||
#include <geometry_msgs/msg/detail/pose__struct.hpp>
|
|
||||||
#include <rclcpp/logging.hpp>
|
#include <rclcpp/logging.hpp>
|
||||||
#include <rclcpp/rclcpp.hpp>
|
#include <rclcpp/rclcpp.hpp>
|
||||||
#include <random>
|
#include <random>
|
||||||
@ -23,14 +20,10 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
using namespace BT;
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
rclcpp::init(argc, argv);
|
rclcpp::init(argc, argv);
|
||||||
rclcpp::NodeOptions node_options;
|
rclcpp::NodeOptions node_options;
|
||||||
|
|
||||||
convertFromString<std::shared_ptr<geometry_msgs::msg::Pose>>("0,0,0");
|
|
||||||
|
|
||||||
auto mainNode = rclcpp::Node::make_shared("tree_general_node", node_options);
|
auto mainNode = rclcpp::Node::make_shared("tree_general_node", node_options);
|
||||||
|
|
||||||
mainNode -> declare_parameter("trees",std::vector<std::string>({}));
|
mainNode -> declare_parameter("trees",std::vector<std::string>({}));
|
||||||
@ -58,12 +51,12 @@ int main(int argc, char **argv) {
|
|||||||
auto connection = std::make_shared<MoveConnection>(moveNode, "arm");
|
auto connection = std::make_shared<MoveConnection>(moveNode, "arm");
|
||||||
executor.add_node(moveNode);
|
executor.add_node(moveNode);
|
||||||
|
|
||||||
factory.registerBuilder<RobotMove>("RobotMove", [connection](const std::string &name, const NodeConfiguration &config) {
|
factory.registerBuilder<RobotMove>("RobotMove", [&connection](const std::string &name, const NodeConfiguration &config) {
|
||||||
return std::make_unique<RobotMove>(name, config, connection);
|
return std::make_unique<RobotMove>(name, config, &connection);
|
||||||
});
|
});
|
||||||
|
|
||||||
factory.registerBuilder<SetRobotVelocity>("SetRobotVelocity", [connection](const std::string &name, const NodeConfiguration &config) {
|
factory.registerBuilder<SetRobotVelocity>("SetRobotVelocity", [&connection](const std::string &name, const NodeConfiguration &config) {
|
||||||
return std::make_unique<SetRobotVelocity>(name, config, connection);
|
return std::make_unique<SetRobotVelocity>(name, config, &connection);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ BT::PortsList ActorAnimation::providedPorts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::NodeStatus ActorAnimation::onStart() {
|
BT::NodeStatus ActorAnimation::onStart() {
|
||||||
std::cout << "started actor animation" << std::endl;
|
std::cout << "started animation" << std::endl;
|
||||||
|
|
||||||
ros_actor_action_server_msgs::action::Animation::Goal goal;
|
ros_actor_action_server_msgs::action::Animation::Goal goal;
|
||||||
|
|
||||||
@ -37,10 +37,8 @@ BT::NodeStatus ActorAnimation::onStart() {
|
|||||||
send_goal_options.result_callback = [=](const ClientGoalHandle<Animation>::WrappedResult & parameter) {
|
send_goal_options.result_callback = [=](const ClientGoalHandle<Animation>::WrappedResult & parameter) {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if(parameter.code == ResultCode::SUCCEEDED){
|
if(parameter.code == ResultCode::SUCCEEDED){
|
||||||
std::cout << "finished actor animation" << std::endl;
|
|
||||||
result = BT::NodeStatus::SUCCESS;
|
result = BT::NodeStatus::SUCCESS;
|
||||||
}else{
|
}else{
|
||||||
std::cout << "failed actor animation" << std::endl;
|
|
||||||
result = BT::NodeStatus::FAILURE;
|
result = BT::NodeStatus::FAILURE;
|
||||||
}
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
@ -55,12 +53,14 @@ BT::NodeStatus ActorAnimation::onStart() {
|
|||||||
BT::NodeStatus ActorAnimation::onRunning() {
|
BT::NodeStatus ActorAnimation::onRunning() {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
auto status = result;
|
auto status = result;
|
||||||
|
if(result != BT::NodeStatus::RUNNING){
|
||||||
|
result = BT::NodeStatus::IDLE;
|
||||||
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorAnimation::onHalted() {
|
void ActorAnimation::onHalted() {
|
||||||
std::cout << "halted actor animation" << std::endl;
|
std::cout << "halted animation" << std::endl;
|
||||||
client->async_cancel_all_goals();
|
client->async_cancel_all_goals();
|
||||||
result = BT::NodeStatus::FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
// Created by bastian on 26.03.22.
|
// Created by bastian on 26.03.22.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../Extensions.hpp"
|
|
||||||
#include "ActorMovement.h"
|
#include "ActorMovement.h"
|
||||||
#include <action_msgs/msg/detail/goal_status__struct.hpp>
|
#include <action_msgs/msg/detail/goal_status__struct.hpp>
|
||||||
#include <behaviortree_cpp_v3/basic_types.h>
|
#include <behaviortree_cpp_v3/basic_types.h>
|
||||||
@ -23,7 +22,7 @@ BT::PortsList ActorMovement::providedPorts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BT::NodeStatus ActorMovement::onStart() {
|
BT::NodeStatus ActorMovement::onStart() {
|
||||||
std::cout << "started actor movement" << std::endl;
|
std::cout << "started moving" << std::endl;
|
||||||
|
|
||||||
ros_actor_action_server_msgs::action::Movement::Goal goal;
|
ros_actor_action_server_msgs::action::Movement::Goal goal;
|
||||||
|
|
||||||
@ -52,10 +51,10 @@ BT::NodeStatus ActorMovement::onStart() {
|
|||||||
send_goal_options.result_callback = [&](ClientGoalHandle<Movement>::WrappedResult parameter) {
|
send_goal_options.result_callback = [&](ClientGoalHandle<Movement>::WrappedResult parameter) {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if(parameter.code == ResultCode::SUCCEEDED){
|
if(parameter.code == ResultCode::SUCCEEDED){
|
||||||
std::cout << "finished actor movement" << std::endl;
|
std::cout << "Success?" << std::endl;
|
||||||
result = BT::NodeStatus::SUCCESS;
|
result = BT::NodeStatus::SUCCESS;
|
||||||
}else{
|
}else{
|
||||||
std::cout << "failed actor movement" << std::endl;
|
std::cout << "Failure?" << std::endl;
|
||||||
result = BT::NodeStatus::FAILURE;
|
result = BT::NodeStatus::FAILURE;
|
||||||
}
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
@ -82,12 +81,15 @@ BT::NodeStatus ActorMovement::onStart() {
|
|||||||
BT::NodeStatus ActorMovement::onRunning() {
|
BT::NodeStatus ActorMovement::onRunning() {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
auto status = result;
|
auto status = result;
|
||||||
|
if(result != BT::NodeStatus::RUNNING){
|
||||||
|
result = BT::NodeStatus::IDLE;
|
||||||
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorMovement::onHalted() {
|
void ActorMovement::onHalted() {
|
||||||
std::cout << "halted actor movement" << std::endl;
|
std::cout << "halted move" << std::endl;
|
||||||
client->async_cancel_all_goals();
|
client->async_cancel_all_goals();
|
||||||
result = BT::NodeStatus::FAILURE;
|
result = BT::NodeStatus::IDLE;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,8 +83,7 @@ BT::NodeStatus BT::GenerateXYPose::tick() {
|
|||||||
randomPose->orientation.y = 0;
|
randomPose->orientation.y = 0;
|
||||||
randomPose->orientation.z = 0;
|
randomPose->orientation.z = 0;
|
||||||
|
|
||||||
std::cout << "Generated Pose." << std::endl;
|
printf("Generated Target: %f %f\n", pos.x, pos.y);
|
||||||
|
|
||||||
setOutput<std::shared_ptr<geometry_msgs::msg::Pose>>("pose", randomPose);
|
setOutput<std::shared_ptr<geometry_msgs::msg::Pose>>("pose", randomPose);
|
||||||
return NodeStatus::SUCCESS;
|
return NodeStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "InAreaTest.h"
|
#include "InAreaTest.h"
|
||||||
#include "../Extensions.hpp"
|
|
||||||
|
|
||||||
BT::PortsList BT::InAreaTest::providedPorts() {
|
BT::PortsList BT::InAreaTest::providedPorts() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -15,24 +15,23 @@ void BT::InterruptableSequence::halt() {
|
|||||||
BT::NodeStatus BT::InterruptableSequence::tick() {
|
BT::NodeStatus BT::InterruptableSequence::tick() {
|
||||||
auto result = children_nodes_[position]->executeTick();
|
auto result = children_nodes_[position]->executeTick();
|
||||||
|
|
||||||
|
setStatus(NodeStatus::RUNNING);
|
||||||
|
|
||||||
if(result==NodeStatus::FAILURE){
|
if(result==NodeStatus::FAILURE){
|
||||||
resetChildren();
|
haltChildren();
|
||||||
position=0;
|
position=0;
|
||||||
setStatus(NodeStatus::FAILURE);
|
|
||||||
return NodeStatus::FAILURE;
|
return NodeStatus::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result==NodeStatus::SUCCESS){
|
if(result==NodeStatus::SUCCESS){
|
||||||
position++;
|
position++;
|
||||||
if(position>=children_nodes_.size()){
|
if(position>=children_nodes_.size()){
|
||||||
resetChildren();
|
haltChildren();
|
||||||
position=0;
|
position=0;
|
||||||
setStatus(NodeStatus::SUCCESS);
|
|
||||||
return NodeStatus::SUCCESS;
|
return NodeStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus(NodeStatus::RUNNING);
|
|
||||||
return NodeStatus::RUNNING;
|
return NodeStatus::RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,19 +11,20 @@ void MoveConnection::planAndExecute(const std::shared_ptr<geometry_msgs::msg::Po
|
|||||||
std::cout<<"planAndExecute."<<std::endl;
|
std::cout<<"planAndExecute."<<std::endl;
|
||||||
lock.lock();
|
lock.lock();
|
||||||
state = RUNNING;
|
state = RUNNING;
|
||||||
|
std::cout<<"got lock."<<std::endl;
|
||||||
lastTarget = pose;
|
lastTarget = pose;
|
||||||
lastCallback = callback;
|
lastCallback = callback;
|
||||||
|
|
||||||
moveGroup.setMaxVelocityScalingFactor(currentSpeed);
|
moveGroup.setMaxVelocityScalingFactor(currentSpeed);
|
||||||
moveGroup.setMaxAccelerationScalingFactor(1);
|
moveGroup.setMaxAccelerationScalingFactor(1);
|
||||||
|
|
||||||
moveGroup.setPoseTarget(*lastTarget);
|
|
||||||
moveGroup.setGoalJointTolerance(0.01);
|
|
||||||
moveGroup.setGoalOrientationTolerance(0.01);
|
|
||||||
|
|
||||||
std::cout<<"Starting planning"<<std::endl;
|
std::cout<<"Starting planning"<<std::endl;
|
||||||
|
|
||||||
std::thread([&](){
|
std::thread([&](){
|
||||||
|
moveGroup.setPoseTarget(*lastTarget);
|
||||||
|
moveGroup.setGoalJointTolerance(0.01);
|
||||||
|
moveGroup.setGoalOrientationTolerance(0.01);
|
||||||
|
|
||||||
std::cout<<"Parameters set."<<std::endl;
|
std::cout<<"Parameters set."<<std::endl;
|
||||||
|
|
||||||
auto finished = moveGroup.move() == moveit::core::MoveItErrorCode::SUCCESS;
|
auto finished = moveGroup.move() == moveit::core::MoveItErrorCode::SUCCESS;
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
class MoveConnection {
|
class MoveConnection {
|
||||||
private:
|
private:
|
||||||
enum {IDLE,RUNNING,SPEED_CHANGE} state = IDLE;
|
enum {IDLE,RUNNING,SPEED_CHANGE} state;
|
||||||
moveit::planning_interface::MoveGroupInterface moveGroup;
|
moveit::planning_interface::MoveGroupInterface moveGroup;
|
||||||
std::shared_ptr<geometry_msgs::msg::Pose> lastTarget = nullptr;
|
std::shared_ptr<geometry_msgs::msg::Pose> lastTarget = nullptr;
|
||||||
std::function<void(bool)> lastCallback = [](__attribute__((unused))bool finished) {};
|
std::function<void(bool)> lastCallback = [](__attribute__((unused))bool finished) {};
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
// Created by bastian on 29.03.22.
|
// Created by bastian on 29.03.22.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "../Extensions.hpp"
|
|
||||||
#include "OffsetPose.h"
|
#include "OffsetPose.h"
|
||||||
#include <geometry_msgs/msg/detail/pose__struct.hpp>
|
#include <geometry_msgs/msg/detail/pose__struct.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -24,7 +23,6 @@ BT::NodeStatus BT::OffsetPose::tick() {
|
|||||||
|
|
||||||
std::shared_ptr<geometry_msgs::msg::Pose> pose;
|
std::shared_ptr<geometry_msgs::msg::Pose> pose;
|
||||||
if (!getInput("input", pose)) {
|
if (!getInput("input", pose)) {
|
||||||
std::cout << "Missing {input} pose" << std::endl;
|
|
||||||
return NodeStatus::FAILURE;
|
return NodeStatus::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
#include "RobotMove.h"
|
#include "RobotMove.h"
|
||||||
|
|
||||||
BT::RobotMove::RobotMove(const std::string &name, const BT::NodeConfiguration &config,
|
BT::RobotMove::RobotMove(const std::string &name, const BT::NodeConfiguration &config,
|
||||||
std::shared_ptr<MoveConnection> connection)
|
std::shared_ptr<MoveConnection> *connection)
|
||||||
: StatefulActionNode(name, config) {
|
: StatefulActionNode(name, config) {
|
||||||
this->connection = connection;
|
this->connection = connection;
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ BT::NodeStatus BT::RobotMove::onStart() {
|
|||||||
printf("X:%f Y:%f Z:%f\n",pose->position.x,pose->position.y,pose->position.z);
|
printf("X:%f Y:%f Z:%f\n",pose->position.x,pose->position.y,pose->position.z);
|
||||||
printf("W:%f X:%f Y:%f Z:%f\n",pose->orientation.w,pose->orientation.x,pose->orientation.y,pose->orientation.z);
|
printf("W:%f X:%f Y:%f Z:%f\n",pose->orientation.w,pose->orientation.x,pose->orientation.y,pose->orientation.z);
|
||||||
asyncResult = NodeStatus::RUNNING;
|
asyncResult = NodeStatus::RUNNING;
|
||||||
connection->planAndExecute(pose,[this](bool finished){
|
connection->get()->planAndExecute(pose,[this](bool finished){
|
||||||
if(finished){
|
if(finished){
|
||||||
printf("Finished move.");
|
printf("Finished move.");
|
||||||
asyncResult = NodeStatus::SUCCESS;
|
asyncResult = NodeStatus::SUCCESS;
|
||||||
@ -42,7 +42,7 @@ BT::NodeStatus BT::RobotMove::onRunning() {
|
|||||||
|
|
||||||
void BT::RobotMove::onHalted() {
|
void BT::RobotMove::onHalted() {
|
||||||
std::cout << "Halting RobotMove" << std::endl;
|
std::cout << "Halting RobotMove" << std::endl;
|
||||||
connection->stop();
|
connection->get()->stop();
|
||||||
asyncResult=NodeStatus::FAILURE;
|
asyncResult=NodeStatus::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,12 +16,12 @@ namespace BT {
|
|||||||
|
|
||||||
class RobotMove : public StatefulActionNode {
|
class RobotMove : public StatefulActionNode {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<MoveConnection> connection;
|
std::shared_ptr<MoveConnection> *connection;
|
||||||
NodeStatus asyncResult = NodeStatus::FAILURE;
|
NodeStatus asyncResult = NodeStatus::FAILURE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RobotMove(const std::string &name, const BT::NodeConfiguration &config,
|
RobotMove(const std::string &name, const BT::NodeConfiguration &config,
|
||||||
std::shared_ptr<MoveConnection> connection);
|
std::shared_ptr<MoveConnection> *connection);
|
||||||
|
|
||||||
NodeStatus onStart() override;
|
NodeStatus onStart() override;
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ BT::NodeStatus BT::SetRobotVelocity::tick() {
|
|||||||
std::cout<<"No velocity given."<<std::endl;
|
std::cout<<"No velocity given."<<std::endl;
|
||||||
return NodeStatus::FAILURE;
|
return NodeStatus::FAILURE;
|
||||||
}
|
}
|
||||||
connection->setSpeedMultiplier(velocity);
|
connection->get()->setSpeedMultiplier(velocity);
|
||||||
return NodeStatus::SUCCESS;
|
return NodeStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ BT::PortsList BT::SetRobotVelocity::providedPorts() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BT::SetRobotVelocity::SetRobotVelocity(const std::string &name, const BT::NodeConfiguration &config, std::shared_ptr<MoveConnection> connection) : SyncActionNode(
|
BT::SetRobotVelocity::SetRobotVelocity(const std::string &name, const BT::NodeConfiguration &config, std::shared_ptr<MoveConnection> *connection) : SyncActionNode(
|
||||||
name, config) {
|
name, config) {
|
||||||
this->connection = connection;
|
this->connection = connection;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,11 +11,11 @@
|
|||||||
namespace BT {
|
namespace BT {
|
||||||
class SetRobotVelocity: public SyncActionNode {
|
class SetRobotVelocity: public SyncActionNode {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<MoveConnection> connection;
|
std::shared_ptr<MoveConnection> *connection{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SetRobotVelocity(const std::string &name, const NodeConfiguration &config,
|
SetRobotVelocity(const std::string &name, const NodeConfiguration &config,
|
||||||
std::shared_ptr<MoveConnection> connection);
|
std::shared_ptr<MoveConnection> *connection);
|
||||||
|
|
||||||
static PortsList providedPorts();
|
static PortsList providedPorts();
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ void WeightedRandomNode::halt() {
|
|||||||
|
|
||||||
NodeStatus WeightedRandomNode::tick() {
|
NodeStatus WeightedRandomNode::tick() {
|
||||||
if (select_next) {
|
if (select_next) {
|
||||||
size_t children_count = children_nodes_.size();
|
const size_t children_count = children_nodes_.size();
|
||||||
|
|
||||||
std::string weightString;
|
std::string weightString;
|
||||||
|
|
||||||
@ -53,18 +53,14 @@ NodeStatus WeightedRandomNode::tick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selected_child_index = i;
|
selected_child_index = i;
|
||||||
|
|
||||||
std::cout<< "Selected child:" << selected_child_index <<std::endl;
|
|
||||||
|
|
||||||
select_next = false;
|
select_next = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeNode *current_child_node = children_nodes_[selected_child_index];
|
TreeNode *current_child_node = children_nodes_[selected_child_index];
|
||||||
NodeStatus child_status = current_child_node->executeTick();
|
const NodeStatus child_status = current_child_node->executeTick();
|
||||||
|
|
||||||
if (child_status != NodeStatus::RUNNING) {
|
if (child_status != NodeStatus::RUNNING) {
|
||||||
select_next = true;
|
select_next = true;
|
||||||
resetChildren();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return child_status;
|
return child_status;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<root main_tree_to_execute="actorTree">
|
<root main_tree_to_execute="actorTree">
|
||||||
<BehaviorTree ID="actorTree">
|
<BehaviorTree ID="actorTree">
|
||||||
<WeightedRandom weights="95,5">
|
<Control ID="WeightedRandom" weights="95,5">
|
||||||
<Sequence>
|
<Sequence>
|
||||||
<SubTree ID="WorkOnBench"/>
|
<SubTree ID="WorkOnBench"/>
|
||||||
<SubTree ID="DepositToShelf"/>
|
<SubTree ID="DepositToShelf"/>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
<Action ID="GenerateXYPose" area="{unsafeArea}" pose="{actorTarget}"/>
|
<Action ID="GenerateXYPose" area="{unsafeArea}" pose="{actorTarget}"/>
|
||||||
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="{actorTarget}"/>
|
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="{actorTarget}"/>
|
||||||
</Sequence>
|
</Sequence>
|
||||||
</WeightedRandom>
|
</Control>
|
||||||
</BehaviorTree>
|
</BehaviorTree>
|
||||||
<BehaviorTree ID="DepositToShelf">
|
<BehaviorTree ID="DepositToShelf">
|
||||||
<Sequence>
|
<Sequence>
|
||||||
|
|||||||
@ -8,11 +8,11 @@
|
|||||||
</Inverter>
|
</Inverter>
|
||||||
|
|
||||||
<Sequence>
|
<Sequence>
|
||||||
<WeightedRandom weights="100,5,2">
|
<Control ID="WeightedRandom" weights="100,5,2">
|
||||||
<Action ID="GenerateXYPose" area="{safeArea}" pose="{actorTarget}"/>
|
<Action ID="GenerateXYPose" area="{safeArea}" pose="{actorTarget}"/>
|
||||||
<Action ID="GenerateXYPose" area="{warningArea}" pose="{actorTarget}"/>
|
<Action ID="GenerateXYPose" area="{warningArea}" pose="{actorTarget}"/>
|
||||||
<Action ID="GenerateXYPose" area="{unsafeArea}" pose="{actorTarget}"/>
|
<Action ID="GenerateXYPose" area="{unsafeArea}" pose="{actorTarget}"/>
|
||||||
</WeightedRandom>
|
</Control>
|
||||||
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="{actorTarget}"/>
|
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="{actorTarget}"/>
|
||||||
</Sequence>
|
</Sequence>
|
||||||
</ReactiveSequence>
|
</ReactiveSequence>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="{actorTarget}"/>
|
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="{actorTarget}"/>
|
||||||
<Action ID="ActorAnimation" animation_name="standing_to_low"/>
|
<Action ID="ActorAnimation" animation_name="standing_to_low"/>
|
||||||
<Action ID="ActorAnimation" animation_name="low_inspect"/>
|
<Action ID="ActorAnimation" animation_name="low_inspect"/>
|
||||||
<Action ID="ActorAnimation" animation_name="low_grab"/>
|
<Action ID="ActorAnimation" animation_name="low_put_back"/>
|
||||||
<Action ID="ActorAnimation" animation_name="low_to_standing"/>
|
<Action ID="ActorAnimation" animation_name="low_to_standing"/>
|
||||||
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="1,0.5,0,0,0,0,1"/>
|
<Action ID="ActorMovement" animation_distance="1.5" animation_name="standing_walk" target="1,0.5,0,0,0,0,1"/>
|
||||||
<Action ID="ActorAnimation" animation_name="standing_extend_arm"/>
|
<Action ID="ActorAnimation" animation_name="standing_extend_arm"/>
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
<Action ID="ActorAnimation" animation_name="standing_extend_arm"/>
|
<Action ID="ActorAnimation" animation_name="standing_extend_arm"/>
|
||||||
<Action ID="ActorAnimation" animation_name="standing_retract_arm"/>
|
<Action ID="ActorAnimation" animation_name="standing_retract_arm"/>
|
||||||
<Action ID="SetCalledTo" state="false"/>
|
<Action ID="SetCalledTo" state="false"/>
|
||||||
<SubTree ID="DepositToShelf"/>
|
|
||||||
</Sequence>
|
</Sequence>
|
||||||
</BehaviorTree>
|
</BehaviorTree>
|
||||||
<BehaviorTree ID="DepositToShelf">
|
<BehaviorTree ID="DepositToShelf">
|
||||||
|
|||||||
@ -10,14 +10,16 @@
|
|||||||
<Action ID="SetRobotVelocity" velocity="0.1"/>
|
<Action ID="SetRobotVelocity" velocity="0.1"/>
|
||||||
<Action ID="SetRobotVelocity" velocity="1"/>
|
<Action ID="SetRobotVelocity" velocity="1"/>
|
||||||
</IfThenElse>
|
</IfThenElse>
|
||||||
<Control ID="InterruptableSequence">
|
<Fallback>
|
||||||
<Action ID="GenerateXYPose" area="{negativeYTable}" pose="{target}"/>
|
<Control ID="InterruptableSequence">
|
||||||
<Action ID="OffsetPose" input="{target}" offset="0,0,1.1" orientation="0,0,1,0" output="{target}"/>
|
<Action ID="GenerateXYPose" area="{negativeYTable}" pose="{target}"/>
|
||||||
<Action ID="RobotMove" target="{target}"/>
|
<Action ID="OffsetPose" input="{target}" offset="0,0,1.1" orientation="0,0,1,0" output="{target}"/>
|
||||||
<Action ID="GenerateXYPose" area="{positiveYTable}" pose="{target}"/>
|
<Action ID="RobotMove" target="{target}"/>
|
||||||
<Action ID="OffsetPose" input="{target}" offset="0,0,1.1" orientation="0,0,1,0" output="{target}"/>
|
<Action ID="GenerateXYPose" area="{positiveYTable}" pose="{target}"/>
|
||||||
<Action ID="RobotMove" target="{target}"/>
|
<Action ID="OffsetPose" input="{target}" offset="0,0,1.1" orientation="0,0,1,0" output="{target}"/>
|
||||||
</Control>
|
<Action ID="RobotMove" target="{target}"/>
|
||||||
|
</Control>
|
||||||
|
</Fallback>
|
||||||
</ReactiveSequence>
|
</ReactiveSequence>
|
||||||
</BehaviorTree>
|
</BehaviorTree>
|
||||||
</root>
|
</root>
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit a295d3319727b3e5ad1b0fa7dbfd34f3369655cf
|
Subproject commit 6c4244de09a53d2352d4db30d7574e8277611a73
|
||||||
@ -68,8 +68,12 @@ void ActorSystem::switchAnimation(EntityComponentManager &_ecm, char *animationN
|
|||||||
}
|
}
|
||||||
|
|
||||||
double Angle(ignition::math::Quaterniond a,ignition::math::Quaterniond b){
|
double Angle(ignition::math::Quaterniond a,ignition::math::Quaterniond b){
|
||||||
auto dot = fmin(abs(a.Normalized().Dot(b.Normalized())),1.0);
|
auto dot = fmin(abs(a.Dot(b)),1.0);
|
||||||
return acos(dot);
|
if(dot > 0.999999){
|
||||||
|
return 0.0;
|
||||||
|
}else{
|
||||||
|
return acos(dot) * 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorSystem::PreUpdate(const UpdateInfo &_info, EntityComponentManager &_ecm) {
|
void ActorSystem::PreUpdate(const UpdateInfo &_info, EntityComponentManager &_ecm) {
|
||||||
@ -180,8 +184,6 @@ void ActorSystem::PreUpdate(const UpdateInfo &_info, EntityComponentManager &_ec
|
|||||||
}
|
}
|
||||||
|
|
||||||
movementDetails.rotateToEndDuration = Angle(movementDetails.targetDiff.Rot(),movementDetails.target.Rot()) / turnSpeed;
|
movementDetails.rotateToEndDuration = Angle(movementDetails.targetDiff.Rot(),movementDetails.target.Rot()) / turnSpeed;
|
||||||
|
|
||||||
igndbg << movementDetails.rotateToTargetDuration << " " <<movementDetails.moveDuration << " " << movementDetails.rotateToEndDuration << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
movementDetails.time += deltaTimeSeconds;
|
movementDetails.time += deltaTimeSeconds;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from ament_index_python import get_package_share_directory
|
from ament_index_python import get_package_share_directory
|
||||||
from launch import LaunchDescription
|
from launch import LaunchDescription
|
||||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, ExecuteProcess, RegisterEventHandler, TimerAction
|
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, ExecuteProcess, RegisterEventHandler
|
||||||
from launch.event_handlers import OnProcessExit
|
from launch.event_handlers import OnProcessExit
|
||||||
from launch_ros.actions import Node, SetParameter
|
from launch_ros.actions import Node, SetParameter
|
||||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||||
@ -129,12 +129,7 @@ def generate_launch_description():
|
|||||||
emulate_tty=True,
|
emulate_tty=True,
|
||||||
),
|
),
|
||||||
|
|
||||||
TimerAction(
|
btree,
|
||||||
period=10.0,
|
|
||||||
actions=[
|
|
||||||
btree,
|
|
||||||
]
|
|
||||||
),
|
|
||||||
|
|
||||||
IncludeLaunchDescription(
|
IncludeLaunchDescription(
|
||||||
PythonLaunchDescriptionSource(
|
PythonLaunchDescriptionSource(
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<rot>180</rot>
|
<rot>180</rot>
|
||||||
</plugin>
|
</plugin>
|
||||||
<skin>
|
<skin>
|
||||||
<filename>$(find ign_actor_plugin)/animation/standing_walk.dae</filename>
|
<filename>$(find ign_actor_plugin)/animation/walk.dae</filename>
|
||||||
<scale>1.0</scale>
|
<scale>1.0</scale>
|
||||||
</skin>
|
</skin>
|
||||||
|
|
||||||
|
|||||||
@ -258,76 +258,39 @@
|
|||||||
<mechanicalReduction>1</mechanicalReduction>
|
<mechanicalReduction>1</mechanicalReduction>
|
||||||
</actuator>
|
</actuator>
|
||||||
</transmission>
|
</transmission>
|
||||||
<gazebo reference="table">
|
|
||||||
<mu1>0.2</mu1>
|
|
||||||
<mu2>0.2</mu2>
|
|
||||||
<visual>
|
|
||||||
<material>
|
|
||||||
<diffuse>0.8 0.8 0.8 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
|
||||||
<gazebo reference="base_bottom">
|
<gazebo reference="base_bottom">
|
||||||
<mu1>0.2</mu1>
|
<mu1>0.2</mu1>
|
||||||
<mu2>0.2</mu2>
|
<mu2>0.2</mu2>
|
||||||
<visual>
|
<material>Gazebo/Orange</material>
|
||||||
<material>
|
|
||||||
<diffuse>0.5 0.5 0.5 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
</gazebo>
|
||||||
<gazebo reference="base_top">
|
<gazebo reference="base_top">
|
||||||
<mu1>0.2</mu1>
|
<mu1>0.2</mu1>
|
||||||
<mu2>0.2</mu2>
|
<mu2>0.2</mu2>
|
||||||
<visual>
|
<material>Gazebo/Orange</material>
|
||||||
<material>
|
|
||||||
<diffuse>1 0.35 0 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
</gazebo>
|
||||||
<gazebo reference="link1_full">
|
<gazebo reference="link1_full">
|
||||||
<mu1>0.2</mu1>
|
<mu1>0.2</mu1>
|
||||||
<mu2>0.2</mu2>
|
<mu2>0.2</mu2>
|
||||||
<visual>
|
<material>Gazebo/Orange</material>
|
||||||
<material>
|
|
||||||
<diffuse>1 0.35 0 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
</gazebo>
|
||||||
<gazebo reference="link2_bottom">
|
<gazebo reference="link2_bottom">
|
||||||
<mu1>0.2</mu1>
|
<mu1>0.2</mu1>
|
||||||
<mu2>0.2</mu2>
|
<mu2>0.2</mu2>
|
||||||
<visual>
|
<material>Gazebo/Orange</material>
|
||||||
<material>
|
|
||||||
<diffuse>1 0.35 0 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
</gazebo>
|
||||||
<gazebo reference="link2_top">
|
<gazebo reference="link2_top">
|
||||||
<mu1>0.2</mu1>
|
<mu1>0.2</mu1>
|
||||||
<mu2>0.2</mu2>
|
<mu2>0.2</mu2>
|
||||||
<visual>
|
<material>Gazebo/Orange</material>
|
||||||
<material>
|
|
||||||
<diffuse>1 0.35 0 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
</gazebo>
|
||||||
<gazebo reference="link3_bottom">
|
<gazebo reference="link3_bottom">
|
||||||
<mu1>0.2</mu1>
|
<mu1>0.2</mu1>
|
||||||
<mu2>0.2</mu2>
|
<mu2>0.2</mu2>
|
||||||
<visual>
|
<material>Gazebo/Orange</material>
|
||||||
<material>
|
|
||||||
<diffuse>1 0.35 0 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
</gazebo>
|
||||||
<gazebo reference="link3_top">
|
<gazebo reference="link3_top">
|
||||||
<mu1>0.2</mu1>
|
<mu1>0.2</mu1>
|
||||||
<mu2>0.2</mu2>
|
<mu2>0.2</mu2>
|
||||||
<visual>
|
<material>Gazebo/Grey</material>
|
||||||
<material>
|
|
||||||
<diffuse>0.5 0.5 0.5 1 </diffuse>
|
|
||||||
</material>
|
|
||||||
</visual>
|
|
||||||
</gazebo>
|
</gazebo>
|
||||||
</robot>
|
</robot>
|
||||||
|
|||||||
@ -25,9 +25,7 @@ void sendAction(mqd_t queue, ActionMessage *message) {
|
|||||||
|
|
||||||
void waitForState(FeedbackMessage *currentFeedback,ActorPluginState state){
|
void waitForState(FeedbackMessage *currentFeedback,ActorPluginState state){
|
||||||
std::unique_lock lock(feedbackMutex);
|
std::unique_lock lock(feedbackMutex);
|
||||||
stateCondition.wait(lock,[¤tFeedback,state]{
|
stateCondition.wait(lock,[¤tFeedback,state]{return currentFeedback->state==state;});
|
||||||
return currentFeedback->state==state;
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -101,12 +99,10 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
if (newFeedback.state==IDLE) {
|
if (newFeedback.state==IDLE) {
|
||||||
if(currentFeedback.state==ANIMATION && currentAnimationGoalPtr!=nullptr){
|
if(currentFeedback.state==ANIMATION && currentAnimationGoalPtr!=nullptr){
|
||||||
std::cout << "Finished Animation. " << std::endl;
|
|
||||||
currentAnimationGoalPtr->succeed(std::make_shared<ros_actor_action_server_msgs::action::Animation_Result>());
|
currentAnimationGoalPtr->succeed(std::make_shared<ros_actor_action_server_msgs::action::Animation_Result>());
|
||||||
currentAnimationGoalPtr = nullptr;
|
currentAnimationGoalPtr = nullptr;
|
||||||
}
|
}
|
||||||
if(currentFeedback.state==MOVEMENT && currentMovementGoalPtr!=nullptr){
|
if(currentFeedback.state==MOVEMENT && currentMovementGoalPtr!=nullptr){
|
||||||
std::cout << "Finished Movement. " << std::endl;
|
|
||||||
currentMovementGoalPtr->succeed(std::make_shared<ros_actor_action_server_msgs::action::Movement_Result>());
|
currentMovementGoalPtr->succeed(std::make_shared<ros_actor_action_server_msgs::action::Movement_Result>());
|
||||||
currentMovementGoalPtr = nullptr;
|
currentMovementGoalPtr = nullptr;
|
||||||
}
|
}
|
||||||
@ -124,14 +120,14 @@ int main(int argc, char **argv) {
|
|||||||
rosMutex.lock();
|
rosMutex.lock();
|
||||||
|
|
||||||
if (currentFeedback.state == IDLE) {
|
if (currentFeedback.state == IDLE) {
|
||||||
std::cout << "Accepting Animation..." << std::endl;
|
std::cout << "Accepting..." << std::endl;
|
||||||
|
|
||||||
currentAction.animationSpeed = animationGoal->animation_speed;
|
currentAction.animationSpeed = animationGoal->animation_speed;
|
||||||
strcpy(currentAction.animationName, animationGoal->animation_name.data());
|
strcpy(currentAction.animationName, animationGoal->animation_name.data());
|
||||||
|
|
||||||
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
|
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Rejecting Animation..." << std::endl;
|
std::cout << "Rejecting..." << std::endl;
|
||||||
rosMutex.unlock();
|
rosMutex.unlock();
|
||||||
return rclcpp_action::GoalResponse::REJECT;
|
return rclcpp_action::GoalResponse::REJECT;
|
||||||
}
|
}
|
||||||
@ -141,11 +137,9 @@ int main(int argc, char **argv) {
|
|||||||
return rclcpp_action::CancelResponse::REJECT;
|
return rclcpp_action::CancelResponse::REJECT;
|
||||||
} else {
|
} else {
|
||||||
rosMutex.lock();
|
rosMutex.lock();
|
||||||
std::cout << "Cancelling Animation..." << std::endl;
|
|
||||||
sendAction(actionQueue, &cancelAction);
|
sendAction(actionQueue, &cancelAction);
|
||||||
|
|
||||||
waitForState(¤tFeedback, IDLE);
|
waitForState(¤tFeedback, IDLE);
|
||||||
std::cout << "Cancelled Animation..." << std::endl;
|
|
||||||
rosMutex.unlock();
|
rosMutex.unlock();
|
||||||
|
|
||||||
return rclcpp_action::CancelResponse::ACCEPT;
|
return rclcpp_action::CancelResponse::ACCEPT;
|
||||||
@ -167,7 +161,7 @@ int main(int argc, char **argv) {
|
|||||||
[¤tAction, ¤tFeedback](__attribute__((unused)) const rclcpp_action::GoalUUID goalUuid, const MovementGoalPtr &movementGoal) {
|
[¤tAction, ¤tFeedback](__attribute__((unused)) const rclcpp_action::GoalUUID goalUuid, const MovementGoalPtr &movementGoal) {
|
||||||
rosMutex.lock();
|
rosMutex.lock();
|
||||||
if (currentFeedback.state == IDLE) {
|
if (currentFeedback.state == IDLE) {
|
||||||
std::cout << "Accepting Movement..." << std::endl;
|
std::cout << "Accepting..." << std::endl;
|
||||||
|
|
||||||
currentAction.target = movementGoal->target;
|
currentAction.target = movementGoal->target;
|
||||||
currentAction.animationSpeed = movementGoal->animation_distance;
|
currentAction.animationSpeed = movementGoal->animation_distance;
|
||||||
@ -175,7 +169,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
|
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Rejecting Movement..." << std::endl;
|
std::cout << "Rejecting..." << std::endl;
|
||||||
rosMutex.unlock();
|
rosMutex.unlock();
|
||||||
return rclcpp_action::GoalResponse::REJECT;
|
return rclcpp_action::GoalResponse::REJECT;
|
||||||
}
|
}
|
||||||
@ -185,11 +179,9 @@ int main(int argc, char **argv) {
|
|||||||
return rclcpp_action::CancelResponse::REJECT;
|
return rclcpp_action::CancelResponse::REJECT;
|
||||||
} else {
|
} else {
|
||||||
rosMutex.lock();
|
rosMutex.lock();
|
||||||
std::cout << "Cancelling Movement..." << std::endl;
|
|
||||||
sendAction(actionQueue, &cancelAction);
|
sendAction(actionQueue, &cancelAction);
|
||||||
|
|
||||||
waitForState(¤tFeedback, IDLE);
|
waitForState(¤tFeedback, IDLE);
|
||||||
std::cout << "Cancelled Movement..." << std::endl;
|
|
||||||
rosMutex.unlock();
|
rosMutex.unlock();
|
||||||
|
|
||||||
return rclcpp_action::CancelResponse::ACCEPT;
|
return rclcpp_action::CancelResponse::ACCEPT;
|
||||||
|
|||||||
4
test.sh
4
test.sh
@ -1,2 +1,2 @@
|
|||||||
ros2 action send_goal /ActorPlugin/animation ign_actor_plugin_msgs/action/Animation "{animation_name: 'standing_walk', animation_speed: 1.0}"
|
ros2 action send_goal /ActorPlugin/animation ign_actor_plugin_msgs/action/Animation "{animation_name: 'walk', animation_speed: 1.0}"
|
||||||
ros2 action send_goal /ActorPlugin/movement ros_actor_action_server_msgs/action/Movement '{animation_name: "standing_walk", animation_speed: 1.0, animation_distance: 1.5, target: {orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}, position: {x: 2.0, y: 0.0, z: 0.0}}}'
|
ros2 action send_goal /ActorPlugin/movement ros_actor_action_server_msgs/action/Movement '{animation_name: "walk", animation_speed: 1.0, animation_distance: 1.5, target: {orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}, position: {x: 2.0, y: 0.0, z: 0.0}}}'
|
||||||
Loading…
x
Reference in New Issue
Block a user