Пример #1
0
    def test_get_car_heading_error(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (2, 0), (2, 2), (0, 2), (0, 0),
                                    (2, 2), (4, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 0)

        params_test['closest_waypoints'] = [1, 2]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 90)

        params_test['closest_waypoints'] = [2, 3]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 180)

        params_test['closest_waypoints'] = [3, 4]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), -90)

        params_test['closest_waypoints'] = [4, 5]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), 45)

        params_test['closest_waypoints'] = [5, 6]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_car_heading_error(), -45)
Пример #2
0
 def test_get_way_points_distance(self):
     params_test = get_test_params()
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_way_points_distance((0, 0), (2, 0)), 2)
     self.assertEqual(rf.get_way_points_distance((0, 0), (2, 2)),
                      math.sqrt(8))
     self.assertEqual(rf.get_way_points_distance((-2, 4), (-4, 2)),
                      math.sqrt(8))
     self.assertEqual(rf.get_way_points_distance((0, 0), (1, 0)), 1)
Пример #3
0
 def test_get_heading_beetween_waypoints(self):
     params_test = get_test_params()
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (2, 0)), 0)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (0, 2)), 90)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (0, -2)),
                      -90)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (2, 2)), 45)
     self.assertEqual(rf.get_heading_between_waypoints((0, 0), (-2, -2)),
                      -135)
Пример #4
0
 def test_get_optimum_speed_ratio(self):
     params_test = get_test_params()
     params_test['heading'] = 0
     params_test['distance_from_center'] = 0
     params_test['steering_angle'] = 0
     params_test['closest_waypoints'] = (0, 1)
     params_test['x'] = params_test['waypoints'][
         params_test['closest_waypoints'][0]][0]
     params_test['y'] = params_test['waypoints'][
         params_test['closest_waypoints'][0]][1]
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_optimum_speed_ratio(), 1.0)
Пример #5
0
 def test_get_waypoint(self):
     params_test = get_test_params()
     params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 3)]
     rf = AwsDeepRacerReward(params_test)
     self.assertEqual(rf.get_way_point(0), (0, 0))
     self.assertEqual(rf.get_way_point(1), (1, 0))
     self.assertEqual(rf.get_way_point(2), (2, 0))
     self.assertEqual(rf.get_way_point(3), (3, 3))
     self.assertEqual(rf.get_way_point(4), (0, 0))
     self.assertEqual(rf.get_way_point(5), (1, 0))
     self.assertEqual(rf.get_way_point(-1), (3, 3))
     self.assertEqual(rf.get_way_point(-2), (2, 0))
     self.assertEqual(rf.get_way_point(-3), (1, 0))
Пример #6
0
    def test_get_expected_turn_direction(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 1), (4, 1),
                                    (5, 1), (6, -6), (-1, -6), (-1, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_expected_turn_direction(), 'LEFT')

        params_test['closest_waypoints'] = [3, 4]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_expected_turn_direction(), 'RIGHT')

        params_test['closest_waypoints'] = [8, 0]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_expected_turn_direction(), 'STRAIGHT')
Пример #7
0
    def test_get_turn_angle(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 1), (4, 1),
                                    (5, 1), (6, -6), (-1, -6), (-1, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), 0)

        params_test['closest_waypoints'] = [1, 2]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), 0)

        params_test['closest_waypoints'] = [2, 3]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), 45)

        params_test['closest_waypoints'] = [5, 6]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.get_turn_angle(), -81.86989764584403)
Пример #8
0
    def test_is_in_turn(self):
        params_test = get_test_params()
        params_test['heading'] = 0
        params_test['waypoints'] = [(0, 0), (1, 0), (2, 0), (3, 1), (4, 1),
                                    (5, 1), (6, -6), (-1, -6), (-1, 0)]

        params_test['closest_waypoints'] = [0, 1]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), False)

        params_test['closest_waypoints'] = [1, 2]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), False)

        params_test['closest_waypoints'] = [2, 3]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), True)

        params_test['closest_waypoints'] = [5, 6]
        rf = AwsDeepRacerReward(params_test)
        self.assertEqual(rf.is_in_turn(), True)
Пример #9
0
import torch

import params
from lavse.data.loaders import get_loader
from lavse.model import model
from lavse.train.train import Trainer
from lavse.utils import file_utils, helper
from lavse.utils.logger import create_logger
from run import load_yaml_opts, parse_loader_name
from tqdm import tqdm

if __name__ == '__main__':
    # mp.set_start_method('spawn')

    # loader_name = 'precomp'
    args = params.get_test_params()
    opt = load_yaml_opts(args.options)
    # init_distributed_mode(args)s

    logger = create_logger(level='debug' if opt.engine.debug else 'info')

    logger.info(f'Used args   : \n{args}')
    logger.info(f'Used options: \n{opt}')

    if 'DATA_PATH' not in os.environ:
        data_path = opt.dataset.data_path
    else:
        data_path = os.environ['DATA_PATH']

    ngpu = torch.cuda.device_count()
Пример #10
0
import torch
import numpy as np
from pathlib import Path

from params import get_test_params
from retrieval.train import evaluation
from retrieval.data.loaders import get_loader
from retrieval.utils.logger import create_logger
from run import load_model, get_data_path, get_tokenizers
from retrieval.utils.file_utils import save_json, load_yaml_opts, parse_loader_name

if __name__ == '__main__':
    args = get_test_params(ensemble=True)
    opt = load_yaml_opts(args.options[0])
    logger = create_logger(level='debug' if opt.engine.debug else 'info')

    logger.info(f'Used args   : \n{args}')
    logger.info(f'Used options: \n{opt}')

    train_data = opt.dataset.train_data

    data_path = get_data_path(opt)

    data_name, lang = parse_loader_name(opt.dataset.train.data)

    loader = get_loader(
        data_split=args.data_split,
        data_path=data_path,
        data_info=opt.dataset.train.data,
        loader_name=opt.dataset.loader_name,
        local_rank=args.local_rank,