Hello,
I am trying to build my action client for the rosject and have the code below. However I am getting invalid syntax error.:
user:~$ rosrun turtle2 actionclient.py
File “/home/user/catkin_ws/src/turtle2/scripts/actionclient.py”, line 31
sub = rospy.Subscriber(’/scan’, LaserScan, callback)
^
SyntaxError: invalid syntax
Not sure why this would be an invalid syntax, the descriptor is unfortunatly vauge. Ive used this line in code before and its worked. What am I doing incorrect?
Code
#! /usr/bin/env python
import rospy
import actionlib
from turtlemvmt.action import turtlebotAction, turtlebotGoal
import rospy
import actionlib
from turtlemvmt.action import turtlebotAction, turtlebotFeedback, turtlebotResult
import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
from std_msgs.msg import String
import actionlib
import actionlib_tutorials.msg
#Get information from /scan into turtlebotGoal
def feedback_cb(msg):
print (‘Feedback received:’, msg)
def call_server():
client = actionlib.SimpleActionClient('turtlebotactionserver', turtlebotAction)
client.wait_for_server()
goal = turtlebotGoal()
def callback(msg):
print ("distance is:" (msg.ranges[180])
(msg.ranges[180]) = goal
sub = rospy.Subscriber('/scan', LaserScan, callback)
rospy.spin()
client.send_goal(goal, feedback_cb=feedback_cb)
client.wait_for_result()
result = client.get_result()
return result
if name == ‘main’:
try:
rospy.init_node('action_client')
result = call_server()
print 'The result is:', result
except rospy.ROSInterruptException as e:
print 'Something went wrong:', e