PilzDE / pilz_tutorials

Files for PILZ tutorials on wiki.ros.org

Home Page:http://wiki.ros.org/pilz_robots/Tutorials/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tutorials 3 and 4 fail to import modules in Python script.

Roiki11 opened this issue · comments

Module import lines currently don't work for me while following the tutorials on ROS Wiki. When running the script with rosrun the line from pilz_robot_programming import * results in NameError: name 'Robot' is not defined. Changing it to pilz_robot_programming.robot import * then results in "ImportError: No module named msg"

The system is Ubuntu 18.04 LTS VM with Latest ROS Melodic, moveIt and Pilz industrial motion packages from the repos. The ROS parts work as expected.

Tracebacks are below

Traceback (most recent call last):
File "/home/joonas/Desktop/robot_ros_ws/src/pilz_tutorial/scripts/myFirstApplication.py", line 67, in
r = Robot(REQUIRED_API_VERSION) # instance of the robot
NameError: name 'Robot' is not defined

File "/home/joonas/Desktop/robot_ros_ws/src/pilz_tutorial/scripts/myFirstApplication.py", line 3, in
from pilz_robot_programming.robot import *
File "/opt/ros/melodic/lib/python2.7/dist-packages/pilz_robot_programming/robot.py", line 32, in
from pilz_msgs.msg import MoveGroupSequenceAction, IsBrakeTestRequiredResult
ImportError: No module named msg

Did you install the apt packages as described in tutorial 2?

Please post the version output of dpkg -l | grep pilz-robot-programming.

Yes, tutorials 1 and 2 work as intended, the problem only comes with the python script at tutorial 3.
dpkg -l | grep pilz-robot-programming.
Returns:
ii ros-melodic-pilz-robot-programming 0.4.10-1bionic.20191205.183526 amd64 An Easy to use API to execute standard industrial robot commands like Ptp, Lin, Circ and Sequence using Moveit.

Trying to run the imports in python console produces the same results.

Maybe there is something wrong in your workspace. Please start out with a fresh catkin_ws without cloning any repo. Do you use catkin or catkin_make? What packages are inside your workspace src/ folder?
source /opt/ros/melodic/setup.bash && python -c "from pilz_robot_programming import *" works for me.

I use catkin_make . The only package i have in my src is the pilz_tutorial package that im working on.
source /opt/ros/melodic/setup.bash && python -c "from pilz_robot_programming import *" Worked for me too so i tried looking in to the PYTHONPATH and i found the issue.
For some reason whenever i create a new workspace, build it with catkin_make and source its setup.bash ROS sets up the PYTHONPATH incorrectly to pointing at a workspace that no longer exists. When i update the PYTHONPATH manually with the correct path it starts working.
No idea why it's doing that but now the tutorials are working. Thanks for the help