0
$\begingroup$

Rosanswers logo

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

Originally posted by Robot Nr.5 on ROS Answers with karma: 3 on 2017-08-03

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by gvdhoorn with karma: 86574 on 2017-08-03

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Robot Nr.5 on 2017-08-03:
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?

Comment by Robot Nr.5 on 2017-08-03:
That means it is not intended to start RViz automatically from the code but manually by yourself?! What a bummer.

Comment by gvdhoorn on 2017-08-03:
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.

$\endgroup$

Your Answer

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