@小小明 chatgpt 答案
在类中使用MoveGroupInterface需要对参数进行适当的传递。可以使用类成员变量 shared_from_this() 函数获取当前对象的 std::shared_ptr,然后将其作为参数传递给 MoveGroupInterface 构造函数。以下是修改后的代码示例:

class TestMoveGroupInterface : public rclcpp::Node { public: TestMoveGroupInterface() : Node( "hello_moveit", rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true)) { // Create the MoveIt MoveGroup Interface move_interface_ = std::make_shared<moveit::planning_interface::MoveGroupInterface>( shared_from_this(), "panda_arm"); } private: std::shared_ptr<moveit::planning_interface::MoveGroupInterface> move_interface_; };

在构造函数中,使用 shared_from_this() 函数获取当前对象的 std::shared_ptr,然后通过 std::make_shared 创建 move_interface_ 对象。这样就能正确地传递当前节点对象的指针给 MoveGroupInterface 构造函数,以完成初始化。