それを移動!チュートリアル、MoveIt!チュートリアル-デモ



Moveit Tutorials Moveit



それを移動!チュートリアル 、Gihubアドレス: https://github.com/ros-planning/moveit_tutorials/blob/kinetic-devel/index.rst

それを移動! RVizプラグインチュートリアル

ROSビジュアライザー(RViz)



pr2_moveit_configパッケージをダウンロードして、コンパイルします

git clone https://github.com/davetcoleman/pr2_moveit_config.git

デモファイル構成プラグインを開始します



roslaunch pr2_moveit_config demo.launch

起動時にpr2_descriptionパッケージが見つからなかったため、ダウンロードしてインストールします

sudo apt-get install ros-kinetic-pr2-description

あなたはrvizを開くことができます、

ここに写真の説明を書いてください



demo.launch のコンテンツは次のとおりです(自動的に生成されるようです):

<launch> <arg name='db' default='false' /> <arg name='db_path' default='$(find pr2_moveit_config)/default_warehouse_mongo_db' /> <arg name='debug' default='false' /> <include file='$(find pr2_moveit_config)/launch/planning_context.launch'> <arg name='load_robot_description' value='true'/> include> <node pkg='tf' type='static_transform_publisher' name='virtual_joint_broadcaster_0' args='0 0 0 0 0 0 odom_combined base_footprint 100' /> <node name='joint_state_publisher' pkg='joint_state_publisher' type='joint_state_publisher'> <param name='/use_gui' value='false'/> <rosparam param='/source_list'>[/move_group/fake_controller_joint_states]rosparam> node> <node name='robot_state_publisher' pkg='robot_state_publisher' type='robot_state_publisher' respawn='true' output='screen' /> <include file='$(find pr2_moveit_config)/launch/move_group.launch'> <arg name='allow_trajectory_execution' value='true'/> <arg name='fake_execution' value='true'/> <arg name='info' value='true'/> <arg name='debug' value='$(arg debug)'/> include> <include file='$(find pr2_moveit_config)/launch/moveit_rviz.launch'> <arg name='config' value='true'/> <arg name='debug' value='$(arg debug)'/> include> <include file='$(find pr2_moveit_config)/launch/default_warehouse_db.launch' if='$(arg db)'> <arg name='moveit_warehouse_database_path' value='$(arg db_path)'/> include> launch>

モーションプランニングプラグインは、最初のオープニングに追加する必要があります。
ここに写真の説明を書いてください
[表示]サブウィンドウの下の[グローバルオプション]タブで、固定座標系をodom_combinedとして選択します。
企画シーントピック 'planning_scene'に設定します。
企画依頼 で、変更します 企画グループ 'right_arm'として。
設定 軌道トピック '/ move_group / display_planned_pa​​th'として。
インタラクティブマーカーサイズ に設定 0.2〜0.5 、要するに、ゼロにならないでください。

以下のインタラクションを開始します
以下に示すように、対話ツールを追加します。ご覧のとおり、緑色の腕は開始ポーズに対応し、黄色の腕はターゲットポーズに対応します。
ここに写真の説明を書いてください
ここに写真の説明を書いてください
目標点を別の腕の近くに移動すると、衝突が発生し、衝突部分が赤くなります。この時点での計画は失敗します。
ここに写真の説明を書いてください
パネルで「MotionPlanning-Slider」を開いて、計画のすべてのステップを観察します
ここに写真の説明を書いてください

グループインターフェイスチュートリアルの移動

MoveIt!のユーザーインターフェイスです MoveGroup クラス。関節や目標位置の設定、モーションプランの作成、ロボットの移動、障害物の追加など、ユーザーが頻繁に使用するさまざまな機能を提供します。このインターフェイスは、ROSトピック、サービス、およびアクションを介して通信します。
あると言われています Youtube 将来的にYouKuにアップロードしたかったのですが、実はこんな感じです
ここに写真の説明を書いてください

ワークスペースを作成する

rosdep update sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install python-wstool python-catkin-tools clang-format-3.8

/ src 流れ落ちる

wstool init . wstool merge https://raw.githubusercontent.com/ros-planning/moveit/kinetic-devel/moveit.rosinstall wstool update rosdep install -y --from-paths . --ignore-src --rosdistro kinetic cd .. catkin config --extend /opt/ros/kinetic --cmake-args -DCMAKE_BUILD_TYPE=Release catkin_make

ソースコードをダウンロードする

git clone https://github.com/ros-planning/moveit_tutorials.git git clone https://github.com/PR2/pr2_common.git -b kinetic-devel git clone https://github.com/davetcoleman/pr2_moveit_config.git

関連する依存関係をインストールしてからコンパイルします

rosdep install --from-paths . --ignore-src --rosdistro kinetic cd ~/ws_moveit catkin config --extend /opt/ros/kinetic --cmake-args -DCMAKE_BUILD_TYPE=Release catkin_make

rvizを開始します

roslaunch pr2_moveit_config demo.launch

新しいターミナルでデモを開始します

roslaunch moveit_tutorials move_group_interface_tutorial.launch

起動後のページはこんな感じ
ここに写真の説明を書いてください
スタンドアロン ボタンまたは押す N 、次のデモンストレーションを見ることができます。
1.ロボットは、右腕を右前のポーズゴールに移動します。
ここに写真の説明を書いてください
2.ロボットは、右腕を右側の関節ゴールに移動します。
ここに写真の説明を書いてください
3.ロボットは、エンドエフェクタのレベルを維持しながら、右腕を新しいポーズの目標に戻します。
ここに写真の説明を書いてください
4.ロボットは、右腕を目的のデカルトパス(上+前方、左、下+後の三角形)に沿って移動します。
ここに写真の説明を書いてください
5.ボックスオブジェクトが右腕の右側の環境に追加されます。ロボットは右腕をポーズゴールに移動し、ボックスとの衝突を回避します。
ここに写真の説明を書いてください
6.オブジェクトが手首に取り付けられます(色が紫/オレンジ/緑に変わります)。
オブジェクトが手首から外れます(色が緑に戻ります)。
オブジェクトが環境から削除されます。
ここに写真の説明を書いてください
7.ロボットは、両方の腕を2つの異なるポーズゴールに同時に移動します。
ここに写真の説明を書いてください

デモの説明

スタートアップファイルは今このパスにあります pr2_tutorials / planning 、ファイルの内容は

<launch> <node name='move_group_interface_tutorial' pkg='moveit_tutorials' type='move_group_interface_tutorial' respawn='false' //Reset the attribute, if true, when the node stops,roslaunchThe node will be restarted. output='screen'> //Display the standard output on the screen instead of recording to the log file. node> launch>

あなたはそれが始まったことを見ることができます move_group_interface_tutorial ノードのタイプ。

/* Author: Sachin Chitta, Dave Coleman */ #include #include #include #include #include #include #include int main(int argc, char **argv) { ros::init(argc, argv, 'move_group_interface_tutorial')//Initialize the node and set the node name ros::NodeHandle node_handle//Process handler, which allows us to interact with the environment ros::AsyncSpinner spinner(1)//ROS multi-thread subscription news, a thread is opened here spinner.start()//Thread start // BEGIN_TUTORIAL // // Setup // ^^^^^ /*MoveIt! Operate on a group of joints called 'planning groups' and store them in an object called JointModelGroup. In the whole MoveIt! The terms 'planning group' and 'joint model group' can be used interchangeably. */ static const std::string PLANNING_GROUP = 'right_arm' /*MoveGroup class can be easily set with the planning group you want to plan and control */ moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP) // moveit:planning_interface:`PlanningSceneInterface` // This class is used to add/remove collision detection obstacles in our virtual environment moveit::planning_interface::PlanningSceneInterface planning_scene_interface // Raw pointers are often used to refer to plan groups to improve performance. const robot_state::JointModelGroup *joint_model_group = move_group.getCurrentState()->getJointModelGroup(PLANNING_GROUP) // Visualization // ^^^^^^^^^^^^^ //MoveItVisualTools package provides the ability to visualize many obstacles, robots and trajectories in rviz, //There are also debugging tools for step-by-step self-checking like scripts namespace rvt = rviz_visual_tools moveit_visual_tools::MoveItVisualTools visual_tools('odom_combined') visual_tools.deleteAllMarkers() // Remote control is a self-checking tool that allows users to browse advanced scripts through buttons and keyboard shortcuts in Rviz visual_tools.loadRemoteControl() // Rviz provides many types of markers, here we mainly use text, cylinders, and spheres Eigen::Affine3d text_pose = Eigen::Affine3d::Identity() text_pose.translation().z() = 1.75 // above head of PR2, the position of the text is placed on the head of PR2 visual_tools.publishText(text_pose, 'MoveGroupInterface Demo', rvt::WHITE, rvt::XLARGE) // Batch publishing is used to reduce the number of messages sent to Rviz to achieve large-scale visualization visual_tools.trigger() // Getting Basic Information // ^^^^^^^^^^^^^^^^^^^^^^^^^ //We can print the name of the reference coordinate system of this robot. ROS_INFO_NAMED('tutorial', 'Reference frame: %s', move_group.getPlanningFrame().c_str()) // We can also print the name of the end effector link of this group. ROS_INFO_NAMED('tutorial', 'End effector link: %s', move_group.getEndEffectorLink().c_str()) // Planning to a Pose goal // ^^^^^^^^^^^^^^^^^^^^^^^ // We can make an action for this group to make it the posture required for the end. geometry_msgs::Pose target_pose1 target_pose1.orientation.w = 1.0 target_pose1.position.x = 0.28 target_pose1.position.y = -0.7 target_pose1.position.z = 1.0 move_group.setPoseTarget(target_pose1) // Now, we call the planner to calculate the plan and visualize it. Please note that we are only planning, not requiring move_group to actually move the robot. // Hahahaha, call... I remembered the Tucao conference moveit::planning_interface::MoveGroupInterface::Plan my_plan bool success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS) ROS_INFO_NAMED('tutorial', 'Visualizing plan 1 (pose goal) %s', success ? '' : 'FAILED') // Visualizing plans // ^^^^^^^^^^^^^^^^^ // We can also visualize this plan in Rviz with a marked line. ROS_INFO_NAMED('tutorial', 'Visualizing plan 1 as trajectory line') visual_tools.publishAxisLabeled(target_pose1, 'pose1') visual_tools.publishText(text_pose, 'Pose Goal', rvt::WHITE, rvt::XLARGE) visual_tools.publishTrajectoryLine(my_plan.trajectory_, joint_model_group) visual_tools.trigger() visual_tools.prompt('next step') // Moving to a pose goal // ^^^^^^^^^^^^^^^^^^^^^ //Except that we now use the move() function, moving to a pose target is similar to the above steps. //Please note that the pose target we set before is still active, so the robot will try to move to that target. //We will not use this function in this tutorial because it is a blocking function and requires a controller to be active and report success when executing the trajectory. /* Uncomment the following line when actually controlling the robot */ /* move_group.move() */ // Planning to a joint-space goal // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //Motion planning in joint space. This will replace the attitude target we set above. // First, we will create a pointer that references the current state of the robot. // RobotState is an object that contains all current position/speed/acceleration data. moveit::core::RobotStatePtr current_state = move_group.getCurrentState() // Next get the current joint value set of the group. std::vector<double> joint_group_positions current_state->copyJointGroupPositions(joint_model_group, joint_group_positions) // Now, let's modify one of the joints, plan to the new joint space target and visualize the plan. joint_group_positions[0] = -1.0 // radians move_group.setJointValueTarget(joint_group_positions) success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS) ROS_INFO_NAMED('tutorial', 'Visualizing plan 2 (joint space goal) %s', success ? '' : 'FAILED') // Visualize the plan in Rviz visual_tools.deleteAllMarkers() visual_tools.publishText(text_pose, 'Joint Space Goal', rvt::WHITE, rvt::XLARGE) visual_tools.publishTrajectoryLine(my_plan.trajectory_, joint_model_group) visual_tools.trigger() visual_tools.prompt('next step') // Planning with Path Constraints // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //You can easily specify path constraints for the connecting rod on the robot. //Let's specify path constraints and pose targets for our group. //First define the path constraints. moveit_msgs::OrientationConstraint ocm ocm.link_name = 'r_wrist_roll_link' ocm.header.frame_id = 'base_link' ocm.orientation.w = 1.0 ocm.absolute_x_axis_tolerance = 0.1 ocm.absolute_y_axis_tolerance = 0.1 ocm.absolute_z_axis_tolerance = 0.1 ocm.weight = 1.0 // Now, set it as the path constraint of the group. moveit_msgs::Constraints test_constraints test_constraints.orientation_constraints.push_back(ocm) move_group.setPathConstraints(test_constraints) // We will reuse the old goals we have planned. Please note that this will only work if the current state has met the path constraints. (Obviously the current state does not meet the constraints) // So, we need to set the starting state to a new pose. robot_state::RobotState start_state(*move_group.getCurrentState()) geometry_msgs::Pose start_pose2 start_pose2.orientation.w = 1.0 start_pose2.position.x = 0.55 start_pose2.position.y = -0.05 start_pose2.position.z = 0.8 start_state.setFromIK(joint_model_group, start_pose2) move_group.setStartState(start_state) // Plan according to the new starting position and the original target position move_group.setPoseTarget(target_pose1) // Planning with constraints can be slow, because every sample must call an inverse kinematics solver. // Let's increase the planning time from the default 5 seconds to ensure that the planner has enough time to succeed. move_group.setPlanningTime(10.0) success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS) ROS_INFO_NAMED('tutorial', 'Visualizing plan 3 (constraints) %s', success ? '' : 'FAILED') // Visualize the plan in Rviz visual_tools.deleteAllMarkers() visual_tools.publishAxisLabeled(start_pose2, 'start') visual_tools.publishAxisLabeled(target_pose1, 'goal') visual_tools.publishText(text_pose, 'Constrained Goal', rvt::WHITE, rvt::XLARGE) visual_tools.publishTrajectoryLine(my_plan.trajectory_, joint_model_group) visual_tools.trigger() visual_tools.prompt('next step') //When completing path constraints, be sure to clear the constraints. move_group.clearPathConstraints() // Cartesian Paths // ^^^^^^^^^^^^^^^ // You can directly plan a Cartesian path by specifying a list of end waypoints. Please note that we start with the new start state above. // The initial pose (starting state) does not need to be added to the waypoint list, but adding it can help visualize std::vector waypoints waypoints.push_back(start_pose2) geometry_msgs::Pose target_pose3 = start_pose2 target_pose3.position.z += 0.2 waypoints.push_back(target_pose3) // up target_pose3.position.y -= 0.1 waypoints.push_back(target_pose3) // left target_pose3.position.z -= 0.2 target_pose3.position.y += 0.2 target_pose3.position.x -= 0.2 waypoints.push_back(target_pose3) // down and right // Cartesian movements are often required, such as approaching and retreating grasping movements. // Here, we demonstrate how to reduce the speed of the robot arm by the scaling factor of the maximum speed of each joint. Note that this is not the speed of the final effector. move_group.setMaxVelocityScalingFactor(0.1) // We want to insert a Cartesian path with a resolution of 1 cm, which is why we specify 0.01 as the maximum step in Cartesian translation. // We specify the jump threshold as 0.0, effectively disabling it. // Warning-Disabling the jump threshold when operating real hardware may cause a large number of unpredictable actions on redundant connections, which may be a safety issue moveit_msgs::RobotTrajectory trajectory const double jump_threshold = 0.0 const double eef_step = 0.01 double fraction = move_group.computeCartesianPath(waypoints, eef_step, jump_threshold, trajectory) ROS_INFO_NAMED('tutorial', 'Visualizing plan 4 (cartesian path) (%.2f%% acheived)', fraction * 100.0) // Visualize the plan in Rviz visual_tools.deleteAllMarkers() visual_tools.publishText(text_pose, 'Cartesian Paths', rvt::WHITE, rvt::XLARGE) visual_tools.publishPath(waypoints, rvt::LIME_GREEN, rvt::SMALL) for (std::size_t i = 0 i 'pt' + std::to_string(i), rvt::SMALL)//Display coordinate system visual_tools.trigger() visual_tools.prompt('next step') // Adding/Removing Objects and Attaching/Detaching Objects // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // Define a collision object ROS message. moveit_msgs::CollisionObject collision_object collision_object.header.frame_id = move_group.getPlanningFrame() collision_object.id = 'box1'// The ID of the object is used to identify it. // Define a box to add to the world. shape_msgs::SolidPrimitive primitive primitive.type = primitive.BOX primitive.dimensions.resize(3) primitive.dimensions[0] = 0.4 primitive.dimensions[1] = 0.1 primitive.dimensions[2] = 0.4 //Define the pose for the box (relative to frame_id) geometry_msgs::Pose box_pose box_pose.orientation.w = 1.0 box_pose.position.x = 0.6 box_pose.position.y = -0.4 box_pose.position.z = 1.2 collision_object.primitives.push_back(primitive) collision_object.primitive_poses.push_back(box_pose) collision_object.operation = collision_object.ADD std::vector collision_objects collision_objects.push_back(collision_object) // Now, let's add the collision object to the world ROS_INFO_NAMED('tutorial', 'Add an object into the world') planning_scene_interface.addCollisionObjects(collision_objects) // Show text in Rviz of status visual_tools.publishText(text_pose, 'Add object', rvt::WHITE, rvt::XLARGE) visual_tools.trigger() // Stop for 1s to allow move group to receive and process collision object messages ros::Duration(1.0).sleep() // Now when we plan a trajectory, it will avoid obstacles move_group.setStartState(*move_group.getCurrentState()) move_group.setPoseTarget(target_pose1) success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS) ROS_INFO_NAMED('tutorial', 'Visualizing plan 5 (pose goal move around cuboid) %s', success ? '' : 'FAILED') // Visualize the plan in Rviz visual_tools.deleteAllMarkers() visual_tools.publishText(text_pose, 'Obstacle Goal', rvt::WHITE, rvt::XLARGE) visual_tools.publishTrajectoryLine(my_plan.trajectory_, joint_model_group) visual_tools.trigger() visual_tools.prompt('next step')//Button? // Now, let's attach the collision object to the robot. The colliding object will turn purple, I haven’t learned what to do ROS_INFO_NAMED('tutorial', 'Attach the object to the robot') move_group.attachObject(collision_object.id) // Show text in Rviz of status visual_tools.publishText(text_pose, 'Object attached to robot', rvt::WHITE, rvt::XLARGE) visual_tools.trigger() /* Sleep to allow MoveGroup to recieve and process the attached collision object message */ ros::Duration(1.0).sleep() visual_tools.prompt('next step')//Button? // Now, let's detach the collision object from the robot. ROS_INFO_NAMED('tutorial', 'Detach the object from the robot') move_group.detachObject(collision_object.id) // Show text in Rviz of status visual_tools.publishText(text_pose, 'Object dettached from robot', rvt::WHITE, rvt::XLARGE) visual_tools.trigger() /* Sleep to allow MoveGroup to recieve and process the detach collision object message */ ros::Duration(1.0).sleep() // Now, let's remove the collision object from the world. ROS_INFO_NAMED('tutorial', 'Remove the object from the world') std::vector<std::string> object_ids object_ids.push_back(collision_object.id) planning_scene_interface.removeCollisionObjects(object_ids) // Show text in Rviz of status visual_tools.publishText(text_pose, 'Object removed', rvt::WHITE, rvt::XLARGE) visual_tools.trigger() /* Sleep to give Rviz time to show the object is no longer there.*/ ros::Duration(1.0).sleep() visual_tools.prompt('next step')//Button? // Dual-arm pose goals // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // First define a new team to handle both arms. static const std::string PLANNING_GROUP2 = 'arms' moveit::planning_interface::MoveGroupInterface two_arms_move_group(PLANNING_GROUP2) // Define two independent pose targets, one for each end effector. Please note that we are reusing the goal at the top right two_arms_move_group.setPoseTarget(target_pose1, 'r_wrist_roll_link') geometry_msgs::Pose target_pose4 target_pose4.orientation.w = 1.0 target_pose4.position.x = 0.7 target_pose4.position.y = 0.15 target_pose4.position.z = 1.0 two_arms_move_group.setPoseTarget(target_pose4, 'l_wrist_roll_link') // Now, we can plan and visualize moveit::planning_interface::MoveGroupInterface::Plan two_arms_plan success = (two_arms_move_group.plan(two_arms_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS) ROS_INFO_NAMED('tutorial', 'Visualizing plan 7 (dual arm plan) %s', success ? '' : 'FAILED') // Visualize the plan in Rviz visual_tools.deleteAllMarkers() visual_tools.publishAxisLabeled(target_pose1, 'goal1') visual_tools.publishAxisLabeled(target_pose4, 'goal2') visual_tools.publishText(text_pose, 'Two Arm Goal', rvt::WHITE, rvt::XLARGE) joint_model_group = move_group.getCurrentState()->getJointModelGroup(PLANNING_GROUP2) visual_tools.publishTrajectoryLine(two_arms_plan.trajectory_, joint_model_group) visual_tools.trigger() // END_TUTORIAL ros::shutdown() return 0 }

ここに写真の説明を書いてください