当前位置: 首页>>代码示例>>Python>>正文


Python testing.main函数代码示例

本文整理汇总了Python中morse.testing.testing.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了main函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUpEnv

    def setUpEnv(self):

        robot = ATRV()

        imu = IMU()
        robot.append(imu)
        imu_noised = IMU()
        imu_noised.alter("Noise", gyro_std=1, accel_std=1)
        robot.append(imu_noised)

        robot.add_default_interface("socket")
        env = Environment("empty", fastmode=True)
        env.add_interface("socket")

    def test_noised_imu(self):
        """ Test if the IMU data is noised
        """
        with Morse() as morse:
            d = morse.robot.imu.get()
            dn = morse.robot.imu_noised.get()
            for i in ["angular_velocity", "linear_acceleration"]:
                for j in range(0, 3):
                    self.assertNotAlmostEqual(d[i][j], dn[i][j], delta=0.001)


########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main

    main(NoiseTest)
开发者ID:chgrand,项目名称:morse,代码行数:30,代码来源:imu_noise_testing.py

示例2: send_ctrl

            self.assertAlmostEqual(pose['yaw'], 2 * delta_yaw, delta=0.1)
            self.assertAlmostEqual(pose['pitch'], 0.0, delta=0.1)
            self.assertAlmostEqual(pose['roll'], 0.0, delta=0.1)

            send_ctrl(cmd_client, 0.0, 0.0, 0.0, z)
            morse.sleep(1.0)
            pose = pose_stream.get()
            self.assertAlmostEqual(pose['x'], 0.0, delta=0.1)
            self.assertAlmostEqual(pose['y'], 0.0, delta=0.1)
            self.assertAlmostEqual(pose['z'], z, delta=0.2)
            self.assertAlmostEqual(pose['yaw'], 2 * delta_yaw, delta=0.2)
            self.assertAlmostEqual(pose['pitch'], 0.0, delta=0.1)
            self.assertAlmostEqual(pose['roll'], 0.0, delta=0.1)

            send_ctrl(cmd_client, 0.0, 0.0, -0.1, z)
            morse.sleep(1.0)
            pose = pose_stream.get()
            self.assertAlmostEqual(pose['x'], 0.0, delta=0.1)
            self.assertAlmostEqual(pose['y'], 0.0, delta=0.1)
            self.assertAlmostEqual(pose['z'], z, delta=0.2)
            self.assertAlmostEqual(pose['yaw'], delta_yaw, delta=0.2)
            self.assertAlmostEqual(pose['pitch'], 0.0, delta=0.1)
            self.assertAlmostEqual(pose['roll'], 0.0, delta=0.1)



########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(StabilizedQuadrirotorTest)
开发者ID:DAInamite,项目名称:morse,代码行数:30,代码来源:stabilized_quadrirotor_testing.py

示例3: main

            pos = gps_stream.get()
            pos_mod = gps_mod_stream.last()

            self.assertAlmostEqual(pos['x'], 100.0, delta=precision)
            self.assertAlmostEqual(pos['y'], 200.0, delta=precision)
            self.assertAlmostEqual(pos['z'], 50.0, delta=precision)
            self.assertAlmostEqual(pos_mod['x'], 43.6008970, delta=geodetic_precision)
            self.assertAlmostEqual(pos_mod['y'], 1.43510869, delta=geodetic_precision)
            self.assertAlmostEqual(pos_mod['z'], 185.0039, delta=precision)

            morse.deactivate('robot.teleport')
            teleport_mod_stream.publish({'x': 43.6000883, 'y': 1.433372470, 'z': 135.1000,  'yaw' : 0.0, 'pitch' : 0.0, 'roll': 0.0})
            morse.sleep(0.03)

            pos = gps_stream.get()
            pos_mod = gps_mod_stream.last()

            self.assertAlmostEqual(pos['x'], 10.0, delta=precision)
            self.assertAlmostEqual(pos['y'], 8.0, delta=precision)
            self.assertAlmostEqual(pos['z'], 0.1, delta=precision)

            self.assertAlmostEqual(pos_mod['x'], 43.6000883, delta=geodetic_precision)
            self.assertAlmostEqual(pos_mod['y'], 1.433372470, delta=geodetic_precision)
            self.assertAlmostEqual(pos_mod['z'], 135.1000, delta=precision)

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(GeodeticModifierTest)
开发者ID:HorvathJo,项目名称:morse,代码行数:29,代码来源:geodetic_testing.py

示例4: test_semantic_camera

    def test_semantic_camera(self):
        """ This test is guaranteed to be started only when the simulator
        is ready.
        """
        with Morse() as morse:
            # not enough argument
            with self.assertRaises(MorseServiceFailed):
                res = morse.rpc('communication', 'distance_and_view')

            # unknown robot does not exit
            with self.assertRaises(MorseServiceFailed):
                res = morse.rpc('communication', 'distance_and_view', 'mana', 'unknow_robot')
                
            res = morse.rpc('communication', 'distance_and_view', 'mana', 'minnie')
            self.assertAlmostEquals(res[0], 10.0, delta=0.01)
            self.assertTrue(res[1])

            res = morse.rpc('communication', 'distance_and_view', 'mana', 'munu')
            self.assertAlmostEquals(res[0], 10.0, delta=0.01)
            self.assertFalse(res[1])

            res = morse.rpc('communication', 'distance_and_view', 'minnie', 'munu')
            self.assertAlmostEquals(res[0], 20.0, delta=0.01)
            self.assertFalse(res[1])

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(Communication_Service_Testing)
开发者ID:Greg8978,项目名称:morse_MaRDi,代码行数:29,代码来源:communication_service_testing.py

示例5: position

            bat_stream = morse.robot.barometer
            teleport_stream = morse.robot.teleport

            bat = bat_stream.get()
            self.assertAlmostEqual(bat['pressure'], 101325.0, delta = 0.1)

            # pressure is independant of position (x,y)
            send_pose(teleport_stream, 5.0, 2.0, 0.0)
            morse.sleep(0.01)
            bat = bat_stream.get()
            self.assertAlmostEqual(bat['pressure'], 101325.0, delta = 0.1)

            # Pressure computed from
            # http://www.digitaldutch.com/atmoscalc/

            send_pose(teleport_stream, 0.0, 0.0, 100.0)
            morse.sleep(0.01)
            bat = bat_stream.get()
            self.assertAlmostEqual(bat['pressure'], 100129.0, delta = 0.1)

            send_pose(teleport_stream, 0.0, 0.0, 1000.0)
            morse.sleep(0.01)
            bat = bat_stream.get()
            self.assertAlmostEqual(bat['pressure'], 89871.0, delta = 0.1)

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(BarometerTest)

开发者ID:HorvathJo,项目名称:morse,代码行数:29,代码来源:barometer_testing.py

示例6: Morse

        IK_TARGET = "ik_target.robot.arm.kuka_7"

        with Morse() as simu:
            self.assertEqual(simu.robot.arm.list_IK_targets(), [IK_TARGET])
            self._check_pose(simu, 0., 0., 1.3105, 0.)

            simu.robot.arm.move_IK_target(IK_TARGET, [0,0,2], None, False).result() # absolute location
            self._check_pose(simu, 0., 0., 1.3105, 0.)

            simu.robot.arm.move_IK_target(IK_TARGET, [1,0,0.3105], None, False).result()
            self._check_pose(simu, 0.778, 0., 0.363, 0.02)

            simu.robot.arm.move_IK_target(IK_TARGET, [1,0,0.3105], [math.pi/2, -math.pi/2, -math.pi], False).result() # arm should be horizontal
            self._check_pose(simu, 1.0, 0., 0.3105, math.radians(90))

            # back to original position
            simu.robot.arm.move_IK_target(IK_TARGET, [0,0,2], [math.pi/2, 0., -math.pi], False).result() # absolute location
            self._check_pose(simu, 0., 0., 1.3105, 0.)

            simu.robot.arm.move_IK_target(IK_TARGET, [-1, 0, -1.6895], None).result() # relative position
            self._check_pose(simu, -0.778, 0., 0.363, -0.02)

            simu.robot.arm.move_IK_target(IK_TARGET, [0.,0.,0.], [0., -math.pi/2, 0.]).result() # relative rotation
            self._check_pose(simu, -1.0, 0., 0.3105, -math.radians(90))

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(ArmatureTest)
开发者ID:HorvathJo,项目名称:morse,代码行数:29,代码来源:armature_testing.py

示例7: Environment

        sick.create_laser_arc()

        env = Environment('indoors-1/boxes', fastmode=True)

    def test_sick_laser(self):
        rospy.init_node('morse_ros_laser_testing', log_level=rospy.DEBUG)

        motion_topic = '/robot/motion'
        laser_topic  = '/robot/sick'

        pub_vw(motion_topic, 1, 1)

        old = []
        for step in range(5):
            msg = rospy.wait_for_message(laser_topic, LaserScan, 10)

            self.assertEqual(len(msg.ranges), 181) # 180 + center ray
            self.assertNotEqual(msg.ranges, old)
            old = msg.ranges
            # assert that : near <= distance <= far
            for distance in msg.ranges:
                self.assertGreaterEqual(distance, 0.1)
                self.assertLessEqual(distance, 30)

            time.sleep(0.2) # wait for turning

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(SickLaserRosTest, time_modes = [TimeStrategies.BestEffort])
开发者ID:adegroote,项目名称:morse,代码行数:30,代码来源:sick.py

示例8: Morse

        IK_TARGET = "ik_target.robot.arm.kuka_7"

        with Morse() as simu:
            self.assertEqual(simu.robot.arm.list_IK_targets(), [IK_TARGET])
            self._check_pose(simu, 0., 0., 1.3105, 0.)

            simu.robot.arm.move_IK_target(IK_TARGET, [0,0,2], None, False).result() # absolute location
            self._check_pose(simu, 0., 0., 1.3105, 0.)

            simu.robot.arm.move_IK_target(IK_TARGET, [1,0,0.3105], None, False).result()
            self._check_pose(simu, 0.778, 0., 0.363, 0.02)

            simu.robot.arm.move_IK_target(IK_TARGET, [1,0,0.3105], [math.pi/2, -math.pi/2, -math.pi], False).result() # arm should be horizontal
            self._check_pose(simu, 1.0, 0., 0.3105, math.radians(90))

            # back to original position
            simu.robot.arm.move_IK_target(IK_TARGET, [0,0,2], [math.pi/2, 0., -math.pi], False).result() # absolute location
            self._check_pose(simu, 0., 0., 1.3105, 0.)

            simu.robot.arm.move_IK_target(IK_TARGET, [-1, 0, -1.6895], None).result() # relative position
            self._check_pose(simu, -0.778, 0., 0.363, -0.02)

            simu.robot.arm.move_IK_target(IK_TARGET, [0.,0.,0.], [0., -math.pi/2, 0.]).result() # relative rotation
            self._check_pose(simu, -1.0, 0., 0.3105, -math.radians(90))

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(ArmatureTest, time_modes = [TimeStrategies.BestEffort])
开发者ID:Greg8978,项目名称:morse,代码行数:29,代码来源:armature_testing.py

示例9: expected

        as expected (as if they were alone).
        This tests the particular wheel parenting mechanism used on
        this robot when several instance are present.
        """
        with Morse() as morse:

            pose1_stream = morse.robot1.pose1
            pose2_stream = morse.robot2.pose2

            pose1_x = pose1_stream.get()["x"]
            self.assertAlmostEqual(pose1_x, 0.0, delta=0.03)

            pose2_x = pose2_stream.get()["x"]
            self.assertAlmostEqual(pose2_x, 0.0, delta=0.03)

            set_speed(morse.robot1.motion1, morse, 1.0, 0.0, 2.0)
            set_speed(morse.robot2.motion2, morse, 1.0, 0.0, 2.0)

            pose1_x = pose1_stream.get()["x"]
            self.assertAlmostEqual(pose1_x, 2.0, delta=0.10)

            pose2_x = pose2_stream.get()["x"]
            self.assertAlmostEqual(pose2_x, 2.0, delta=0.10)


########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main

    main(TwoRMP400Test)
开发者ID:thesourcerer8,项目名称:morse,代码行数:30,代码来源:two_segways.py

示例10: main

            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sync:
                sync.connect(('localhost', 5000))

                # Now the clock is blocked until we triggered it.
                # Checking it :)
                time.sleep(0.2)
                prev_clock = clock_stream.last()
                time.sleep(0.2)
                clock = clock_stream.last()
                self.assertTrue(clock['timestamp'] == prev_clock['timestamp'])

                # triggering once
                sync.send(bytes('foo', 'utf-8'))
                clock = clock_stream.get()
                self.assertAlmostEqual(clock['timestamp'] - prev_clock['timestamp'], 0.1, delta = 0.0001)

                # So cool, isn't it :)
                # Close the socket, no more control 

            prev_clock = clock_stream.last()
            time.sleep(0.2)
            clock = clock_stream.last()

            self.assertTrue(clock['timestamp'] > prev_clock['timestamp'])

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(SocketSyncTest, time_modes = [TimeStrategies.FixedSimulationStep])
开发者ID:HorvathJo,项目名称:morse,代码行数:29,代码来源:socket_sync_testing.py

示例11: range

            self.assertAlmostEqual(pose['y'], 8.0, delta=self.precision)
            self.assertAlmostEqual(pose['z'], 20.0, delta=self.precision)

            # Test only one rotation each time, otherwise, it a bit more
            # complex to check that it does the good transformation
            # (without a matrix transformation library)
            for i in range(0, 5):
                self._test_one_pose(random.uniform(-30.0, 30.0),
                                    random.uniform(-30.0, 30.0),
                                    random.uniform(10.0, 50.0),
                                    random.uniform(-math.pi, math.pi),
                                    0, 0)
                self._test_one_pose(random.uniform(-30.0, 30.0),
                                    random.uniform(-30.0, 30.0),
                                    random.uniform(10.0, 50.0),
                                    0,
                                    random.uniform(-math.pi, math.pi),
                                    0)
                self._test_one_pose(random.uniform(-30.0, 30.0),
                                    random.uniform(-30.0, 30.0),
                                    random.uniform(10.0, 50.0),
                                    0, 0,
                                    random.uniform(-math.pi, math.pi))



########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(TeleportTest)
开发者ID:Greg8978,项目名称:morse_MaRDi,代码行数:30,代码来源:teleport_testing.py

示例12: range

            # search the green block in the image
            cam = cam_stream.get()
            for i in range(320*240):
                o = cam['image'][i]
                # Value computed with gimp help ...
                if (o['r'] < 5 and o['g'] > 110 and o['b'] < 5):
                    res.append(i)

            self.assertEqual(len(res), 0)

            # Now, illuminate the scene
            light_stream.publish({"emit": True})

            morse.sleep(2.0)
            cam = cam_stream.get()
            # search the green block in the image
            for i in range(320*240):
                o = cam['image'][i]
                # Value computed with gimp help ...
                if (o['r'] < 5 and o['g'] > 110 and o['b'] < 5):
                    res.append(i)

            self.assertTrue(len(res) > 10000)


########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(LightTest)
开发者ID:lakky,项目名称:morse,代码行数:29,代码来源:light_testing.py

示例13: PR2JointStateTest

class PR2JointStateTest(RosTestCase):

    # from the output of "rostopic echo /joint_states" on the PR2
    pr2_joints_list = ['fl_caster_rotation_joint', 'fl_caster_l_wheel_joint', 'fl_caster_r_wheel_joint', 'fr_caster_rotation_joint', 'fr_caster_l_wheel_joint', 'fr_caster_r_wheel_joint', 'bl_caster_rotation_joint', 'bl_caster_l_wheel_joint', 'bl_caster_r_wheel_joint', 'br_caster_rotation_joint', 'br_caster_l_wheel_joint', 'br_caster_r_wheel_joint', 'torso_lift_joint', 'torso_lift_motor_screw_joint', 'head_pan_joint', 'head_tilt_joint', 'laser_tilt_mount_joint', 'r_upper_arm_roll_joint', 'r_shoulder_pan_joint', 'r_shoulder_lift_joint', 'r_forearm_roll_joint', 'r_elbow_flex_joint', 'r_wrist_flex_joint', 'r_wrist_roll_joint', 'r_gripper_joint', 'r_gripper_l_finger_joint', 'r_gripper_r_finger_joint', 'r_gripper_r_finger_tip_joint', 'r_gripper_l_finger_tip_joint', 'r_gripper_motor_screw_joint', 'r_gripper_motor_slider_joint', 'l_upper_arm_roll_joint', 'l_shoulder_pan_joint', 'l_shoulder_lift_joint', 'l_forearm_roll_joint', 'l_elbow_flex_joint', 'l_wrist_flex_joint', 'l_wrist_roll_joint', 'l_gripper_joint', 'l_gripper_l_finger_joint', 'l_gripper_r_finger_joint', 'l_gripper_r_finger_tip_joint', 'l_gripper_l_finger_tip_joint', 'l_gripper_motor_screw_joint', 'l_gripper_motor_slider_joint']

    def setUpEnv(self):
        print("Adding a PR2 robot...")
        pr2 = BasePR2()
        pr2.add_interface("ros")

        env = Environment('empty', fastmode = True)
        env.aim_camera([1.0470, 0, 0.7854])


    def test_base_jointstates(self):
        rospy.loginfo("Creating listener node to check if posture of PR2 is published.")
        rospy.init_node('pr2_jointstate_listener', log_level = rospy.DEBUG, disable_signals=True)
        rospy.loginfo("Subscribing to pr2_posture topic.")
        jointstate_msg = rospy.client.wait_for_message("joint_states", JointState)
        name_len = len(jointstate_msg.name)
        pos_len = len(jointstate_msg.position)
        rospy.loginfo("Checking if number of jointstate names equals number of jointstate positions.")
        self.assertEqual(pos_len, name_len, 'Found %s jointstate names but %s jointstate positions. Please check the configuration of your pr2_posture sensor and middleware!'%(name_len, pos_len))
        rospy.loginfo("Checking is every jointstate is present.")
        self.assertEqual(set(self.pr2_joints_list), set(jointstate_msg.name), 'Could not find all joints of the PR2. Please check if you named the joints correctly in your pr2_posture sensor and middleware!' )

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(PR2JointStateTest)
开发者ID:Greg8978,项目名称:morse,代码行数:30,代码来源:jointstate_ros.py

示例14: Morse

        """
        with Morse() as morse:
            semantic_stream = morse.robot.camera
            teleport_client = morse.robot.motion

            o = semantic_stream.get()
            objects= o['visible_objects']
            self.assertEqual(objects, [])

            # Change the orientation of the robot using the v_w socket
            send_dest(teleport_client, morse, -5.0, 0.0, math.pi)

            # Second test for the sensor, with objects in front
            o = semantic_stream.get()
            objects= o['visible_objects']
            self.assertEqual(len(objects), 1)
            self.assertEqual(objects[0]['name'],'RedBox')
            # RedBox in camera frame:
            position = [0, -0.2, 2.2]
            quaternion = {'x':0.5, 'y':0.5, 'z':-0.5, 'w':0.5}
            # quaternion is equal to euler (pi, pi, 0) in XYZ mode
            for i in [0,1,2]:
                self.assertAlmostEqual(objects[0]['position'][i], position[i], delta=0.1)
            for i in ['x', 'y', 'z', 'w']:
                self.assertAlmostEqual(objects[0]['orientation'][i], quaternion[i], delta=.1)

########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(Semantic_Camera_Test)
开发者ID:DAInamite,项目名称:morse,代码行数:30,代码来源:semantic_camera_relative_testing.py

示例15: main

        ######

        # sending again the goal, and ask for cancellation
        self.cb_fired = False
        client.send_goal(goal1, done_cb = self.cb_preempted)
        time.sleep(1)
        client.cancel_goal()
        self.check_not_moving()
        self.assertTrue(self.cb_fired)
        ######

        # sending again the goal, this time, interrupted by another one
        self.cb_fired = False
        client.send_goal(goal1, done_cb = self.cb_preempted)
        time.sleep(1)
        client2.send_goal(goal2, done_cb = self.cb_succeeded)
        time.sleep(0.5)
        self.assertTrue(self.cb_fired)
        self.cb_fired = False
        time.sleep(5)
        self.assertTrue(self.cb_fired)
        ######




########################## Run these tests ##########################
if __name__ == "__main__":
    from morse.testing.testing import main
    main(RosActionsTest)
开发者ID:DAInamite,项目名称:morse,代码行数:30,代码来源:actions.py


注:本文中的morse.testing.testing.main函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。