ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

move_group.setWorkspace() doesn't work?

asked 2017-10-19 07:18:49 -0500

EdwinvanEmmerik gravatar image

Hi all!

I am working on a project where I have to build lego structures collaberative with a human. Now I am new to moveit and have the cartesian path planning working in gazebo (sinusoidals, pick and place movement).

I was trying to use the move_group.setWorspace() function and for some reason it just doesn't give this information to the planning_scene_interface. When I execute a trajectory outside of it's workspace it will just go there for no reason. Also i wanted to implement anti-collision using octomapping however I don't think it will be a good idea to start on that if i can't control the size of my workspace properly.

PS: I also have changed the workspace settings in the moveit.rviz file from the ur5, I can see the workspace getting these dimensions in rviz however the ur5 will still go there.

Kind regards, Edwin van Emmerik CODE:

int main(int argc, char **argv) { ros::init(argc, argv, "trajectory_tester"); ros::NodeHandle node_handle;
ros::AsyncSpinner spinner(1); spinner.start(); // Construct planning scene for the move_group const std::string PLANNING_GROUP = "manipulator"; moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP); move_group.setWorkspace(-0.2, -0.2, 0.05, 1, 1, 1); // set workspace size for move_group robot_model_loader::RobotModelLoader robot_model_loader("robot_description"); robot_model::RobotModelPtr robot_model = robot_model_loader.getModel(); // Make sure that the robot model gets loaded if (robot_model != 0) { ROS_INFO("Robot model loaded"); } else { ROS_INFO("Could not load robot model"); }

// Get the planning frames
ROS_INFO("Reference frame: %s", move_group.getPlanningFrame().c_str());
ROS_INFO("Reference frame: %s", move_group.getEndEffectorLink().c_str());
move_group.setPlannerId("PRMstarkConfigDefault"); //default planner is set to RTTCONNECT in ompl_planning_.yaml
moveit::planning_interface::MoveGroupInterface::Plan my_plan;
int chosenone;
std::cout << "You can choose between pick and place(1) and sinusoidal movements(2)" << std::endl;
std::cin >> chosenone;
std::cout << std::endl;
// Construct target_pose object of type geometry_msgs
// Construct waypoints vector of type geometry_msgs::Pose
std::vector<geometry_msgs::Pose> waypoints;
geometry_msgs::Pose start_pose = move_group.getCurrentPose().pose;
geometry_msgs::Pose target_pose = start_pose;

        // Keep initiazlize state and also keep the UR5 facing downwards for default
        target_pose.position.x = 0.6;
        target_pose.position.y = 0.05;
        target_pose.position.z = 0.1;
        target_pose.orientation.w = 0.707;
        target_pose.orientation.x = 0;
        target_pose.orientation.y = 0.707;
        target_pose.orientation.z = 0;

        int number_of_waypoints = 7;
        double x[number_of_waypoints];
        x[0] = 0.5;
        x[1] = 0.0;
        x[2] = 0.0;
        x[3] = 0.0;
        x[4] = 0.5;
        x[5] = 0.5;
        x[6] = 0.5;
        double y[number_of_waypoints];
        y[0] = 0.0;
        y[1] = 0.5;
        y[2] = 0.5;
        y[3] = 0.5;
        y[4] = 0.0;
        y[5] = 0.0;
        y[6] = 0.0;
        double z[number_of_waypoints];
        z[0] = 0.4;
        z[1] = 0.4;
        z[2] = 0.1;
        z[3] = 0.4;
        z[4] = 0.4;
        z[5] = 0.1;
        z[6] = 0.4;
        for (int i = 0; i < number_of_waypoints; i++)
            target_pose.position.x = x[i];
            target_pose.position.y = y[i];
            target_pose.position.z = z[i];

/* NOTE THAT ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-19 08:48:52 -0500

v4hn gravatar image

updated 2017-10-19 08:50:19 -0500

Hello there,

the "workspace" parameter currently does not affect revolute joints! The parameter was originally introduced to restrict the movement of mobile robots or drones to stay within some volume, modeled via Planar or Floating joints.

If you want to have the framework avoid regions in space please add collision objects for them. If you want the arm to stay within some bounded volume, you can model this as "wall" collision objects.

P.S. The project sounds awesome! I'm somewhat jealous :-)

edit flag offensive delete link more


Thanks for your answer. I do think it is a little weird, I have read most off the questions that were similar to this one and the reason I did ask it is because I thought they would have resolved it by now.

Do you mean with a wall just to add objects around the robot to use that as workspace?

EdwinvanEmmerik gravatar imageEdwinvanEmmerik ( 2017-10-20 11:19:13 -0500 )edit

they would have resolved it by now.

You are part of "they". Write a patch and I'm happy to review and merge it :-)

mean with a wall just to add objects

That's how people worked around this in the past, yes...

v4hn gravatar imagev4hn ( 2017-10-21 08:26:39 -0500 )edit

It's probably also the easiest way upstream to add such collision objects when a workspace is configured...

v4hn gravatar imagev4hn ( 2017-10-21 08:27:22 -0500 )edit

Yea I added 5 walls to my workspace and it is working now! Sounds really cool that everybody can help on improving moveit! I think it is quiet complicated and that is probably the reason why it is not implemented yet. Is there any documentation on writing patches? Just for self-interest!

EdwinvanEmmerik gravatar imageEdwinvanEmmerik ( 2017-10-21 13:14:25 -0500 )edit

Great! If you want to contribute to MoveIt, have a look at http://moveit.ros.og and read through the "Contribute" section in the top panel.

v4hn gravatar imagev4hn ( 2017-10-22 03:35:07 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-10-19 07:18:49 -0500

Seen: 321 times

Last updated: Oct 19 '17