diff --git a/CMakeLists.txt b/CMakeLists.txt index 43a10f8..6e23265 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ catkin_package( INCLUDE_DIRS include LIBRARIES ros_essentials_cpp CATKIN_DEPENDS roscpp rospy std_msgs message_runtime - DEPENDS system_lib + # DEPENDS system_lib ) ########### diff --git a/src/assignment/turtlesim_motion_pose.py b/src/assignment/turtlesim_motion_pose.py index 0b72b31..81f34fa 100755 --- a/src/assignment/turtlesim_motion_pose.py +++ b/src/assignment/turtlesim_motion_pose.py @@ -7,79 +7,70 @@ import time from std_srvs.srv import Empty -x=0 -y=0 -z=0 -yaw=0 +x = 0 +y = 0 +z = 0 +yaw = 0 + def poseCallback(pose_message): global x global y, z, yaw - x= pose_message.x - y= pose_message.y + x = pose_message.x + y = pose_message.y yaw = pose_message.theta - #print "pose callback" - #print ('x = {}'.format(pose_message.x)) #new in python 3 - #print ('y = %f' %pose_message.y) #used in python 2 - #print ('yaw = {}'.format(pose_message.theta)) #new in python 3 + # print "pose callback" + # print ('x = {}'.format(pose_message.x)) #new in python 3 + # print ('y = %f' %pose_message.y) #used in python 2 + # print ('yaw = {}'.format(pose_message.theta)) #new in python 3 def move(speed, distance): - #declare a Twist message to send velocity commands + # declare a Twist message to send velocity commands velocity_message = Twist() - #get current location - x0=x - y0=y - #z0=z; - #yaw0=yaw; - velocity_message.linear.x =speed + # get current location + x0 = x + y0 = y + # z0 = z; + # yaw0 = yaw; + velocity_message.linear.x = speed distance_moved = 0.0 - loop_rate = rospy.Rate(10) # we publish the velocity at 10 Hz (10 times a second) - cmd_vel_topic='/cmd_vel' + loop_rate = rospy.Rate(10) # we publish the velocity at 10 Hz (10 times a second) + cmd_vel_topic = '/cmd_vel' velocity_publisher = rospy.Publisher(cmd_vel_topic, Twist, queue_size=10) - - while True : + while True: rospy.loginfo("Turtlesim moves forwards") velocity_publisher.publish(velocity_message) - loop_rate.sleep() - - #rospy.Duration(1.0) - - distance_moved = distance_moved+abs(0.5 * math.sqrt(((x-x0) ** 2) + ((y-y0) ** 2))) - print distance_moved - if not (distance_moved