Missing compile step?
I'm learning ROS for Turtlebot3, and am getting an error message that appears to tell me that I missed a compilation or build step. Perhaps I am missing an environment variable. Here are the key steps:
$ catkin_create_pkg wanderbot rospy geometry_msgs sensor_msgs
$ source ~/catkin_ws/devel/setup.bash
pitosalas@ubuntu:~/catkin_ws/wanderbot/src$ ./redgreen.py
from: can't read /var/mail/geometry_msgs.msg
./redgreen.py: line 6: syntax error near unexpected token `('
./redgreen.py: line 6: `cmd_vel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1) #<1>'
And looking for the missing geometry_msgs.msg:
pitosalas@ubuntu:/$ ls -l /opt/ros/kinetic/share/geometry_msgs/
total 12
drwxr-xr-x 2 root root 4096 Jul 23 18:39 cmake
drwxr-xr-x 2 root root 4096 Jul 23 18:39 msg
-rw-r--r-- 1 root root 794 Sep 30 2016 package.xml
And inside you can see the Twist.msg:
ls -l /opt/ros/kinetic/share/geometry_msgs/msg/
total 116
-rw-r--r-- 1 root root 119 Sep 30 2016 Accel.msg
-rw-r--r-- 1 root root 83 Sep 30 2016 AccelStamped.msg
-rw-r--r-- 1 root root 330 Sep 30 2016 AccelWithCovariance.msg
-rw-r--r-- 1 root root 124 Sep 30 2016 AccelWithCovarianceStamped.msg
-rw-r--r-- 1 root root 235 Sep 30 2016 Inertia.msg
-rw-r--r-- 1 root root 30 Sep 30 2016 InertiaStamped.msg
-rw-r--r-- 1 root root 367 Sep 30 2016 Point32.msg
-rw-r--r-- 1 root root 84 Sep 30 2016 Point.msg
-rw-r--r-- 1 root root 98 Sep 30 2016 PointStamped.msg
-rw-r--r-- 1 root root 107 Sep 30 2016 Polygon.msg
-rw-r--r-- 1 root root 104 Sep 30 2016 PolygonStamped.msg
-rw-r--r-- 1 root root 96 Sep 30 2016 Pose2D.msg
-rw-r--r-- 1 root root 85 Sep 30 2016 PoseArray.msg
-rw-r--r-- 1 root root 119 Sep 30 2016 Pose.msg
-rw-r--r-- 1 root root 79 Sep 30 2016 PoseStamped.msg
-rw-r--r-- 1 root root 323 Sep 30 2016 PoseWithCovariance.msg
-rw-r--r-- 1 root root 122 Sep 30 2016 PoseWithCovarianceStamped.msg
-rw-r--r-- 1 root root 108 Sep 30 2016 Quaternion.msg
-rw-r--r-- 1 root root 117 Sep 30 2016 QuaternionStamped.msg
-rw-r--r-- 1 root root 118 Sep 30 2016 Transform.msg
-rw-r--r-- 1 root root 337 Sep 30 2016 TransformStamped.msg
-rw-r--r-- 1 root root 115 Sep 30 2016 Twist.msg
-rw-r--r-- 1 root root 82 Sep 30 2016 TwistStamped.msg
-rw-r--r-- 1 root root 326 Sep 30 2016 TwistWithCovariance.msg
-rw-r--r-- 1 root root 124 Sep 30 2016 TwistWithCovarianceStamped.msg
-rw-r--r-- 1 root root 382 Sep 30 2016 Vector3.msg
-rw-r--r-- 1 root root 103 Sep 30 2016 Vector3Stamped.msg
-rw-r--r-- 1 root root 117 Sep 30 2016 Wrench.msg
-rw-r--r-- 1 root root 85 Sep 30 2016 WrenchStamped.msg
pitosalas@ubuntu:/$
Here's the full source of red green.py:
#example 1
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
cmd_vel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1) #<1>
rospy.init_node('red_light_green_light')
red_light_twist = Twist() #<2>
green_light_twist = Twist()
green_light_twist.linear.x = 0.5 #<3>
driving_forward = False
light_change_time = rospy.Time.now()
rate = rospy.Rate(10)
while not rospy.is_shutdown():
if ...
Why is the
wanderbot
package outside yoursrc
space? That won't work (well it can, but let's not complicate things).Put it in
catkin_ws/src
, runcatkin_make
(orcatkin build
),source
yourdevel/setup.bash
and try again.Also, check what you have on line 6 of
redgreen.py
.Thanks @gvdhoorn... I made the suggested corrections, and updated the original question above. Then run it with
cd ~./catkin_ws/src/wanderbot/src; ./redgreen.py
and got the same error. Any other suggestion would be appreciated!It looks like you're not finding
geometry_msgs
in/var/mail
(from: can't read /var/mail/geometry_msgs.msg
). Where is it installed on your system? I'm on Ubuntu 14.04 and using Indigo, and it's installed at/opt/ros/indigo/share/geometry_msgs
.@jayess, thanks, it seems to be there. Also I've updated the original question with that detail and some more. Thanks for sticking with me!
Make sure to post the entire contents of your source. I ran the previous edit of your code and didn't get any errors. I ran the current version and got your errorl
yes. I guess I was trying to unclutter the question before I had any idea that that comment was the culprit!