Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MotionPlanningRvizPlugin: Enhanced External ROS Topic API #823

Closed
wants to merge 8 commits into from

Conversation

phy25
Copy link
Contributor

@phy25 phy25 commented Apr 5, 2018

Description

This PR derived from the idea in a ROS Answer question: Provide external topics setting the start state and the goal state in the MotionPlanningRvizPlugin with a RobotState object. This improves the current API in which the state can only be set with the current robot position.

To achieve this, two new topics are subscribed:

  • /rviz/moveit/update_custom_start_state
  • /rviz/moveit/update_custom_goal_state

What's more, for the completeness of the external API, stopping command is exposed too:

  • /rviz/moveit/stop

Finally, the state of allow_external_program UI checkbox can be kept across sessions now, in order to ease the usage. The slot function adds a init check, to prevent uninitialized error.

As I am new to MoveIt! and C++, any feedback is welcome. The feature has been tested locally, and I will complete the following checklist in a week, sorry about that.

Checklist

  • Required: Code is auto formatted using clang-format
  • Extended the tutorials / documentation, if necessary reference - Nothing in the docs for now except the joystick; I will not add more docs
  • Include a screenshot if changing a GUI - N/A
  • Optional: Created tests, which fail without this PR reference
  • Optional: Decide if this should be cherry-picked to other current ROS branches (Indigo, Jade, Kinetic)

 - /rviz/moveit/update_start_state_RobotState
 - /rviz/moveit/update_goal_state_RobotState
Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice submission, I attached some requests inline.

ros::Subscriber update_start_state_subscriber_;
ros::Subscriber update_goal_state_subscriber_;
ros::Subscriber update_start_state_RobotState_subscriber_;
ros::Subscriber update_goal_state_RobotState_subscriber_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change update_*_state_RobotState et al to update_custom_*_state throughout the request?
The datatype does not belong into the identifier.

if (first_time_)
{
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed here?

At first glance this seems unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required because when resuming saved UI state (before first_time_ == true), this function will be executed because of the Qt signal, while something required for this doesn't complete loading (I guess), then it will segfault indefinitely. The quick fix applied here:

  1. Don't execute unless first_time_ load completes;
  2. Manually trigger the function after first_time_ load.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a neat solution, as you say.
It would be interesting for me to know what goes wrong here. The only thing I can imagine is that planning_display_->getRobotInteraction() is still a nullptr.

Please add a proper comment explaining this reasoning above the condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The marker_access_lock_ in the interactive marker is the issue. I cannot think of a nicer fix for now 😞

Thread 1 "rviz" received signal SIGSEGV, Segmentation fault.
__GI___pthread_mutex_lock (mutex=0x158) at ../nptl/pthread_mutex_lock.c:67
#0 __GI___pthread_mutex_lock (mutex=0x158) at ../nptl/pthread_mutex_lock.c:67
#1 0x00007ffff7a8b098 in boost::unique_lockboost::mutex::lock() () from /opt/ros/kinetic/lib/librviz.so
#2 0x00007fff90d87a55 in robot_interaction::RobotInteraction::toggleMoveInteractiveMarkerTopic(bool) ()
from /home/phy/moveit-clone/devel/lib/libmoveit_robot_interaction.so.0.9.11
#3 0x00007fff91ececc6 in moveit_rviz_plugin::MotionPlanningFrame::allowExternalProgramCommunication(bool) ()
from /home/phy/moveit-clone/devel/lib/libmoveit_motion_planning_rviz_plugin_core.so.0.9.11
#4 0x00007ffff1f80d2a in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5 0x00007ffff77fe312 in QAbstractButton::toggled(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#6 0x00007ffff7561645 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#7 0x00007ffff7562acc in QAbstractButton::setChecked(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#8 0x00007fff91f4113c in moveit_rviz_plugin::MotionPlanningDisplay::load(rviz::Config const&) ()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... which means getRobotInteraction() is not a valid object yet, I guess.
Fair enough. Please add a comment that explains this reasoning above the if here as well as in the lines below that trigger the lazy load.


void MotionPlanningFrame::remoteUpdateStartStateRobotStateCallback(const moveit_msgs::RobotStateConstPtr& msg)
{
moveit_msgs::RobotState msg_no_attached(*msg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the unchanged message right now and thus redundant.

I think it is a good idea though to restrict these start state changes to forbid changes in the attached collision objects.
We don't have that possibility in the RViz GUI either
and it might cause weird state effects in the GUI.

I would propose to add

msg_no_attached.attached_collision_objects.clear();
msg_no_attached.is_diff = true;

after the new variable definition here and below.

@phy25 phy25 changed the title MotionPlanningRvizPlugin: Enhanced External ROS Topic API WIP: MotionPlanningRvizPlugin: Enhanced External ROS Topic API Apr 11, 2018
@phy25 phy25 changed the title WIP: MotionPlanningRvizPlugin: Enhanced External ROS Topic API MotionPlanningRvizPlugin: Enhanced External ROS Topic API Apr 11, 2018
@phy25
Copy link
Contributor Author

phy25 commented Apr 11, 2018

Renamed stuff, clang-formatted, and added the collision object remover, and local test looks good. A squash merge is preferred as there are too many commits 🔧.
I will check whether docs update is required later.

&MotionPlanningFrame::remoteUpdateCustomStartStateCallback, this);
update_custom_goal_state_subscriber_ =
nh.subscribe("/rviz/moveit/update_goal_state_RobotState", 1,
&MotionPlanningFrame::remoteUpdateCustomGoalStateCallback, this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to change the topic names (*_custom_*_state), please do that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to push that single commit, sorry.

Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, one last request for change. Otherwise this looks good and I'm happy to include it.

Please also look at clang-format again, the CI failed

if (first_time_)
{
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... which means getRobotInteraction() is not a valid object yet, I guess.
Fair enough. Please add a comment that explains this reasoning above the if here as well as in the lines below that trigger the lazy load.

@phy25
Copy link
Contributor Author

phy25 commented Apr 11, 2018

Got it. Finished.

@v4hn
Copy link
Contributor

v4hn commented Apr 12, 2018

Awesome, thank you for your endurance 👍

I approve to merge this into kinetic-devel. Now another maintainer can review and merge.

@phy25
Copy link
Contributor Author

phy25 commented May 6, 2018

Should I rebase this or someone else is working on this 😂 ?

@rhaschke
Copy link
Contributor

rhaschke commented May 6, 2018

@phy25 I'm working on merging this.

rhaschke pushed a commit that referenced this pull request May 6, 2018
 - /rviz/moveit/update_custom_start_state
 - /rviz/moveit/update_custom_goal_state

stopping from external:
 - /rviz/moveit/stop
@rhaschke
Copy link
Contributor

rhaschke commented May 6, 2018

Merged after rebase: 83809de, github didn't notice.

@rhaschke rhaschke closed this May 6, 2018
dg-shadow pushed a commit to shadow-robot/moveit that referenced this pull request Jul 30, 2018
 - /rviz/moveit/update_custom_start_state
 - /rviz/moveit/update_custom_goal_state

stopping from external:
 - /rviz/moveit/stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants