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


Python UasTelemetry.uas_heading方法代码示例

本文整理汇总了Python中auvsi_suas.models.uas_telemetry.UasTelemetry.uas_heading方法的典型用法代码示例。如果您正苦于以下问题:Python UasTelemetry.uas_heading方法的具体用法?Python UasTelemetry.uas_heading怎么用?Python UasTelemetry.uas_heading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在auvsi_suas.models.uas_telemetry.UasTelemetry的用法示例。


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

示例1: create_uas_logs

# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import uas_heading [as 别名]
    def create_uas_logs(self, user, entries):
        """Create a list of uas telemetry logs.

        Args:
            user: User to create logs for.
            entries: List of (lat, lon, alt) tuples for each entry.

        Returns:
            List of UasTelemetry objects
        """
        ret = []

        for (lat, lon, alt) in entries:
            pos = GpsPosition()
            pos.latitude = lat
            pos.longitude = lon
            pos.save()
            apos = AerialPosition()
            apos.altitude_msl = alt
            apos.gps_position = pos
            apos.save()
            log = UasTelemetry()
            log.user = user
            log.uas_position = apos
            log.uas_heading = 0
            log.save()
            ret.append(log)

        return ret
开发者ID:Dronolab,项目名称:interop,代码行数:31,代码来源:mission_config_test.py

示例2: test_out_of_bounds

# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import uas_heading [as 别名]
    def test_out_of_bounds(self):
        """Tests the UAS out of bounds method."""
        (zone_details, uas_details) = TESTDATA_FLYZONE_EVALBOUNDS
        # Create FlyZone objects
        zones = []
        for (alt_min, alt_max, wpts) in zone_details:
            zone = FlyZone()
            zone.altitude_msl_min = alt_min
            zone.altitude_msl_max = alt_max
            zone.save()
            for wpt_id in xrange(len(wpts)):
                (lat, lon) = wpts[wpt_id]
                gpos = GpsPosition()
                gpos.latitude = lat
                gpos.longitude = lon
                gpos.save()
                apos = AerialPosition()
                apos.gps_position = gpos
                apos.altitude_msl = 0
                apos.save()
                wpt = Waypoint()
                wpt.order = wpt_id
                wpt.position = apos
                wpt.save()
                zone.boundary_pts.add(wpt)
            zone.save()
            zones.append(zone)

        # For each user, validate time out of bounds
        user_id = 0
        epoch = timezone.now().replace(year=1970,
                                       month=1,
                                       day=1,
                                       hour=0,
                                       minute=0,
                                       second=0,
                                       microsecond=0)
        for exp_violations, exp_out_of_bounds_time, log_details in uas_details:
            # Create the logs
            user = User.objects.create_user('testuser%d' % user_id,
                                            '[email protected]', 'testpass')
            user_id += 1
            uas_logs = []
            for (lat, lon, alt, timestamp) in log_details:
                gpos = GpsPosition()
                gpos.latitude = lat
                gpos.longitude = lon
                gpos.save()
                apos = AerialPosition()
                apos.gps_position = gpos
                apos.altitude_msl = alt
                apos.save()
                log = UasTelemetry()
                log.user = user
                log.uas_position = apos
                log.uas_heading = 0
                log.save()
                log.timestamp = epoch + datetime.timedelta(seconds=timestamp)
                log.save()
                uas_logs.append(log)
            # Assert out of bounds time matches expected
            num_violations, out_of_bounds_time = \
                FlyZone.out_of_bounds(zones, uas_logs)
            self.assertEqual(num_violations, exp_violations)
            self.assertAlmostEqual(out_of_bounds_time, exp_out_of_bounds_time)
开发者ID:auvsi-suas,项目名称:interop,代码行数:67,代码来源:fly_zone_test.py

示例3: test_evaluate_collision_with_uas

# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import uas_heading [as 别名]
    def test_evaluate_collision_with_uas(self):
        """Tests the collision with UAS method."""
        # Get test data
        user = User.objects.create_user('testuser', '[email protected]',
                                        'testpass')
        user.save()
        testdata = TESTDATA_MOVOBST_EVALCOLLISION
        (obst_rad, obst_speed, obst_pos, log_details) = testdata
        # Create the obstacle
        obst = MovingObstacle()
        obst.speed_avg = obst_speed
        obst.sphere_radius = obst_rad
        obst.save()
        for pos_id in xrange(len(obst_pos)):
            (lat, lon, alt) = obst_pos[pos_id]
            gpos = GpsPosition()
            gpos.latitude = lat
            gpos.longitude = lon
            gpos.save()
            apos = AerialPosition()
            apos.gps_position = gpos
            apos.altitude_msl = alt
            apos.save()
            wpt = Waypoint()
            wpt.order = pos_id
            wpt.position = apos
            wpt.save()
            obst.waypoints.add(wpt)
        obst.save()
        # Create sets of logs
        epoch = timezone.now().replace(year=1970,
                                       month=1,
                                       day=1,
                                       hour=0,
                                       minute=0,
                                       second=0,
                                       microsecond=0)
        inside_logs = []
        outside_logs = []
        for (time_sec, inside_pos, outside_pos) in log_details:
            log_time = epoch + datetime.timedelta(seconds=time_sec)
            logs_pos = [(inside_pos, inside_logs), (outside_pos, outside_logs)]
            for (positions, log_list) in logs_pos:
                for (lat, lon, alt) in positions:
                    gpos = GpsPosition()
                    gpos.latitude = lat
                    gpos.longitude = lon
                    gpos.save()
                    apos = AerialPosition()
                    apos.gps_position = gpos
                    apos.altitude_msl = alt
                    apos.save()
                    log = UasTelemetry()
                    log.user = user
                    log.uas_position = apos
                    log.uas_heading = 0
                    log.save()
                    log.timestamp = log_time
                    log.save()
                    log_list.append(log)

        # Assert the obstacle correctly computes collisions
        log_collisions = [(True, inside_logs), (False, outside_logs)]
        for (inside, logs) in log_collisions:
            self.assertEqual(obst.evaluate_collision_with_uas(logs), inside)
            for log in logs:
                self.assertEqual(
                    obst.evaluate_collision_with_uas([log]), inside)
开发者ID:legonigel,项目名称:interop,代码行数:70,代码来源:moving_obstacle_test.py

示例4: test_interpolated_collision

# 需要导入模块: from auvsi_suas.models.uas_telemetry import UasTelemetry [as 别名]
# 或者: from auvsi_suas.models.uas_telemetry.UasTelemetry import uas_heading [as 别名]
    def test_interpolated_collision(self):
        # Get test data
        user = User.objects.create_user('testuser', '[email protected]',
                                        'testpass')
        user.save()
        utm = distance.proj_utm(zone=18, north=True)
        (obst_rad, obst_speed, obst_pos, log_details) = TESTDATA_MOVOBST_INTERP
        # Create the obstacle
        obst = MovingObstacle()
        obst.speed_avg = obst_speed
        obst.sphere_radius = obst_rad
        obst.save()
        for pos_id in xrange(len(obst_pos)):
            (lat, lon, alt) = obst_pos[pos_id]
            gpos = GpsPosition()
            gpos.latitude = lat
            gpos.longitude = lon
            gpos.save()
            apos = AerialPosition()
            apos.gps_position = gpos
            apos.altitude_msl = alt
            apos.save()
            wpt = Waypoint()
            wpt.order = pos_id
            wpt.position = apos
            wpt.save()
            obst.waypoints.add(wpt)
        obst.save()

        for (inside, log_list) in log_details:
            logs = []
            for i in range(len(log_list)):
                lat, lon, alt = log_list[i]
                pos = GpsPosition()
                pos.latitude = lat
                pos.longitude = lon
                pos.save()
                apos = AerialPosition()
                apos.altitude_msl = alt
                apos.gps_position = pos
                apos.save()
                log = UasTelemetry()
                log.user = user
                log.uas_position = apos
                log.uas_heading = 0
                log.save()
                if i == 0:
                    log.timestamp = timezone.now().replace(year=1970,
                                                           month=1,
                                                           day=1,
                                                           hour=0,
                                                           minute=0,
                                                           second=0,
                                                           microsecond=0)
                if i > 0:
                    log.timestamp = (
                        logs[i - 1].timestamp + datetime.timedelta(seconds=1))
                logs.append(log)
            self.assertEqual(
                obst.determine_interpolated_collision(logs[0], logs[1], utm),
                inside)
开发者ID:legonigel,项目名称:interop,代码行数:63,代码来源:moving_obstacle_test.py


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