Ask Your Question

How to change MoveIt! goal state through code?

asked 2017-03-20 06:12:04 -0500

HenrySleek gravatar image

updated 2017-03-21 11:14:51 -0500

I am working with ROS Indigo and MoveIt! and I already set up my robot through the setup assistant, and In Rivz I can see the start and goal state, in green and orange. I can manually move the orange goal state from Rviz and then plan and execute a trajectory in order to reach it. Otherwise, I have a piece of code that sets a goal trajectory and plans and executes the whole trajectory to it.

But I would like to just move the (orange) goal state to a new position through a piece of code, without planning any trajectory. Just changing the goal state. How can I do it?

edit retag flag offensive close merge delete


Please stop editing your posts over and over again. This sends out notification emails every time to everyone who watches ros-answers.

v4hn gravatar image v4hn  ( 2017-03-21 05:38:26 -0500 )edit

Oh damn, I am sorry, I didn't know. I just wanted to have it pop up at the top of the question list in the Home page. I will stop now that I have an answer.

HenrySleek gravatar image HenrySleek  ( 2017-03-22 05:34:17 -0500 )edit

Hey you said that you had a piece of code that sets a goal trajectory and plans and executes that trajectory? I am struggling to figure out how to do this, would you mind giving some details?

levi strauss gravatar image levi strauss  ( 2018-07-03 15:11:45 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-21 05:36:51 -0500

v4hn gravatar image

MoveIt's RViz display is mostly independent. The orange goal state corresponds to the goal state of the display only. There is no such thing as a "global goal state".

So actually you are looking for a way to tell the motion planning display to update the robot state it maintains as its goal state. Others asked for more general remote-control functionality of the whole motion planning display in the past. There is no satisfying implementation of this at the moment. Someone implemented a small part of it a while ago, but apparently lost interest. Since then, nobody provided patches to improve on the current state...

So this is what you can do out of the box:

If you check the "Allow External Comm." box in the planning tab, then you can send an std_msgs/Empty message to the /rviz/moveit/update_goal_state topic and the goal state will be set to the current state of the robot.

This is setup here:

and implemented .

It is pretty straight-forward and at most an afternoon of work to add another callback that receives a moveit_msgs/RobotState.msg and updates the start state or goal state with it.

A patch for this (and a pull-request for the moveit repository) would be awesome!

edit flag offensive delete link more


I checked that code and indeed it's really a pity that nobody tried to expand it. Anyway, maybe it is enough to call a planning_display_->setQueryGoalState(state); setting the wanted state. Though, trying it, I have the following problem:

HenrySleek gravatar image HenrySleek  ( 2017-03-21 11:13:07 -0500 )edit

Yes and no. You can't do that from outside the rviz display, i.e. from your own node. You can just add another callback and subscriber though, that receives a moveit_msgs/RobotState.msg and calls planning_display_->setQueryGoalState() with that one.

v4hn gravatar image v4hn  ( 2017-03-21 12:03:12 -0500 )edit

I see. But I prefer not modifying the source code, since now it's installed with binaries and I didn't want to put my hands on it. Is there a way for doing it with MoveIt! installed from binaries?

HenrySleek gravatar image HenrySleek  ( 2017-03-22 03:03:17 -0500 )edit

It is quite easy to compile moveit locally (see install section on the website). If you implement the missing function and add a pull-request to the repository, we could have it in the next release and then you don't need your own source build anymore :) This is how open source contributions work...

v4hn gravatar image v4hn  ( 2017-03-22 05:32:54 -0500 )edit

If you are not willing to edit MoveIt source code, then no. You can't change the goal start arbitrarily (until someone contributed this functionality).

v4hn gravatar image v4hn  ( 2017-03-22 05:34:32 -0500 )edit

A tested patch is available here: . A PR will be made soon.

phy gravatar image phy  ( 2018-04-04 09:41:44 -0500 )edit

Hi, I know this is kinda old, but recently I'm running into the same challenge. I am trying to send goal states through /rviz_moveit_motion_planning_display/robot_interaction_interactive_marker_topic/update, but I saw that Rviz's display update rate become significantly slower. I guess you can verify this by trying the same thing.

Right now I am trying to increase Rviz display's speed. Any idea?

RicoJ gravatar image RicoJ  ( 2020-11-13 09:47:02 -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



Asked: 2017-03-20 06:12:04 -0500

Seen: 1,993 times

Last updated: Mar 21 '17