forked from PickNikRobotics/moveit_pro_empty_ws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'src/example_behaviors/' changes from d1451e3..b360dc0
b360dc0 Merge commit '7e8c6066177e2fd16ea46cfb16d8c207e17fd929' a71ffeb fixed build and test for example behaviors (#39) 72ad640 Sam naming (#38) 46a17ce Sync 6.5 to main (#37) d41f38d Add example SAM 2 behavior and objective (#23) f6ac548 Sync V6.5 to main (#29) e932e45 Merge branch 'main' into pr-update-to-make-ports-explicit 6a14c44 Fix depend of moveit_studio_behavior 1416547 version bump 5f6056a formatting a06f504 pre-commit formatting 5bfeaa5 Moving registration behaviors 93dd16f Added mtc to jtc converter git-subtree-dir: src/example_behaviors git-subtree-split: b360dc0970f6dbe4b633cb33edb9ef75042f00d7
- Loading branch information
Showing
41 changed files
with
1,749 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
objectives: | ||
behavior_loader_plugins: | ||
example_behaviors: | ||
- "example_behaviors::ExampleBehaviorsBehaviorsLoader" | ||
- "example_behaviors::ExampleBehaviorsLoader" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<library path="example_behaviors"> | ||
<class | ||
type="example_behaviors::ExampleBehaviorsBehaviorsLoader" | ||
type="example_behaviors::ExampleBehaviorsLoader" | ||
base_class_type="moveit_studio::behaviors::SharedResourcesNodeLoaderBase" | ||
/> | ||
</library> |
49 changes: 49 additions & 0 deletions
49
include/example_behaviors/convert_mtc_solution_to_joint_trajectory.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <Eigen/Core> | ||
#include <behaviortree_cpp/action_node.h> | ||
#include <behaviortree_cpp/bt_factory.h> | ||
#include <moveit/robot_model_loader/robot_model_loader.h> | ||
#include <moveit_msgs/msg/robot_trajectory.hpp> | ||
#include <moveit_studio_behavior/utils/trajectory_utils.hpp> | ||
#include <moveit_studio_behavior_interface/behavior_context.hpp> | ||
#include <moveit_studio_behavior_interface/check_for_error.hpp> | ||
#include <moveit_studio_behavior_interface/shared_resources_node.hpp> | ||
#include <moveit_task_constructor_msgs/msg/solution.hpp> | ||
#include <spdlog/spdlog.h> | ||
#include <trajectory_msgs/msg/joint_trajectory.hpp> | ||
#include <yaml-cpp/yaml.h> | ||
|
||
namespace example_behaviors | ||
{ | ||
/** | ||
* @brief Converts a MoveIt Task Constructor Solution into a JointTrajectory. | ||
* | ||
* @details | ||
* | Data Port Name | Port Type | Object Type | | ||
* | ----------------- |---------------|---------------------------------------------------------| | ||
* | solution | Input | moveit_task_constructor_msgs::msg::Solution | | ||
* | joint_group | Input | std::string | | ||
* | velocity_scaling_factor | Input | double | | ||
* | acceleration_scaling_factor | Input | double | | ||
* | sampling_rate | Input | int | | ||
* | joint_trajectory | Output | trajectory_msgs::msg::JointTrajectory | | ||
*/ | ||
class ConvertMtcSolutionToJointTrajectory final : public moveit_studio::behaviors::SharedResourcesNode<BT::SyncActionNode> | ||
{ | ||
public: | ||
ConvertMtcSolutionToJointTrajectory(const std::string& name, const BT::NodeConfiguration& config, | ||
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources); | ||
|
||
static BT::PortsList providedPorts(); | ||
|
||
static BT::KeyValueVector metadata(); | ||
|
||
BT::NodeStatus tick() override; | ||
|
||
private: | ||
std::unique_ptr<robot_model_loader::RobotModelLoader> robot_model_loader_; | ||
|
||
const std::vector<Eigen::VectorXd>& extractJointPositions(const moveit_task_constructor_msgs::msg::Solution& solution); | ||
}; | ||
} // namespace example_behaviors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
include/example_behaviors/example_convert_mtc_solution_to_joint_trajectory.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <Eigen/Core> | ||
#include <behaviortree_cpp/action_node.h> | ||
#include <behaviortree_cpp/bt_factory.h> | ||
#include <moveit/robot_model_loader/robot_model_loader.h> | ||
#include <moveit_msgs/msg/robot_trajectory.hpp> | ||
#include <moveit_studio_behavior/utils/trajectory_utils.hpp> | ||
#include <moveit_studio_behavior_interface/behavior_context.hpp> | ||
#include <moveit_studio_behavior_interface/check_for_error.hpp> | ||
#include <moveit_studio_behavior_interface/shared_resources_node.hpp> | ||
#include <moveit_task_constructor_msgs/msg/solution.hpp> | ||
#include <spdlog/spdlog.h> | ||
#include <trajectory_msgs/msg/joint_trajectory.hpp> | ||
#include <yaml-cpp/yaml.h> | ||
|
||
namespace example_behaviors | ||
{ | ||
/** | ||
* @brief Converts a MoveIt Task Constructor Solution into a JointTrajectory. | ||
* | ||
* @details | ||
* | Data Port Name | Port Type | Object Type | | ||
* | ----------------- |---------------|---------------------------------------------------------| | ||
* | solution | Input | moveit_task_constructor_msgs::msg::Solution | | ||
* | joint_group | Input | std::string | | ||
* | velocity_scaling_factor | Input | double | | ||
* | acceleration_scaling_factor | Input | double | | ||
* | sampling_rate | Input | int | | ||
* | joint_trajectory | Output | trajectory_msgs::msg::JointTrajectory | | ||
*/ | ||
class ExampleConvertMtcSolutionToJointTrajectory final : public moveit_studio::behaviors::SharedResourcesNode<BT::SyncActionNode> | ||
{ | ||
public: | ||
ExampleConvertMtcSolutionToJointTrajectory(const std::string& name, const BT::NodeConfiguration& config, | ||
const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources); | ||
|
||
static BT::PortsList providedPorts(); | ||
|
||
static BT::KeyValueVector metadata(); | ||
|
||
BT::NodeStatus tick() override; | ||
|
||
private: | ||
std::unique_ptr<robot_model_loader::RobotModelLoader> robot_model_loader_; | ||
|
||
const std::vector<Eigen::VectorXd>& extractJointPositions(const moveit_task_constructor_msgs::msg::Solution& solution); | ||
}; | ||
} // namespace example_behaviors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#pragma once | ||
|
||
#include <behaviortree_cpp/action_node.h> | ||
|
||
// This header includes the SharedResourcesNode type | ||
#include <moveit_studio_behavior_interface/shared_resources_node.hpp> | ||
#include <moveit_studio_behavior_interface/async_behavior_base.hpp> | ||
|
||
|
||
namespace example_behaviors | ||
{ | ||
/** | ||
* @brief TODO(...) | ||
*/ | ||
class ExampleNDTRegistration : public moveit_studio::behaviors::AsyncBehaviorBase | ||
{ | ||
public: | ||
/** | ||
* @brief Constructor for the behavior. | ||
* @param name The name of a particular instance of this Behavior. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree. | ||
* @param shared_resources A shared_ptr to a BehaviorContext that is shared among all SharedResourcesNode Behaviors in the behavior tree. This BehaviorContext is owned by the Studio Agent's ObjectiveServerNode. | ||
* @param config This contains runtime configuration info for this Behavior, such as the mapping between the Behavior's data ports on the behavior tree's blackboard. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree. | ||
* @details An important limitation is that the members of the base Behavior class are not instantiated until after the initialize() function is called, so these classes should not be used within the constructor. | ||
*/ | ||
ExampleNDTRegistration(const std::string& name, const BT::NodeConfiguration& config, const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources); | ||
|
||
/** | ||
* @brief Implementation of the required providedPorts() function for the Behavior. | ||
* @details The BehaviorTree.CPP library requires that Behaviors must implement a static function named providedPorts() which defines their input and output ports. If the Behavior does not use any ports, this function must return an empty BT::PortsList. | ||
* This function returns a list of ports with their names and port info, which is used internally by the behavior tree. | ||
* @return See ndt_registration.cpp for port list and description. | ||
*/ | ||
static BT::PortsList providedPorts(); | ||
|
||
/** | ||
* @brief Implementation of the metadata() function for displaying metadata, such as Behavior description and | ||
* subcategory, in the MoveIt Studio Developer Tool. | ||
* @return A BT::KeyValueVector containing the Behavior metadata. | ||
*/ | ||
static BT::KeyValueVector metadata(); | ||
|
||
protected: | ||
tl::expected<bool, std::string> doWork() override; | ||
|
||
private: | ||
/** @brief Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member */ | ||
std::shared_future<tl::expected<bool, std::string>>& getFuture() override | ||
{ | ||
return future_; | ||
} | ||
|
||
/** @brief Classes derived from AsyncBehaviorBase must have this shared_future as a class member */ | ||
std::shared_future<tl::expected<bool, std::string>> future_; | ||
}; | ||
} // namespace example_behaviors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#pragma once | ||
|
||
#include <behaviortree_cpp/action_node.h> | ||
|
||
// This header includes the SharedResourcesNode type | ||
#include <moveit_studio_behavior_interface/shared_resources_node.hpp> | ||
#include <moveit_studio_behavior_interface/async_behavior_base.hpp> | ||
|
||
|
||
namespace example_behaviors | ||
{ | ||
/** | ||
* @brief TODO(...) | ||
*/ | ||
class ExampleRANSACRegistration : public moveit_studio::behaviors::AsyncBehaviorBase | ||
{ | ||
public: | ||
/** | ||
* @brief Constructor for the behavior. | ||
* @param name The name of a particular instance of this Behavior. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree. | ||
* @param shared_resources A shared_ptr to a BehaviorContext that is shared among all SharedResourcesNode Behaviors in the behavior tree. This BehaviorContext is owned by the Studio Agent's ObjectiveServerNode. | ||
* @param config This contains runtime configuration info for this Behavior, such as the mapping between the Behavior's data ports on the behavior tree's blackboard. This will be set by the behavior tree factory when this Behavior is created within a new behavior tree. | ||
* @details An important limitation is that the members of the base Behavior class are not instantiated until after the initialize() function is called, so these classes should not be used within the constructor. | ||
*/ | ||
ExampleRANSACRegistration(const std::string& name, const BT::NodeConfiguration& config, const std::shared_ptr<moveit_studio::behaviors::BehaviorContext>& shared_resources); | ||
|
||
/** | ||
* @brief Implementation of the required providedPorts() function for the Behavior. | ||
* @details The BehaviorTree.CPP library requires that Behaviors must implement a static function named providedPorts() which defines their input and output ports. If the Behavior does not use any ports, this function must return an empty BT::PortsList. | ||
* This function returns a list of ports with their names and port info, which is used internally by the behavior tree. | ||
* @return See ransac_registration.cpp for port list and description. | ||
*/ | ||
static BT::PortsList providedPorts(); | ||
|
||
/** | ||
* @brief Implementation of the metadata() function for displaying metadata, such as Behavior description and | ||
* subcategory, in the MoveIt Studio Developer Tool. | ||
* @return A BT::KeyValueVector containing the Behavior metadata. | ||
*/ | ||
static BT::KeyValueVector metadata(); | ||
|
||
protected: | ||
tl::expected<bool, std::string> doWork() override; | ||
|
||
private: | ||
/** @brief Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member */ | ||
std::shared_future<tl::expected<bool, std::string>>& getFuture() override | ||
{ | ||
return future_; | ||
} | ||
|
||
/** @brief Classes derived from AsyncBehaviorBase must have this shared_future as a class member */ | ||
std::shared_future<tl::expected<bool, std::string>> future_; | ||
}; | ||
} // namespace example_behaviors |
Oops, something went wrong.