visualizers.viser_app.controllers.sampling_base
#
Module Contents#
- visualizers.viser_app.controllers.sampling_base.MAX_NUM_TRACES = 5#
- class visualizers.viser_app.controllers.sampling_base.SamplingBaseConfig#
Bases:
jacta.visualizers.viser_app.controllers.controller.ControllerConfig
Base controller config with spline parameters. .. py:attribute:: horizon
- type:
float
- value:
1.0
- num_nodes: int = 3#
- num_rollouts: int = 32#
- spline_order: Literal[zero, slinear, cubic] = 'slinear'#
- control_freq: float = 20.0#
- use_noise_ramp: bool = False#
- class visualizers.viser_app.controllers.sampling_base.SamplingBase(task: jacta.visualizers.viser_app.tasks.task.Task, config: SamplingBaseConfig, reward_config: jacta.visualizers.viser_app.tasks.task.TaskConfig)#
Bases:
jacta.visualizers.viser_app.controllers.controller.Controller
Base class for all sampling controller implementations. .. py:property:: num_timesteps
- type:
int
Helper function to recalculate the number of timesteps for simulation
- Parameters:
task (jacta.visualizers.viser_app.tasks.task.Task) –
config (SamplingBaseConfig) –
reward_config (jacta.visualizers.viser_app.tasks.task.TaskConfig) –
- property rollout_times: numpy.ndarray#
Helper function to calculate the rollout times based on the horizon length
- Return type:
numpy.ndarray
- property spline_timesteps: numpy.ndarray#
Helper function to create new timesteps for spline queries.
- Return type:
numpy.ndarray
- property spline: scipy.interpolate.interp1d#
Spline defining the current control signal to be applied.
- Return type:
scipy.interpolate.interp1d
- property controls: numpy.ndarray#
Contains the control signals applied in the current rollout.
- Return type:
numpy.ndarray
- resize_data() None #
Resize states, sensors, and models to (config.num_rollouts, num_timesteps, …).
- Return type:
None
- abstract update_action(curr_state: numpy.ndarray, curr_time: float, additional_info: dict[str, Any]) None #
Abstract method for updating controller actions from current state/time.
- Parameters:
curr_state (numpy.ndarray) –
curr_time (float) –
additional_info (dict[str, Any]) –
- Return type:
None
- abstract action(time: float) numpy.ndarray #
Abstract method for querying current action from controller.
- Parameters:
time (float) –
- Return type:
numpy.ndarray
- update_spline(times: numpy.ndarray, controls: numpy.ndarray) None #
Update the spline with new timesteps / controls.
- Parameters:
times (numpy.ndarray) –
controls (numpy.ndarray) –
- Return type:
None
- set_default_controls() None #
Set default value for the Controller.controls. if there is no default value set to zero.
- Return type:
None
- reset() None #
Reset the controls, candidate controls and the spline to their default values.
- Return type:
None
- update_traces() None #
Update traces by extracting data from sensors readings.
We need to have num_spline_points - 1 line segments. Sensors will initially be of shape (num_rollout x num_timesteps * num_physics_substeps x nsensordata) and needs to end up being in shape (num_elite * num_trace_sensors * size of a single rollout x 2 (first and last point of spline) x 3 (3d pos))
- Return type:
None
- visualizers.viser_app.controllers.sampling_base.make_spline(times: numpy.ndarray, controls: numpy.ndarray, spline_order: str) scipy.interpolate.interp1d #
Helper function for creating spline objects.
- Parameters:
times (numpy.ndarray) – array of times for knot points, shape (T,).
controls (numpy.ndarray) – (possibly batched) array of controls to interpolate, shape (…, T, m).
spline_order (str) – Order to use for interpolation. Same as parameter for scipy.interpolate.interp1d.
extrapolate – Whether to allow extrapolation queries. Default true (for re-initialization).
- Return type:
scipy.interpolate.interp1d