Basic Model

Basic model class which is inherited by all models supported by the FRobs_RL library.

class basic_model.BasicModel(env, save_model_path, log_path, ns='/', load_trained=False)[source]

Base class for all the algorithms supported by the frobs_rl library.

Parameters
  • env – The environment to be used.

  • save_model_path – The path to save the model.

  • log_path – The path to save the log.

  • ns – The namespace of the parameters.

  • load_trained – Whether or not to load a trained model.

check_env() bool[source]

Use the stable-baselines check_env method to check the environment.

Returns

True if the environment is correct, False otherwise.

Return type

bool

close_env() bool[source]

Use the env close method to close the environment.

Returns

True if the environment was closed, False otherwise.

Return type

bool

predict(observation, state=None, mask=None, deterministic=False)[source]

Get the current action based on the observation, state or mask

Parameters
  • observation (ndarray) – The enviroment observation

  • state (ndarray) – The previous states of the enviroment, used in recurrent policies.

  • mask (ndarray) – The mask of the last states, used in recurrent policies.

  • deterministic (bool) – Whether or not to return deterministic actions.

Returns

The action to be taken and the next state(for recurrent policies)

Return type

ndarray, ndarray

save_model() bool[source]

Function to save the model.

Returns

True if the model was saved, False otherwise.

Return type

bool

save_replay_buffer() bool[source]

Funtion to save the replay buffer, to be used the training must be finished or an error will be raised.

Returns

True if the replay buffer was saved, False otherwise.

Return type

bool

set_model_logger() bool[source]

Function to set the logger of the model.

Returns

True if the logger was set, False otherwise.

Return type

bool

train() bool[source]

Function to train the model the number of steps specified in the ROS parameter server. The function will automatically save the model after training.

Returns

True if the training was successful, False otherwise.

Return type

bool