diff --git a/core/src/solvers/cartesian_path.cpp b/core/src/solvers/cartesian_path.cpp index d247831a3..e3140f9d7 100644 --- a/core/src/solvers/cartesian_path.cpp +++ b/core/src/solvers/cartesian_path.cpp @@ -41,6 +41,7 @@ #include #include +#include #include using namespace trajectory_processing; @@ -56,6 +57,8 @@ CartesianPath::CartesianPath() { p.declare("step_size", 0.01, "step size between consecutive waypoints"); p.declare("jump_threshold", 1.5, "acceptable fraction of mean joint motion per step"); p.declare("min_fraction", 1.0, "fraction of motion required for success"); + p.declare("kinematics_options", kinematics::KinematicsQueryOptions(), + "KinematicsQueryOptions to pass to CartesianInterpolator"); } void CartesianPath::init(const core::RobotModelConstPtr& /*robot_model*/) {} @@ -96,7 +99,8 @@ bool CartesianPath::plan(const planning_scene::PlanningSceneConstPtr& from, cons double achieved_fraction = moveit::core::CartesianInterpolator::computeCartesianPath( &(sandbox_scene->getCurrentStateNonConst()), jmg, trajectory, &link, target, true, moveit::core::MaxEEFStep(props.get("step_size")), - moveit::core::JumpThreshold(props.get("jump_threshold")), is_valid); + moveit::core::JumpThreshold(props.get("jump_threshold")), is_valid, + props.get("kinematics_options")); assert(!trajectory.empty()); // there should be at least the start state result = std::make_shared(sandbox_scene->getRobotModel(), jmg); diff --git a/core/src/task.cpp b/core/src/task.cpp index 81aca0f30..5290c34ca 100644 --- a/core/src/task.cpp +++ b/core/src/task.cpp @@ -79,10 +79,12 @@ TaskPrivate::TaskPrivate(Task* me, const std::string& ns) TaskPrivate& TaskPrivate::operator=(TaskPrivate&& other) { this->WrapperBasePrivate::operator=(std::move(other)); ns_ = std::move(other.ns_); - introspection_ = std::move(other.introspection_); robot_model_ = std::move(other.robot_model_); robot_model_loader_ = std::move(other.robot_model_loader_); task_cbs_ = std::move(other.task_cbs_); + // Ensure same introspection status, but keep the existing introspection instance, + // which stores this task pointer and includes it in its task_id_ + static_cast(me_)->enableIntrospection(static_cast(other.introspection_)); return *this; } @@ -211,17 +213,17 @@ void Task::init() { stages()->pimpl()->resolveInterface(InterfaceFlags({ GENERATE })); // provide introspection instance to all stages - impl->setIntrospection(impl->introspection_.get()); + auto* introspection = impl->introspection_.get(); impl->traverseStages( - [impl](Stage& stage, int /*depth*/) { - stage.pimpl()->setIntrospection(impl->introspection_.get()); + [introspection](Stage& stage, int /*depth*/) { + stage.pimpl()->setIntrospection(introspection); return true; }, 1, UINT_MAX); // first time publish task - if (impl->introspection_) - impl->introspection_->publishTaskDescription(); + if (introspection) + introspection->publishTaskDescription(); } bool Task::canCompute() const { diff --git a/core/test/test_move_to.cpp b/core/test/test_move_to.cpp index fd7dabb9a..8799cec05 100644 --- a/core/test/test_move_to.cpp +++ b/core/test/test_move_to.cpp @@ -1,4 +1,5 @@ #include "models.h" +#include "stage_mockups.h" #include #include @@ -156,6 +157,33 @@ TEST_F(PandaMoveTo, poseIKFrameAttachedSubframeTarget) { EXPECT_ONE_SOLUTION; } +// https://github.com/ros-planning/moveit_task_constructor/pull/371#issuecomment-1151630657 +TEST(Task, taskMoveConstructor) { + auto create_task = [] { + moveit::core::RobotModelConstPtr robot_model = getModel(); + Task t("first"); + t.setRobotModel(robot_model); + auto ref = new stages::FixedState("fixed"); + auto scene = std::make_shared(t.getRobotModel()); + ref->setState(scene); + + t.add(Stage::pointer(ref)); + t.add(std::make_unique()); + t.add(std::make_unique(ref)); + return t; + }; + + Task t; + t = create_task(); + + try { + t.init(); + EXPECT_TRUE(t.plan(1)); + } catch (const InitStageException& e) { + ADD_FAILURE() << "InitStageException:" << std::endl << e << t; + } +} + int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); rclcpp::init(argc, argv);