ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Missing compile step?

asked 2017-07-26 11:03:54 -0600

pitosalas gravatar image

updated 2017-07-27 13:57:47 -0600

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 ...
(more)
edit retag flag offensive close merge delete

Comments

Why is the wanderbot package outside your src space? That won't work (well it can, but let's not complicate things).

Put it in catkin_ws/src, run catkin_make (or catkin build), source your devel/setup.bash and try again.

Also, check what you have on line 6 of redgreen.py.

gvdhoorn gravatar image gvdhoorn  ( 2017-07-26 15:48:18 -0600 )edit

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!

pitosalas gravatar image pitosalas  ( 2017-07-26 19:05:44 -0600 )edit

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 gravatar image jayess  ( 2017-07-26 19:37:01 -0600 )edit

@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!

pitosalas gravatar image pitosalas  ( 2017-07-26 21:02:23 -0600 )edit

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

jayess gravatar image jayess  ( 2017-07-27 15:18:25 -0600 )edit

yes. I guess I was trying to unclutter the question before I had any idea that that comment was the culprit!

pitosalas gravatar image pitosalas  ( 2017-07-27 15:26:25 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-07-27 13:57:09 -0600

pitosalas gravatar image

I think I found the problem: the first line of the .py file was a #comment... before the shebang line. I think thats what messed everything up!

edit flag offensive delete link more

Comments

If this solved your question you should mark it as correct.

jayess gravatar image jayess  ( 2017-07-27 15:18:51 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-07-26 11:03:54 -0600

Seen: 459 times

Last updated: Jul 27 '17