ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Trouble Achieving Dynamic Obstacle Avoidance with MoveIt2 and Octomap

asked 2023-05-16 06:47:32 -0500

angcorcue2 gravatar image

I'm working with a 6 DOF robotic arm in MoveIt2 using ROS 2 Foxy. I'm successfully visualizing the occupancy map of obstacles generated by Octomap in RViz, but I'm facing difficulties in achieving dynamic obstacle avoidance. The map is only updated when the robot is stationary, and if a dynamic obstacle appears in the arm's trajectory during execution, the arm continues its movement without stopping. I've tried enabling the replanning option, but it doesn't seem to address the issue. Could someone please suggest a solution or provide guidance on how to implement dynamic obstacle avoidance in MoveIt2 using Octomap?

My sensors_3d.yaml file is configured as follows:

sensors: ["zed2_handlerbot"]
zed2_handlerbot:
    sensor_plugin: occupancy_map_monitor/PointCloudOctomapUpdater
    point_cloud_topic: /zed2i_filtered_pointcloud
    max_range: 2.0
    point_subsample: 4
    padding_offset: 0.0
    padding_scale: 1.0
    max_update_rate: 2.0
    filtered_cloud_topic: filtered_cloud

My move_group.launch file has the following configuration:

octomap_config = {'octomap_frame': 'zed2i_left_camera_frame', 
                  'octomap_resolution': 0.05,
                  'max_range': 2.0}
run_move_group_node = Node(
        package="moveit_ros_move_group",
        executable="move_group",
        output="screen",
        parameters=[
            robot_description,
            robot_description_semantic,
            robot_description_kinematics,
            robot_description_planning,
            octomap_config,
            octomap_updater_config,
            ompl_planning_pipeline_config,
            trajectory_execution,
            moveit_controllers,
            planning_scene_monitor_parameters,
        ],
        arguments=["__log_level:=debug"],
    )

To perform the moves, I am following the example of moveit_cpp_example as follows:

executor.add_node(move_group_node);
std::thread([&executor]() {executor.spin();}).detach();

static const std::string PLANNING_GROUP = "handlerbot_arm";
moveit::planning_interface::MoveGroupInterface move_group(move_group_node, PLANNING_GROUP);
moveit::planning_interface::PlanningSceneInterface planning_scene_interface;
moveit::planning_interface::MoveGroupInterface::Plan my_plan;


// Raw pointers are frequently used to refer to the planning group for improved performance.
const moveit::core::JointModelGroup * joint_model_group =
  move_group.getCurrentState()->getJointModelGroup(PLANNING_GROUP);



move_group.setGoalOrientationTolerance(0.05); 
move_group.setGoalPositionTolerance(0.05);  
move_group.setPlanningTime(10.0);


geometry_msgs::msg::PoseStamped target_pose1, target_pose2;

std::this_thread::sleep_for(std::chrono::seconds(2));



move_group.setPlannerId("PRMstar");

// ############################################################################################################


move_group.setPoseReferenceFrame(pose_40.header.frame_id);
move_group.setMaxVelocityScalingFactor(0.2);
move_group.setPoseTarget(pose_40,"hand_press");
move_group.plan(my_plan);
move_group.move();
std::this_thread::sleep_for(std::chrono::seconds(2));

Does anyone have any ideas on how I can troubleshoot and resolve this issue?"

edit retag flag offensive close merge delete

Comments

What happens when the arm reaches the obstacle? Does move_group.move() stop the movement and abort, or does the arm continue through the obstacle as if it wasn't there?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-05-16 07:29:34 -0500 )edit

When it encounters an obstacle, it continues as if nothing happened. It collides with it and wipes out everything. Luckily, I'm conducting my tests with cardboard boxes and not real walls...

angcorcue2 gravatar image angcorcue2  ( 2023-05-16 09:22:26 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-17 09:47:28 -0500

Mike Scheutzow gravatar image

I can share a few things I learned about moveit in ros1 - it is likely still the same in ros2, but you'd need to confirm.

  • if you do the plan() and the move() in separate calls, move_group performs collision checking during plan(), but not during the move(). In this case, move() just follows the trajectory plan that was created.

  • When collision checking is done, it is for self-collision and for objects found in the planning_scene. So you have to make sure the planning_scene is populated with your "obstacles".

  • I believe it takes only one call to check a set of arm joint values for (a potential) collision. So maybe you could run a separate thread during the move() that keeps making this call (a few times per second?) This thread would abort the move() if the collision check reports a problem.

  • if the move() is aborted, it's up to your code to handle the replanning.

edit flag offensive delete link more

Comments

Yes, I had read about planning and executing the movement separately and tried it without results.

The main problem I have is that my planning scene only updates octomap when the robot is stopped, during the movement octomap doesn't update the planning scene, I don't know why.

On the other hand, I have tried to add basic objects (cubes) in the planning scene in the middle of a trajectory during its execution and the movement stops! Maybe a possible temporary solution could be to generate collision objects using my pointcloud and add them to the planning scene by hand, but I'm not sure how to do it.

angcorcue2 gravatar image angcorcue2  ( 2023-05-17 10:45:07 -0500 )edit

The main problem I have is that my planning scene only updates octomap when the robot is stopped, during the movement octomap doesn't update the planning scene

Just a guess: are you providing enough spinners for simultaneous callback operation? This use case almost certainly requires a Multi-threaded Executor.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-05-18 07:10:54 -0500 )edit

Excuse my ignorance, I'm a newbie in ROS2. I still don't understand very well how some things work internally. I've been doing some simple tests by launching two move_group nodes, Launching 'run_move_group_node' twice as I mentioned above in my move_group.launch. Doing this, the octomap can update during movement (but extremely slowly!) How could I make the move_group node multithreaded? I wasn't too experienced with ROS1 and these changes have me lost.

angcorcue2 gravatar image angcorcue2  ( 2023-05-18 10:16:18 -0500 )edit

From what I can see, the move_group node is implemented as multithread (rclcpp::executors::MultiThreadedExecutor executor;). I don't really understand why it works when launching two nodes at the same time... I've also tried to use asyncMove without success. Thanks a lot for your time :D

angcorcue2 gravatar image angcorcue2  ( 2023-05-19 02:41:27 -0500 )edit
1

Sorry, I don't know enough about ros2 to answer this. But ros2 has this concept of Callback Groups, and I would look into that.

https://github.com/ros2/ros2_document...

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-05-19 06:05:43 -0500 )edit

Good morning! You mentioned that you have quite a bit of experience with MoveIt, and I wanted to know if you have ever encountered another problem that I am experiencing. As I mentioned, I am working with a real robotic arm, and I have an issue where when I send it a target pose and it moves towards it, it doesn't reach it completely. The end effector ends up slightly off from the target position, and I need to send another command for it to go to that point until it finally reaches it. Typically, it takes 2 or 3 iterations of sending the goal to reach it. I have tried modifying the tolerances, but it doesn't improve. Have you ever had a similar issue in the past? Thank you very much for all your help.

angcorcue2 gravatar image angcorcue2  ( 2023-05-22 06:50:17 -0500 )edit

Please create a new question. Feel free to include a url back to this question if you think it helps explain things.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-05-22 09:21:33 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2023-05-16 06:47:32 -0500

Seen: 456 times

Last updated: May 17 '23