Skip to content

Releases: nkiyohara/gymnasium-cartpole-swingup

v0.1.8: Fixed theta sign in visualization

Choose a tag to compare

@nkiyohara nkiyohara released this 13 Apr 17:42

Changes

  • Fixed theta sign in visualization
  • Added keyboard control example
  • Moved examples to dedicated directory

v0.1.7: Customizable Initial State

Choose a tag to compare

@nkiyohara nkiyohara released this 13 Apr 11:50

Add the ability to customize the initial state of the environment:

  • Add support for exact initial state specification via reset(options={"initial_state": [x, x_dot, theta, theta_dot]})
  • Add initialization parameters for customizing random start states:
    • initial_state_mean: Mean of initial state distribution
    • initial_state_noise: Standard deviation for each state component
  • Update documentation with examples
  • Add tests for new functionality

v0.1.6: Custom Reward Function Support

Choose a tag to compare

@nkiyohara nkiyohara released this 13 Apr 09:45

What's New

  • Custom Reward Function: Define your own reward functions to customize learning objectives
  • Simplified Versioning: Implemented single source of truth for package versioning

Custom Reward Example

# Define a custom reward function
def my_reward(state, action, next_state):
    x, x_dot, theta, theta_dot = next_state
    return np.cos(theta) * 2.0  # Reward upright pole position

# Use with environment
env = gym.make('CartPoleSwingUp-v0', custom_reward_fn=my_reward)

See the updated README for full documentation.

Release v0.1.5

Choose a tag to compare

@nkiyohara nkiyohara released this 11 Apr 22:20

New Features

  • Added observation mode selection
    • obs_mode="raw": Original state representation [x, x_dot, theta, theta_dot]
    • obs_mode="trig": Trigonometric representation [x, x_dot, sin(theta), cos(theta), theta_dot]

Usage

# Original state representation (raw theta value)
env = gym.make("CartPoleSwingUp-v0", obs_mode="raw")

# Trigonometric state representation (sin/cos transformation)
env = gym.make("CartPoleSwingUp-v0", obs_mode="trig")

v0.1.4: PILCO Reward Sign Fix

Choose a tag to compare

@nkiyohara nkiyohara released this 11 Apr 11:27

Changelog

  • 🐛 Fixed incorrect reward sign in PILCO mode
  • 📝 Updated documentation to correctly reflect reward = -cost calculation
  • 🧪 Ensured consistency between implementation and documentation

CartPole SwingUp v0.1.3 - Add PILCO cost mode

Choose a tag to compare

@nkiyohara nkiyohara released this 10 Apr 17:27

New Features

  • Dual Cost Functions: Added PILCO cost mode as an alternative to the default reward function
    • cost_mode="default": Original reward based on angle and position
    • cost_mode="pilco": PILCO-style reward based on pole tip position
    • Customizable sigma_c parameter for PILCO cost function width

Documentation

  • Updated README with detailed explanation of both cost functions
  • Added example code showing how to use the new parameters

Tests

  • Added tests for both cost modes to ensure correct behavior
  • Improved test coverage

Usage

# Default cost mode
env = gym.make("CartPoleSwingUp-v0", cost_mode="default")

# PILCO cost mode
env = gym.make("CartPoleSwingUp-v0", cost_mode="pilco", sigma_c=0.25)

CartPole SwingUp v0.1.2 - Updated Parameters

Choose a tag to compare

@nkiyohara nkiyohara released this 08 Apr 22:41

Changes

  • Updated default parameters to match reference implementation:
    • Pole length: 0.6m
    • Time step (dt): 0.1s
  • Changed observation space to use raw angle θ instead of trigonometric representation
  • Simplified state representation to [x, ẋ, θ, θ̇]

Under-actuated Cart-Pole Swing-Up

The cart-pole system is an under-actuated system with a freely swinging pendulum of 60 cm mounted on a cart. The swing-up and balancing task cannot be solved using a linear model. The cart-pole system state space consists of the position of the cart x, cart velocity ẋ, the angle θ of the pendulum and the angular velocity θ̇. A horizontal force u∈[-10,10] N can be applied to the cart.

Starting in a position where the pendulum hangs downwards, the objective is to automatically learn a controller that swings the pendulum up and balances it in the inverted position in the middle of the track.

CartPole SwingUp v0.1.1 - Customizable Physics

Choose a tag to compare

@nkiyohara nkiyohara released this 08 Apr 21:57

What's New

  • Added customizable physics parameters
  • Fixed package naming convention (underscores to hyphens)
  • Updated documentation

Parameters

env = gym.make(
    "CartPoleSwingUp-v0",
    gravity=9.81,        # Gravitational acceleration
    cart_mass=1.0,       # Cart mass
    pole_mass=0.1,       # Pole mass
    pole_length=0.5,     # Pole length
    force_mag=12.0,      # Force magnitude scale
    friction=0.05,       # Friction coefficient
    x_threshold=2.5,     # Position boundary
)

CartPole SwingUp v0.1.0 - Initial Release

Choose a tag to compare

@nkiyohara nkiyohara released this 08 Apr 21:38

Gymnasium CartPole SwingUp v0.1.0

Initial release of CartPole SwingUp environment for Gymnasium.

Features

  • Modified version of classic CartPole where the pole starts in a downward position
  • Compatible with Gymnasium API
  • Smooth rendering with Pygame
  • Realistic physics simulation

Installation

pip install gymnasium-cartpole-swingup

Example

import gymnasium as gym
import gymnasium_cartpole_swingup

env = gym.make("CartPoleSwingUp-v0", render_mode="human")
observation, info = env.reset()

for _ in range(1000):
    action = env.action_space.sample()  # Your agent goes here
    observation, reward, terminated, truncated, info = env.step(action)
    
    if terminated or truncated:
        observation, info = env.reset()