def parse(tokens, filename): """Parses the given file, converts it to an AST, and performs weeding. Returns the tree or throws an JoosSyntaxException.""" parse_tree = parse_token_list(tokens) sys.setrecursionlimit(100000) tree_root = et.ElementTree.Element("fake_root") xml_tree = dump_to_xml(parse_tree, tree_root)[0] tree = simplify.simplify_tree(xml_tree) weed.weed(tree, filename) tree.filename = filename return tree
def test_change_velocity(self): commandX = weed.weed("robot_0", False) twist = Twist() twist.linear.x = 1.0 commandX.cmd_vel_pub.publish(twist) commandX.wait(5) self.assertEqual(commandX.twist.linear.x , 1.0)
def test_change_velocity(self): commandX = weed.weed("robot_0", False) twist = Twist() twist.linear.x = 1.0 commandX.cmd_vel_pub.publish(twist) commandX.wait(5) self.assertEqual(commandX.twist.linear.x, 1.0)
def test_move_x_steps_backward(self): #Starting position is (-3,0,0) # move robot 3 meters using the method commandX = weed.weed("robot_11", False) commandX.move_x_steps(-3) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > -6.5 ) & (data_from_callback.pose.pose.position.x < -5.5): result = True self.assertTrue(result)
def test_move_to_backwards(self): # earliest position (4,0,0) # move robot backward to position (0,0,0) commandX = weed.weed("robot_11", False) commandX.move_to(Point(0.0, 0.0, 0.0)) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > -0.5 ) & (data_from_callback.pose.pose.position.x < 0.5): result = True self.assertTrue(result)
def test_move_x_steps_backward(self): #Starting position is (-3,0,0) # move robot 3 meters using the method commandX = weed.weed("robot_11", False) commandX.move_x_steps(-3) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > -6.5) & (data_from_callback.pose.pose.position.x < -5.5): result = True self.assertTrue(result)
def test_move_to_backwards(self): # earliest position (4,0,0) # move robot backward to position (0,0,0) commandX = weed.weed("robot_11", False) commandX.move_to(Point(0.0, 0.0, 0.0)) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > -0.5) & (data_from_callback.pose.pose.position.x < 0.5): result = True self.assertTrue(result)
def test_move_x_steps(self): #Starting position is (0,0,0) # move robot 3 meters to on the direction he is facing (negative) commandX = weed.weed("robot_11", False) commandX.move_x_steps(3) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > -3.5 ) & (data_from_callback.pose.pose.position.x < -2.5): result = True self.assertTrue(result)
def test_move_x_steps(self): #Starting position is (0,0,0) # move robot 3 meters to on the direction he is facing (negative) commandX = weed.weed("robot_11", False) commandX.move_x_steps(3) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > -3.5) & (data_from_callback.pose.pose.position.x < -2.5): result = True self.assertTrue(result)
def test_move_to(self): # ensure that node starts from position 0 self.assertEquals(int(data_from_callback.pose.pose.position.x), 0.0) # Test method commandX = weed.weed("robot_11", False) commandX.move_to(Point(4.0, 0.0, 0.0)) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > 3.5 ) & (data_from_callback.pose.pose.position.x < 4.5): result = True self.assertTrue(result)
def test_move_to(self): # ensure that node starts from position 0 self.assertEquals(int(data_from_callback.pose.pose.position.x), 0.0) # Test method commandX = weed.weed("robot_11", False) commandX.move_to(Point(4.0, 0.0, 0.0)) # testing robot is in the correct position (allowing margin of error of <1) result = False if (data_from_callback.pose.pose.position.x > 3.5) & (data_from_callback.pose.pose.position.x < 4.5): result = True self.assertTrue(result)
def test_turn_left(self): commandX = weed.weed("robot_0", False) self.assertEqual(commandX.face_value(commandX.rad_orient), Face.East) commandX.turnLeft() self.assertEqual(commandX.face_value(commandX.rad_orient), Face.North)
def test_laser_switching(self): commandX = weed.weed("robot_11", False) self.assertEqual(commandX.laser_on, False) commandX.laser_on = True self.assertEqual(commandX.laser_on, True)
def test_laser_switching(self): commandX = weed.weed("robot_11", False) self.assertEqual(commandX.laser_on, False) commandX.laser_on = True self.assertEqual(commandX.laser_on , True)
def test_turn_left(self): commandX = weed.weed("robot_0", False) self.assertEqual(commandX.face_value(commandX.rad_orient),Face.East) commandX.turnLeft() self.assertEqual(commandX.face_value(commandX.rad_orient),Face.North)