def create_params():
    p = DotMap()

    # Load the dependencies
    p.system_dynamics_params = create_system_dynamics_params()
    p.waypoint_params = create_waypoint_params()

    # p.pipeline = ControlPipelineV0
    # New control pipeline v1 doesn't rescale the trajectory to maximize the speed
    p.pipeline = ControlPipelineV1

    # The directory for saving the control pipeline files
    # p.dir = '/home/anjianl/Desktop/project/WayPtNav/data/control_data/control_pipelines'
    # New control pipeline v1 doesn't rescale the trajectory to maximize the speed
    p.dir = '/home/anjianl/Desktop/project/WayPtNav/data/control_data/new_control_pipelines'

    # Spline parameters
    p.spline_params = DotMap(spline=Spline3rdOrder,
                             max_final_time=6.0,
                             epsilon=1e-5)
    # If planning a trajectory of 3s, it will be very greedy and oscillate a lot.
    # p.spline_params = DotMap(spline=Spline3rdOrder,
    #                          max_final_time=3.0,
    #                          epsilon=1e-5)
    p.minimum_spline_horizon = 1.5

    # LQR setting parameters
    p.lqr_params = DotMap(cost_fn=QuadraticRegulatorRef,
                          quad_coeffs=np.array([1.0, 1.0, 1.0, 1.0, 1.0],
                                               dtype=np.float32),
                          linear_coeffs=np.zeros((5), dtype=np.float32))

    # Velocity binning parameters
    p.binning_parameters = DotMap(
        num_bins=61,
        min_speed=p.system_dynamics_params.v_bounds[0],
        max_speed=p.system_dynamics_params.v_bounds[1])

    # Converting K to world coordinates is slow
    # so only set this to true when LQR data is needed
    p.convert_K_to_world_coordinates = False

    # When not needed, LQR controllers can be discarded
    # to save memory
    p.discard_LQR_controller_data = True

    # Set this to True to ignore precomputed
    # LQR trajectories
    p.discard_precomputed_lqr_trajectories = False

    # Set this to true if you want trajectory objects to track
    # linear and angular acceleration. If not set to false to save memory
    p.track_trajectory_acceleration = True

    p.verbose = False
    return p
def create_rgb_trainer_params():
    from params.simulator.sbpd_simulator_params import create_params as create_simulator_params
    from params.visual_navigation_trainer_params import create_params as create_trainer_params

    from params.waypoint_grid.sbpd_image_space_grid import create_params as create_waypoint_params
    from params.model.resnet50_arch_v1_params import create_params as create_model_params

    from params.reachability_map.reachability_map_params import create_params as create_reachability_map_params

    # Load the dependencies
    simulator_params = create_simulator_params()

    # Seed
    simulator_params.seed = 10

    # Ensure the waypoint grid is projected SBPD Grid
    simulator_params.planner_params.control_pipeline_params.waypoint_params = create_waypoint_params(
    )

    # Ensure the renderer modality is rgb
    simulator_params.obstacle_map_params.renderer_params.camera_params.modalities = [
        'rgb'
    ]
    simulator_params.obstacle_map_params.renderer_params.camera_params.img_channels = 3
    simulator_params.obstacle_map_params.renderer_params.camera_params.width = 1024
    simulator_params.obstacle_map_params.renderer_params.camera_params.height = 1024
    simulator_params.obstacle_map_params.renderer_params.camera_params.im_resize = 0.21875

    # Change episode horizon
    simulator_params.episode_horizon_s = 80.0

    # Ensure the renderer is using area3
    # TODO: When generating our own data, choose area 3, area4, area5
    #  When testing, choosing area 1
    simulator_params.obstacle_map_params.renderer_params.building_name = 'area4'
    # TODO: area3: thread='v1'; area4: thread='v2'; area5a: thread='v3'
    simulator_params.reachability_map_params.thread = 'v2'
    # specify reachability data dir name according to building_name and thread
    create_reachability_data_dir_params(
        simulator_params.reachability_map_params)

    # Save trajectory data
    simulator_params.save_trajectory_data = True

    # Choose cost function
    # TODO: in training, always use 'heuristics'
    # simulator_params.cost = 'heuristics'  # heuristics cost.
    simulator_params.cost = 'reachability'

    p = create_trainer_params(simulator_params=simulator_params)

    # Create the model params
    p.model = create_model_params()

    return p
def create_params():
    p = DotMap()

    # Load the dependencies
    p.system_dynamics_params = create_system_dynamics_params()
    p.waypoint_params = create_waypoint_params()

    p.pipeline = ControlPipelineV0

    # The directory for saving the control pipeline files
    p.dir = os.path.join(base_data_dir(), 'control_pipelines')

    # Spline parameters
    p.spline_params = DotMap(
        spline=Spline3rdOrder,
        max_final_time=10.0,  #60 crashes pc with 32Gb ram, 6 is default
        epsilon=1e-5)
    p.minimum_spline_horizon = 1.5  # default 1.5

    # LQR setting parameters
    p.lqr_params = DotMap(cost_fn=QuadraticRegulatorRef,
                          quad_coeffs=np.array([1.0, 1.0, 1.0, 1.0, 1.0],
                                               dtype=np.float32),
                          linear_coeffs=np.zeros((5), dtype=np.float32))

    # Velocity binning parameters
    p.binning_parameters = DotMap(
        num_bins=20,  # 61 crashes pc with 32gb ram, 15 is slow
        min_speed=p.system_dynamics_params.v_bounds[0],
        max_speed=p.system_dynamics_params.v_bounds[1])

    # Converting K to world coordinates is slow
    # so only set this to true when LQR data is needed
    p.convert_K_to_world_coordinates = False

    # When not needed, LQR controllers can be discarded
    # to save memory
    p.discard_LQR_controller_data = True

    # Set this to True to ignore precomputed
    # LQR trajectories
    p.discard_precomputed_lqr_trajectories = False

    # Set this to true if you want trajectory objects to track
    # linear and angular acceleration. If not set to false to save memory
    p.track_trajectory_acceleration = True

    p.verbose = True
    return p
def create_rgb_trainer_params():
    from params.simulator.sbpd_simulator_params import create_params as create_simulator_params
    from params.visual_navigation_trainer_params import create_params as create_trainer_params

    from params.waypoint_grid.sbpd_image_space_grid import create_params as create_waypoint_params
    from params.model.resnet50_arch_v1_params import create_params as create_model_params

    # Load the dependencies
    simulator_params = create_simulator_params()

    # Ensure the waypoint grid is projected SBPD Grid
    simulator_params.planner_params.control_pipeline_params.waypoint_params = create_waypoint_params(
    )

    # Ensure the renderer modality is rgb
    simulator_params.obstacle_map_params.renderer_params.camera_params.modalities = [
        'rgb'
    ]
    simulator_params.obstacle_map_params.renderer_params.camera_params.img_channels = 3
    simulator_params.obstacle_map_params.renderer_params.camera_params.width = 1024
    simulator_params.obstacle_map_params.renderer_params.camera_params.height = 1024
    simulator_params.obstacle_map_params.renderer_params.camera_params.im_resize = 0.21875

    # Ensure the renderer is using area1
    simulator_params.obstacle_map_params.renderer_params.building_name = 'area1'

    # Change the episode horizon
    simulator_params.episode_horizon_s = 80.0

    # Save trajectory data
    simulator_params.save_trajectory_data = True

    p = create_trainer_params(simulator_params=simulator_params)

    # Create the model params
    p.model = create_model_params()

    return p