小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
Moveit2教程中,无法通过点击RvizVisualGui里的next使机械臂执行规划的路径
-
Moveit2的官方教程里的Visualizing In RViz部分
这一部分的最后应该可以通过点击两下RvizVisualGui里面的Next分别让Moveit执行Planning和Execut两个部分
但是我现在只能Planning,怎么点击next都没用
就像这样
程序代码
#include <memory> #include <thread> // <---- add this to the set of includes at the top #include <rclcpp/rclcpp.hpp> #include <moveit/move_group_interface/move_group_interface.h> #include <moveit_visual_tools/moveit_visual_tools.h> int main(int argc, char *argv[]) { // Initialize ROS and create the Node rclcpp::init(argc,argv); auto const node = std::make_shared<rclcpp::Node>( "hello_moveit", rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true) ); // Create a ROS logger auto const logger = rclcpp::get_logger("hello_moveit"); // We spin up a SingleThreadedExecutor so MoveItVisualTools interact with ROS rclcpp::executors::SingleThreadedExecutor executor; executor.add_node(node); auto spinner = std::thread([&executor]() { executor.spin(); }); // Create the MoveIt MoveGroup Interface using moveit::planning_interface::MoveGroupInterface; auto move_group_interface = MoveGroupInterface(node, "panda_arm"); // Construct and initialize MoveItVisualTools auto moveit_visual_tools = moveit_visual_tools::MoveItVisualTools{ node, "panda_link0", rviz_visual_tools::RVIZ_MARKER_TOPIC, move_group_interface.getRobotModel()}; moveit_visual_tools.deleteAllMarkers(); moveit_visual_tools.loadRemoteControl(); // Create a closures for visualization auto const draw_title = [&moveit_visual_tools](auto text) { auto const text_pose = [] { auto msg = Eigen::Isometry3d::Identity(); msg.translation().z() = 1.0; return msg; }(); moveit_visual_tools.publishText(text_pose, text, rviz_visual_tools::WHITE, rviz_visual_tools::XLARGE); }; auto const prompt = [&moveit_visual_tools](auto text) { moveit_visual_tools.prompt(text); }; auto const draw_trajectory_tool_path = [&moveit_visual_tools, jmg = move_group_interface.getRobotModel()->getJointModelGroup( "panda_arm")](auto const trajectory) { moveit_visual_tools.publishTrajectoryLine(trajectory, jmg); }; // Set a target Pose auto const target_pose = []{ geometry_msgs::msg::Pose msg; msg.orientation.w = 1.0; msg.position.x = 0.28; msg.position.y = -0.2; msg.position.z = 0.5; return msg; }(); move_group_interface.setPoseTarget(target_pose); // Create a plan to that target pose prompt("Press 'Next' in the RvizVisualToolsGui window to plan"); draw_title("Planning"); moveit_visual_tools.trigger(); auto const [success, plan] = [&move_group_interface] { moveit::planning_interface::MoveGroupInterface::Plan msg; auto const ok = static_cast<bool>(move_group_interface.plan(msg)); return std::make_pair(ok, msg); }(); // Execute the plan if (success) { draw_trajectory_tool_path(plan.trajectory_); moveit_visual_tools.trigger(); prompt("Press 'Next' in the RvizVisualToolsGui window to execute"); draw_title("Executing"); moveit_visual_tools.trigger(); move_group_interface.execute(plan); } else { draw_title("Planning Failed!"); moveit_visual_tools.trigger(); RCLCPP_ERROR(logger, "Planing failed!"); } // Shutdown ROS rclcpp::shutdown(); draw_title("Planning Failed!"); moveit_visual_tools.trigger(); spinner.join(); // <--- Join the thread before exiting return 0; }
节点 的info
ros2@ros2-virtual-machine:~/ws_moveit2$ ros2 run hello_moveit hello_moveit [INFO] [1661360488.626960032] [moveit_rdf_loader.rdf_loader]: Loaded robot model in 0.0678787 seconds [INFO] [1661360488.628283941] [moveit_robot_model.robot_model]: Loading robot model 'panda'... [WARN] [1661360488.695523433] [moveit_ros.robot_model_loader]: No kinematics plugins defined. Fill and load kinematics.yaml! [INFO] [1661360488.720934001] [move_group_interface]: Ready to take commands for planning group panda_arm. [INFO] [1661360488.724223353] [hello_moveit.remote_control]: RemoteControl Ready. [INFO] [1661360488.725084425] [hello_moveit.remote_control]: Waiting to continue: Press 'Next' in the RvizVisualToolsGui window to plan [INFO] [1661360492.640161451] [hello_moveit.remote_control]: ... continuing [INFO] [1661360492.644604333] [move_group_interface]: MoveGroup action client/server ready seconds [INFO] [1661360488.628283941] [moveit_robot_model.robot_model]: Loading robot model 'panda'... [WARN] [1661360488.695523433] [moveit_ros.robot_model_loader]: No kinematics plugins defined. Fill and load kinematics.yaml! [INFO] [1661360488.720934001] [move_group_interface]: Ready to take commands for planning group panda_arm. [INFO] [1661360488.724223353] [hello_moveit.remote_control]: RemoteControl Ready. [INFO] [1661360488.725084425] [hello_moveit.remote_control]: Waiting to continue: Press 'Next' in the RvizVisualToolsGui window to plan [INFO] [1661360492.640161451] [hello_moveit.remote_control]: ... continuing [INFO] [1661360492.644604333] [move_group_interface]: MoveGroup action client/server ready
RViz的info
[move_group-4] You can start planning now! [move_group-4] [spawner-7] [INFO] [1661360353.318260256] [spawner_panda_arm_controller]: Configured and activated panda_arm_controller [spawner-8] [INFO] [1661360353.327594408] [spawner_panda_hand_controller]: Configured and activated panda_hand_controller [spawner-6] [INFO] [1661360353.383695147] [spawner_joint_state_broadcaster]: Configured and activated joint_state_broadcaster [INFO] [spawner-8]: process has finished cleanly [pid 94207] [INFO] [spawner-7]: process has finished cleanly [pid 94204] [INFO] [spawner-6]: process has finished cleanly [pid 94200] [rviz2-1] [INFO] [1661360354.267672189] [rviz2]: Stereo is NOT SUPPORTED [rviz2-1] [INFO] [1661360354.267899244] [rviz2]: OpenGl version: 4.1 (GLSL 4.1) [rviz2-1] [INFO] [1661360354.351648952] [rviz2]: Stereo is NOT SUPPORTED [rviz2-1] Warning: class_loader.impl: SEVERE WARNING!!! A namespace collision has occurred with plugin factory for class rviz_default_plugins::displays::InteractiveMarkerDisplay. New factory will OVERWRITE existing one. This situation occurs when libraries containing plugins are directly linked against an executable (the one running right now generating this message). Please separate plugins out into their own library or just don't link against the library and use either class_loader::ClassLoader/MultiLibraryClassLoader to open. [rviz2-1] at line 253 in /opt/ros/humble/include/class_loader/class_loader/class_loader_core.hpp [rviz2-1] [ERROR] [1661360357.821614316] [moveit_ros_visualization.motion_planning_frame]: Action server: /recognize_objects not available [rviz2-1] [INFO] [1661360357.873758611] [moveit_rdf_loader.rdf_loader]: Loaded robot model in 0.00513378 seconds [rviz2-1] [INFO] [1661360357.874944292] [moveit_robot_model.robot_model]: Loading robot model 'panda'... [rviz2-1] [WARN] [1661360358.716952499] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic. [rviz2-1] [INFO] [1661360358.751094199] [moveit_rdf_loader.rdf_loader]: Loaded robot model in 0.00200306 seconds [rviz2-1] [INFO] [1661360358.751463280] [moveit_robot_model.robot_model]: Loading robot model 'panda'... [rviz2-1] Link panda_link1 had 1 children [rviz2-1] Link panda_link2 had 1 children [rviz2-1] Link panda_link3 had 1 children [rviz2-1] Link panda_link4 had 1 children [rviz2-1] Link panda_link5 had 1 children [rviz2-1] Link panda_link6 had 1 children [rviz2-1] Link panda_link7 had 1 children [rviz2-1] Link panda_link8 had 1 children [rviz2-1] Link panda_hand had 2 children [rviz2-1] Link panda_leftfinger had 0 children [rviz2-1] Link panda_rightfinger had 0 children [rviz2-1] [INFO] [1661360359.083960168] [moveit_ros.planning_scene_monitor.planning_scene_monitor]: Starting planning scene monitor [rviz2-1] [INFO] [1661360359.097253739] [moveit_ros.planning_scene_monitor.planning_scene_monitor]: Listening to '/monitored_planning_scene' [move_group-4] [INFO] [1661360375.585521251] [moveit_move_group_default_capabilities.move_action_capability]: Received request [move_group-4] [INFO] [1661360375.586967901] [moveit_move_group_default_capabilities.move_action_capability]: executing.. [move_group-4] [INFO] [1661360375.601250081] [moveit_move_group_default_capabilities.move_action_capability]: Planning request received for MoveGroup action. Forwarding to planning pipeline. [move_group-4] [INFO] [1661360375.686041510] [moveit.ompl_planning.model_based_planning_context]: Planner configuration 'panda_arm' will use planner 'geometric::RRTConnect'. Additional configuration parameters will be set when the planner is constructed. [move_group-4] [INFO] [1661360383.336210974] [moveit_move_group_default_capabilities.move_action_capability]: Motion plan was computed successfully. [rviz2-1] [ERROR] [1661360383.348745116] [moveit_rviz_plugin_render_tools.trajectory_visualization]: No robot state or robot model loaded [rviz2-1] [INFO] [1661360435.917535550] [moveit_rdf_loader.rdf_loader]: Loaded robot model in 0.0237417 seconds [rviz2-1] [INFO] [1661360435.917753658] [moveit_robot_model.robot_model]: Loading robot model 'panda'... [rviz2-1] [INFO] [1661360436.272922611] [moveit_ros.planning_scene_monitor.planning_scene_monitor]: Stopping planning scene monitor [rviz2-1] [INFO] [1661360436.344188261] [moveit_rdf_loader.rdf_loader]: Loaded robot model in 0.00450804 seconds [rviz2-1] [INFO] [1661360436.344267960] [moveit_robot_model.robot_model]: Loading robot model 'panda'... [rviz2-1] Link panda_link1 had 1 children [rviz2-1] Link panda_link2 had 1 children [rviz2-1] Link panda_link3 had 1 children [rviz2-1] Link panda_link4 had 1 children [rviz2-1] Link panda_link5 had 1 children [rviz2-1] Link panda_link6 had 1 children [rviz2-1] Link panda_link7 had 1 children [rviz2-1] Link panda_link8 had 1 children [rviz2-1] Link panda_hand had 2 children [rviz2-1] Link panda_leftfinger had 0 children [rviz2-1] Link panda_rightfinger had 0 children [rviz2-1] [INFO] [1661360436.608225858] [moveit_ros.planning_scene_monitor.planning_scene_monitor]: Starting planning scene monitor [rviz2-1] [INFO] [1661360436.611345331] [moveit_ros.planning_scene_monitor.planning_scene_monitor]: Listening to '/monitored_planning_scene' [move_group-4] [INFO] [1661360492.648210808] [moveit_move_group_default_capabilities.move_action_capability]: Received request [move_group-4] [INFO] [1661360492.648641234] [moveit_move_group_default_capabilities.move_action_capability]: executing.. [move_group-4] [INFO] [1661360492.660429954] [moveit_move_group_default_capabilities.move_action_capability]: Planning request received for MoveGroup action. Forwarding to planning pipeline. [move_group-4] [INFO] [1661360492.696150698] [moveit.ompl_planning.model_based_planning_context]: Planner configuration 'panda_arm' will use planner 'geometric::RRTConnect'. Additional configuration parameters will be set when the planner is constructed. [move_group-4] [INFO] [1661360501.549985786] [moveit_move_group_default_capabilities.move_action_capability]: Motion plan was computed successfully. [rviz2-1] [ERROR] [1661360501.551738192] [moveit_rviz_plugin_render_tools.trajectory_visualization]: No robot state or robot model loaded
-
@1206768372 在 Moveit2教程中,无法通过点击RvizVisualGui里的next使机械臂执行规划的路径 中说:
if (success) {
draw_trajectory_tool_path(plan.trajectory_);
moveit_visual_tools.trigger();
prompt("Press 'Next' in the RvizVisualToolsGui window to execute");
draw_title("Executing");
moveit_visual_tools.trigger();
move_group_interface.execute(plan);只有規劃成功後才能進行plan
-
@小鱼 但是在Rviz的info倒数第二行好像说了已经计算成功了诶
-
@小鱼 在 Moveit2教程中,无法通过点击RvizVisualGui里的next使机械臂执行规划的路径 中说:
prompt("Press 'Next' in the RvizVisualToolsGui window to execute");
但是没看到这句话的打印,估计跟这个错误有关系
@1206768372 在 Moveit2教程中,无法通过点击RvizVisualGui里的next使机械臂执行规划的路径 中说:
[rviz2-1] [ERROR] [1661360501.551738192] [moveit_rviz_plugin_render_tools.trajectory_visualization]: No robot state or robot model loaded
-
@小鱼 问题终于解决了 Moveit2的官方教程有些问题。
首先得先把原本默认使用的Fast DDS改成 Cyclone DDS
sudo apt install ros-rolling-rmw-cyclonedds-cpp
或者跟着这个
然后重启终端
接着再打开hello_moveit.cpp
把这一段初始化提到新建一个Thread之前
// Create the MoveIt MoveGroup Interface using moveit::planning_interface::MoveGroupInterface; auto move_group_interface = MoveGroupInterface(node, "panda_arm"); // We spin up a SingleThreadedExecutor so MoveItVisualTools interact with ROS rclcpp::executors::SingleThreadedExecutor executor; executor.add_node(node); auto spinner = std::thread([&executor]() { executor.spin(); });
接着重新编译 就可以解决了!
GitHub上的解决办法在这
-
-