Ask Your Question
0

MoveIt Tutorial rviz does not start

asked 2017-08-03 07:52:31 -0600

Robot Nr.5 gravatar image

Hi guys, I try to move the robot Sawyer from rethinkrobotics to a given point. My base program for this is here. Because it doesn't work well just typing in coordinates I want to try to simulate the movement or at least read out the joint positions with rviz. Therefor I completed the MoveIt tutorial from rethinkrobotics and now I try to apply the python tutorial to reach my goal.

Right now I am trying to get the first lines of code from the given example working (just to "printing robot state") but rviz won't start. The output in the console seems to be like it should be, the action server is up and running and rviz works fine if I start it manually by

$ roslaunch sawyer_moveit_config sawyer_moveit.launch

So I leave that console window open and start the example which should start rviz, but nothing happens. Any ideas?

Here's the part of the code example I want to work (cleaned it a bit):

#!/usr/bin/env python

################### CORRECT STARTUP ###################
# $ rosrun file.py joint_states:=/robot/joint_states
#######################################################
#######################################################

## BEGIN_SUB_TUTORIAL imports
##
## To use the python interface to move_group, import the moveit_commander
## module.  We also import rospy and some messages that we will use.
import sys
import copy
import rospy
import moveit_commander
import moveit_msgs.msg
import geometry_msgs.msg
## END_SUB_TUTORIAL

from std_msgs.msg import String

def move_group_python_interface_tutorial():
## BEGIN_TUTORIAL
##
## Setup
## ^^^^^
## CALL_SUB_TUTORIAL imports
##
## First initialize moveit_commander and rospy.
print "============ Starting tutorial setup"
moveit_commander.roscpp_initialize(sys.argv)
rospy.init_node('move_group_python_interface_tutorial',
              anonymous=True)

## Instantiate a RobotCommander object.  This object is an interface to
## the robot as a whole.
robot = moveit_commander.RobotCommander()

## Instantiate a PlanningSceneInterface object.  This object is an interface
## to the world surrounding the robot.
scene = moveit_commander.PlanningSceneInterface()

## Instantiate a MoveGroupCommander object.  This object is an interface
## to one group of joints.  In this case the group is the joints in the left
## arm.  This interface can be used to plan and execute motions on the left
## arm.
group = moveit_commander.MoveGroupCommander("right_arm")

## We create this DisplayTrajectory publisher which is used below to publish
## trajectories for RVIZ to visualize.
display_trajectory_publisher = rospy.Publisher(
                                  '/move_group/display_planned_path',
                                  moveit_msgs.msg.DisplayTrajectory,
                                  queue_size=20)

## Wait for RVIZ to initialize. This sleep is ONLY to allow Rviz to come up.
print "============ Waiting for RVIZ..."
rospy.sleep(10)
print "============ Starting tutorial "

## Getting Basic Information
## ^^^^^^^^^^^^^^^^^^^^^^^^^
##
## We can get the name of the reference frame for this robot
print "============ Reference frame: %s" % group.get_planning_frame()

## We can also print the name of the end-effector link for this group
print "============ Reference frame: %s" % group.get_end_effector_link()

## We can get a list of all the groups in the robot
print "============ Robot Groups:"
print robot.get_group_names()

## Sometimes for debugging it is useful to print the entire state of the
## robot.
print "============ Printing robot state"
print robot.get_current_state()
print "============"

## When finished shut down moveit_commander.
moveit_commander.roscpp_shutdown()

## END_TUTORIAL

print "============ STOPPING"


if __name__=='__main__':
try:
  move_group_python_interface_tutorial()
except rospy.ROSInterruptException:
  pass
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-03 09:32:15 -0600

gvdhoorn gravatar image

updated 2017-08-03 10:11:06 -0600

Which launch file is supposed to start RViz? This line:

Wait for RVIZ to initialize. This sleep is ONLY to allow Rviz to come up.

and the following bits of Python are not going to start RViz, they just make your script wait for a bit.


Edit:

But how do I start RViz then?

It's not made explicit, but demo.launch starts RViz for you. This is shown in the Running the Code section of the tutorial you linked.

edit flag offensive delete link more

Comments

I am new to this stuff and just copied the example. That there is no explicit call for RViz is clear to me, but with my little knowledge I supposed it gets called some other way. Also I am not sure if the file has to be in a special folder inside the ros workspace.

But how do I start RViz then?

Robot Nr.5 gravatar imageRobot Nr.5 ( 2017-08-03 09:45:19 -0600 )edit

That means it is not intended to start RViz automatically from the code but manually by yourself?! What a bummer.

Robot Nr.5 gravatar imageRobot Nr.5 ( 2017-08-03 10:25:59 -0600 )edit

Yes, you are supposed to start things yourself. But the script / code also doesn't start MoveIt for you, so you'll have to start that anyway. And then demo.launch starts all those things for you, so I don't really see the problem.

gvdhoorn gravatar imagegvdhoorn ( 2017-08-03 10:27:25 -0600 )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

Stats

Asked: 2017-08-03 07:52:31 -0600

Seen: 577 times

Last updated: Aug 03 '17