Kamerider benchmark

From KameRider
Jump to: navigation, search

Description: This package is built for the Demo Challenge on Benchmarking Service Robots which requires the robot to move to a certain distance or rotate for a number of times with precision. It also includes a waypoint traveller program allowing the robot to move to certain coordinates in a prebuilt map created by the user.

Pre-requirements: Turtlebot Hydro, Pi speech tutorial, Turtlebot Gmapping tutorial

1. Using forward_by_meters

forward_by_meters allows the robot to move for a distance in meters. The desired distance in meters and speed in meters per second should first be set in the program. Note that the robot may not move in exact accuracy as specified in the program, therefore the user needs to subtract the offset distance from the desired distance in order to compensate the error. (- OFFSET if overshoot, + OFFSET if distance is not reached).

# move forward certain distance
self.current_x = self.robot_pose.pose.pose.position.x
self.current_y = self.robot_pose.pose.pose.position.y

self.distance_travelled = 0
self.initial_x = self.robot_pose.pose.pose.position.x
self.initial_y = self.robot_pose.pose.pose.position.y
while (self.distance_travelled < 1.0 - OFFSET):  # Desired distance in meters
	self.msg.linear.x = 0.2  # Desired speed in meters per second
	self.msg.angular.z = 0.0
	self.cmd_vel_pub.publish(self.msg)
	self.diff_x = self.robot_pose.pose.pose.position.x - self.initial_x
	self.diff_y = self.robot_pose.pose.pose.position.y - self.initial_y

	self.distance_travelled = math.sqrt(self.diff_x*self.diff_x + self.diff_y*self.diff_y)
	self.cmd_vel_pub.publish(Twist())

To run the program, enter the following lines in your terminal while connected to your turtlebot.

$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch kamerider_benchmark forward_by_meters.launch

2. Using rotate

rotate_n_times allows the robot to rotate a number of times specified in the program. The desired number of turns and the rotation speed in radians per second should first be set in the program. The turtlebot may not rotate the exact number of turns as specified in the program. In this case, the user needs to subtract the offset from the desired number of turns. (- OFFSET if overshoot, + OFFSET if distance is not reached).

# rotate clockwise
self.N_turn = 2 - OFFSET    # Set the number of turns
while self.current_d > self.N_turn*-360:
	self.msg.linear.x = 0  
	self.msg.angular.z = -0.40  # Set the speed in radians per second
	self.cmd_vel_pub.publish(self.msg)
self.cmd_vel_pub.publish(Twist())

To run the program, enter the following lines in your terminal while connected to your turtlebot.

$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch kamerider_benchmark rotate_n_times.launch

3. Using waypoint_traveler

waypoint_traveler allows the robot to move to several coordinates in sequence as specified by the user. To use, replace the 0's with any coordinate obtained from the map that we want the turtlebot to reach.

You need to build a map in order to use this. Please refer to Turtlebot Gmapping tutorial for map building and how to acquire pose coordinates.

        ##
	## Insert real-world coordinates in the 0's
	##
	locations['1'] = Pose(Point(0.00, 0.00, 0.00), Quaternion(0.00, 0.00, 0.00, 0.00))

	locations['2'] = Pose(Point(0.00, 0.00, 0.00), Quaternion(0.00, 0.00, 0.00, 0.00))

	locations['3'] = Pose(Point(0.00, 0.00, 0.00), Quaternion(0.00, 0.00, 0.00, 0.00))

	locations['4'] = Pose(Point(0.00, 0.00, 0.00), Quaternion(0.00, 0.00, 0.00, 0.00))

	locations['5'] = Pose(Point(0.00, 0.00, 0.00), Quaternion(0.00, 0.00, 0.00, 0.00))

	locations['6'] = Pose(Point(0.00, 0.00, 0.00), Quaternion(0.00, 0.00, 0.00, 0.00))

	locations['7'] = Pose(Point(0.00, 0.00, 0.00), Quaternion(0.00, 0.00, 0.00, 0.00))

	self.goal = MoveBaseGoal()
        rospy.loginfo("Starting navigation test")

To run the program, enter the following lines in your terminal while connected to your turtlebot.

$ roslaunch turtlebot_bringup minimal.launch
$ roslaunch kamerider_benchmark waypoint_traveler.launch