Normalize Action Wrapper

Enviroment wrapper to normalize the action space.

Note

Only works for Box action spaces.

Example use

from kobuki_maze_rl.task_env import kobuki_maze
from frobs_rl.common import ros_gazebo
import gym
import rospy

from frobs_rl.wrappers.NormalizeActionWrapper import NormalizeActionWrapper

if __name__ == '__main__':

    # Launch Gazebo
    ros_gazebo.launch_Gazebo(paused=True, gui=False)

    # Start node
    rospy.logwarn("Start")
    rospy.init_node('kobuki_maze_train')

    # Launch the task environment
    env = gym.make('KobukiMazeEnv-v0')

    #--- Normalize action space
    env = NormalizeActionWrapper(env)

Wrapper documentation

class NormalizeActionWrapper.NormalizeActionWrapper(env)[source]

Wrapper to normalize the action space.

Parameters

env – (gym.Env) Gym environment that will be wrapped

rescale_action(scaled_action)[source]

Rescale the action from [-1, 1] to [low, high]

Parameters

scaled_action (np.ndarray) – The action to rescale.

Returns

The rescaled action.

Return type

np.ndarray

reset()[source]

Reset the environment

step(action)[source]
Parameters

action (floar or int) – Action taken by the agent

Returns

observation, reward, is the episode over, additional informations

Return type

(np.ndarray, float, bool, dict)