0
$\begingroup$

Rosanswers logo

I can't figure out what I am doing wrong that would cause this issue. I originally was just using the move() function but that wasn't returning either. I thought it had something to do with just running this in rviz and not really executing anything.

So I switched to plan() instead but found I was having the same issue. I've attached the barebones I've boiled this down to:

#include <ros/ros.h>
#include <moveit/move_group_interface/move_group.h>

int main(int argc, char **argv) {
    ros::init(argc, argv, "move_group_interface_demo");
    ros::NodeHandle node;

    move_group_interface::MoveGroup group("arm");

    ros::Rate rate(1);
    while (node.ok()){
        group.setRandomTarget();

        moveit::planning_interface::MoveGroup::Plan  plan;

        ROS_INFO("Planning");

        if(group.plan(plan)) {
            ROS_INFO("Planning Successful");
        }
        else {
            ROS_WARN("Planning failed!");
        }
        rate.sleep();
    }

    ROS_INFO("DONE");

    ros::waitForShutdown();
    return 0;
}

Like I said, I'm sure it's a careless mistake that I'm not seeing. I'm using the demo.launch file created using the MoveIt! Setup Assistant. I see the plan being visualized in RViz after the planning is initiated? But the function doesn't return in this simple node.

In the terminal I see "Planning" being printed but neither the successful or failure messages print after that.

Also, I can use the planners in MoveIt! just fine inside of RViz to "plan and execute".

Any ideas?


Originally posted by skiesel on ROS Answers with karma: 549 on 2013-10-16

Post score: 6


Original comments

Comment by Martin Günther on 2013-10-17:
Perfect question! You'd better ask this at https://groups.google.com/forum/#!forum/moveit-users, and I'm sure you'll get a quick answer there.

Comment by skiesel on 2013-10-17:
Thanks Martin, I'll repost this to their google-group.

Comment by Damon on 2015-06-24:
Thanks for the question (and the answer) skiesel. Was useful. :)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

After a goodnight's sleep it hit me. THREADS. Ugh.

http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning#Multi-threaded_Spinning

ros::AsyncSpinner spinner(1);
spinner.start();

Originally posted by skiesel with karma: 549 on 2013-10-17

This answer was ACCEPTED on the original site

Post score: 10


Original comments

Comment by ravipr009 on 2018-12-24:
Thanks! it works

Comment by fvd on 2020-09-09:
I had this issue in an Rviz panel which cannot own an AsyncSpinner, but the answer was also THREADS. The Moveit MotionPlanning plugin has good examples on how to launch threads with boost::bind.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.