### Run RocketSimVis Visualizer (Any Platform) Source: https://context7.com/zealanl/rocketsimvis/llms.txt Start the RocketSimVis application from the command line using the main Python script. This method is compatible with any platform where Python is installed. ```bash # Run visualizer (any platform) python src/main.py ``` -------------------------------- ### Programmatic Startup of RocketSimVis Visualizer Source: https://context7.com/zealanl/rocketsimvis/llms.txt Start the RocketSimVis visualizer programmatically by calling the 'main' function. This initializes the UDP socket listener and the OpenGL rendering window. ```python # Programmatic startup from src.main import main # Starts socket listener on port 9273 and opens visualization window # - Socket thread listens for JSON game states # - OpenGL window renders at monitor refresh rate # - Click to cycle through player cameras # - Press 'P' to switch to player closest to ball main() ``` -------------------------------- ### Run RocketSimVis Visualizer (Windows) Source: https://context7.com/zealanl/rocketsimvis/llms.txt Execute the provided batch script to run the RocketSimVis visualizer on Windows. This script likely handles starting the application and its dependencies. ```bash # Run visualizer (Windows) RUN.bat ``` -------------------------------- ### Integrate with rlgym-sim Source: https://github.com/zealanl/rocketsimvis/blob/main/README.md Add these lines to your rlgym-sim environment setup to enable visualization. This replaces the default render function with one that sends states to RocketSimVis. ```python # Add these lines right after "env = rlgym_sim.make( ..." import rocketsimvis_rlgym_sim_client as rsv type(env).render = lambda self: rsv.send_state_to_rocketsimvis(self._prev_state) # That's it! ``` -------------------------------- ### Install RocketSimVis Dependencies Source: https://context7.com/zealanl/rocketsimvis/llms.txt Install the necessary Python packages for RocketSimVis using pip. This command includes moderngl, PyOpenGL, numpy, and other required libraries. ```bash # Install dependencies pip install moderngl moderngl-window PyOpenGL pyrr numpy pywavefront pyqt5 ``` -------------------------------- ### Render Debug Lines for Trajectory Visualization Source: https://context7.com/zealanl/rocketsimvis/llms.txt Render debug lines in 3D space for visualizing trajectories or hitboxes. This example shows lines along the X, Y, and Z axes, and a diagonal line. ```python # Render debug lines for trajectory visualization debug_state = { "ball_phys": {"pos": [0, 0, 100], "vel": [0, 0, 0], "ang_vel": [0, 0, 0]}, "cars": [], "render": { "lines": [ {"start": [0, 0, 0], "end": [1000, 0, 0]}, {"start": [0, 0, 0], "end": [0, 1000, 0]}, {"start": [0, 0, 0], "end": [0, 0, 1000]}, {"start": [-500, -500, 0], "end": [500, 500, 0]} ] } } ``` -------------------------------- ### Send 2v2 Game State via UDP Source: https://context7.com/zealanl/rocketsimvis/llms.txt Demonstrates constructing a full 2v2 game state including ball physics, car states, and boost pads, then streaming it to the visualizer at 60Hz. ```python import socket import json import time import math UDP_IP = "127.0.0.1" UDP_PORT = 9273 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def create_game_state(t): """Generate animated game state for visualization testing.""" ball_x = math.sin(t) * 1000 ball_y = math.cos(t) * 1000 return { "gamemode": "soccar", "ball_phys": { "pos": [ball_x, ball_y, 100 + math.sin(t * 2) * 50], "forward": [math.cos(t), math.sin(t), 0], "up": [0, 0, 1], "vel": [math.cos(t) * 500, math.sin(t) * 500, 0], "ang_vel": [0, 0, 3] }, "cars": [ { # Blue player 1 "team_num": 0, "phys": { "pos": [-2000, -1000, 17], "forward": [1, 0, 0], "up": [0, 0, 1], "vel": [500, 0, 0], "ang_vel": [0, 0, 0] }, "boost_amount": 80, "on_ground": True, "is_demoed": False }, { # Blue player 2 "team_num": 0, "phys": { "pos": [-2000, 1000, 17], "forward": [1, 0, 0], "up": [0, 0, 1], "vel": [0, 0, 0], "ang_vel": [0, 0, 0] }, "boost_amount": 33, "on_ground": True, "is_demoed": False }, { # Orange player 1 "team_num": 1, "phys": { "pos": [2000, -1000, 17], "forward": [-1, 0, 0], "up": [0, 0, 1], "vel": [-500, 0, 0], "ang_vel": [0, 0, 0] }, "boost_amount": 100, "on_ground": True, "is_demoed": False }, { # Orange player 2 "team_num": 1, "phys": { "pos": [2000, 1000, 17], "forward": [-1, 0, 0], "up": [0, 0, 1], "vel": [0, 0, 0], "ang_vel": [0, 0, 0] }, "boost_amount": 50, "on_ground": True, "is_demoed": False } ], "boost_pad_states": [True] * 34 # Standard 34 boost pads } # Animation loop - send states at 60Hz t = 0 while True: state = create_game_state(t) sock.sendto(json.dumps(state).encode('utf-8'), (UDP_IP, UDP_PORT)) t += 1/60 time.sleep(1/60) ``` -------------------------------- ### POST /udp/game-state Source: https://context7.com/zealanl/rocketsimvis/llms.txt Sends a full game state update to the RocketSimVis visualizer via UDP. ```APIDOC ## UDP Port 9273 ### Description Sends a JSON-encoded game state to the visualizer. The visualizer processes this data to render the ball, cars, and boost pads in real-time. ### Method UDP Datagram ### Endpoint 127.0.0.1:9273 ### Request Body - **ball_phys** (object) - Required - Physics state of the ball. - **cars** (array) - Required - List of car state objects. - **boost_pad_states** (array) - Required - Boolean array indicating active/inactive status of boost pads. - **boost_pad_locations** (array) - Optional - Array of [x, y, z] coordinates for custom boost pad placement. ### Request Example { "ball_phys": { "pos": [0, 0, 100], "vel": [500, 200, 0], "ang_vel": [0, 0, 5] }, "cars": [ { "team_num": 0, "phys": { "pos": [-1000, 0, 17], "vel": [1000, 0, 0], "ang_vel": [0, 0, 0] }, "boost_amount": 75, "on_ground": true, "is_demoed": false } ], "boost_pad_states": [true, true, false] } ``` -------------------------------- ### POST /gamestate Source: https://github.com/zealanl/rocketsimvis/blob/main/networking-format.md Sends the current game state to the RocketSimVis renderer via UDP. ```APIDOC ## POST /gamestate ### Description Transmits the current physics state of the ball, cars, and boost pads to the visualizer. ### Method POST (UDP) ### Request Body - **ball_phys** (object) - Required - Physics state of the ball. - **cars** (array) - Required - List of car objects. - **boost_pad_locations** (array) - Optional - List of [x, y, z] coordinates for boost pads. - **boost_pad_states** (array) - Optional - List of booleans indicating if a boost pad is active. ### Physics State Object - **pos** (array) - Required - [x, y, z] position. - **forward** (array) - Optional - Normalized forward vector. - **up** (array) - Optional - Normalized upward vector. - **vel** (array) - Required - [x, y, z] velocity. - **ang_vel** (array) - Required - [x, y, z] angular velocity. ### Request Example { "ball_phys": { "pos": [0, 0, 0], "vel": [0, 0, 0], "ang_vel": [0, 0, 0] }, "cars": [ { "team_num": 0, "phys": { "pos": [10, 10, 0], "vel": [0, 0, 0], "ang_vel": [0, 0, 0] }, "boost_amount": 0.5, "on_ground": true, "is_demoed": false } ] } ``` -------------------------------- ### Boost Pad Configuration Source: https://context7.com/zealanl/rocketsimvis/llms.txt Allows customization of boost pad locations and states. If not provided, default locations are used. Big boost pads are identified by a z-coordinate of 73. ```python # Custom boost pad configuration game_state_with_boosts = { "ball_phys": {"pos": [0, 0, 100], "vel": [0, 0, 0], "ang_vel": [0, 0, 0]}, "cars": [], # Optional: Override default boost pad locations "boost_pad_locations": [ [0, -4240, 70], # Small boost (z=70) [-3072, -4096, 73], # Big boost (z=73) [3072, -4096, 73], # Big boost # ... add more locations ], # Required for boost pad rendering (matches location array length) "boost_pad_states": [True, False, True] # Active/inactive states } ``` -------------------------------- ### Configure Standard Soccar Game Mode Source: https://context7.com/zealanl/rocketsimvis/llms.txt Configure the standard 'soccar' game mode. This is the default mode and can be omitted if not explicitly setting other modes. ```python # Standard soccar mode (default) soccar_state = { "gamemode": "soccar", # or omit for default "ball_phys": {"pos": [0, 0, 92], "vel": [0, 0, 0], "ang_vel": [0, 0, 0]}, "cars": [] } ``` -------------------------------- ### Configure Camera Parameters Programmatically Source: https://context7.com/zealanl/rocketsimvis/llms.txt Set camera parameters like distance, height, and field of view programmatically using the Config class. These settings can also be adjusted via the UI at runtime. ```python # Camera configuration (set programmatically via Config class) from config import Config, ConfigVal config = Config() # Camera parameters with defaults config.camera_distance = ConfigVal(300, 100, 500) # Distance from car config.camera_height = ConfigVal(120, 0, 300) # Height above car config.camera_fov = ConfigVal(75, 20, 120) # Field of view (player cam) config.camera_bird_fov = ConfigVal(60, 20, 120) # FOV for stadium camera # Camera lean behavior (when looking up at ball) config.camera_lean_height_scale = ConfigVal(1.0, 0, 1) config.camera_lean_dist_scale = ConfigVal(0.1, 0, 1) config.camera_lean_min_height_clamp = ConfigVal(300, 0, 500) ``` -------------------------------- ### Send Game State via UDP Source: https://context7.com/zealanl/rocketsimvis/llms.txt This Python snippet demonstrates how to send a basic game state, including the ball and one car, to the RocketSimVis visualizer using UDP. Ensure the visualizer is listening on the specified IP and port. ```python import socket import json UDP_IP = "127.0.0.1" UDP_PORT = 9273 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Basic game state with ball and one car game_state = { "ball_phys": { "pos": [0, 0, 100], "forward": [1, 0, 0], "up": [0, 0, 1], "vel": [500, 200, 0], "ang_vel": [0, 0, 5] }, "cars": [ { "team_num": 0, # 0 = Blue, 1 = Orange "phys": { "pos": [-1000, 0, 17], "forward": [1, 0, 0], "up": [0, 0, 1], "vel": [1000, 0, 0], "ang_vel": [0, 0, 0] }, "boost_amount": 75, "on_ground": True, "is_demoed": False } ], "boost_pad_states": [True] * 34 # All boost pads active } # Send state to visualizer sock.sendto(json.dumps(game_state).encode('utf-8'), (UDP_IP, UDP_PORT)) ``` -------------------------------- ### Define full gamestate JSON structure Source: https://github.com/zealanl/rocketsimvis/blob/main/networking-format.md Defines the complete gamestate including the ball, car data, and optional boost pad configurations. Boost pad locations default to standard RLGym/RLBot ordering if not specified. ```json { "ball_phys": , "cars": [ { # Example car "team_num": <0 or 1>, # Blue = 0, orange = 1 "phys": , OPTIONAL "controls": { "throttle": , "seer": , "pitch": , "yaw": , "roll": , "boost": , "jump": , "handbrake": , }, "boost_amount": (from 0 to 1), "on_ground": , OPTIONAL "has_flipped_or_double_jumped": , "is_demoed": } ], # Use this to change the locations and number of boost pads # If you never set this, the visualizer will use the soccar boost locations with RLGym/RLBot ordering OPTIONAL "boost_pad_locations": [ [, , ], [, , ], ... ], # If you don't provide this, no boost pads will be rendered OPTIONAL "boost_pad_states": [ , , ... ] } ``` -------------------------------- ### RLGym-Sim Client Integration Source: https://context7.com/zealanl/rocketsimvis/llms.txt This snippet shows the import statement for the client module that integrates rlgym_sim with RocketSimVis. It converts GameState objects to the required JSON format and sends them via UDP. ```python # rocketsimvis_rlgym_sim_client.py usage import rlgym_sim import rocketsimvis_rlgym_sim_client as rsv ``` -------------------------------- ### Configure Heatseeker Game Mode with Ball Trails Source: https://context7.com/zealanl/rocketsimvis/llms.txt Set the game mode to 'heatseeker' to enable special ball ribbon trails that visualize ball speed. This configuration includes specific ball physics for demonstration. ```python # Heatseeker mode with ball trails heatseeker_state = { "gamemode": "heatseeker", # Enables ball ribbon trail effect "ball_phys": { "pos": [0, 2000, 200], "forward": [0, 1, 0], "up": [0, 0, 1], "vel": [0, 2500, 100], # Fast ball shows prominent trail "ang_vel": [0, 0, 0] }, "cars": [], "boost_pad_states": [True] * 34 } ``` -------------------------------- ### Patch rlgym_sim Render Method for RocketSimVis Source: https://context7.com/zealanl/rocketsimvis/llms.txt Patch the 'render' method of an rlgym_sim environment to send state data to RocketSimVis for visualization. This allows real-time state updates during simulation. ```python import rlgym_sim import rocketsimvis as rsv # Create your rlgym_sim environment env = rlgym_sim.make( # your environment configuration ) # Patch the render method to send state to RocketSimVis type(env).render = lambda self: rsv.send_state_to_rocketsimvis(self._prev_state) # Now env.render() will visualize the current state obs = env.reset() while True: action = agent.get_action(obs) obs, reward, done, info = env.step(action) env.render() # Sends state to RocketSimVis ``` -------------------------------- ### Car State Structure Source: https://context7.com/zealanl/rocketsimvis/llms.txt Represents the state of a car in the simulation. Includes team, physics data, boost amount, and optional controller inputs. The visualizer infers boosting and renders trails based on boost amount changes. ```python car_state = { "team_num": 1, # 0 = Blue team, 1 = Orange team "phys": { "pos": [2000, -3000, 17], "forward": [0, 1, 0], "up": [0, 0, 1], "vel": [0, 2300, 0], "ang_vel": [0, 0, 0] }, "controls": { # Optional controller input state "throttle": 1.0, "steer": 0.0, "pitch": 0.0, "yaw": 0.0, "roll": 0.0, "boost": True, "jump": False, "handbrake": False }, "boost_amount": 50, # 0-100 boost percentage "on_ground": True, "has_flipped_or_double_jumped": False, # Optional "is_demoed": False } ``` -------------------------------- ### Physics State Structure Source: https://context7.com/zealanl/rocketsimvis/llms.txt Defines the structure for physics states of objects like the ball and cars. It includes position, orientation vectors, linear velocity, and angular velocity. Rotation can be explicitly provided or computed from angular velocity. ```python # Full physics state with explicit rotation physics_state = { "pos": [100, 200, 50], # Position in world coordinates [x, y, z] "forward": [1, 0, 0], # Normalized forward direction vector "up": [0, 0, 1], # Normalized up direction vector "vel": [1500, 500, 100], # Linear velocity "ang_vel": [0.5, 0, 2.0] # Angular velocity (used if rotation not provided) } # Minimal physics state (rotation computed from angular velocity) minimal_physics_state = { "pos": [0, 0, 92], "vel": [0, 0, 0], "ang_vel": [0, 0, 3.14] # Ball will spin based on this } ``` -------------------------------- ### Define physics state JSON structure Source: https://github.com/zealanl/rocketsimvis/blob/main/networking-format.md Represents the physics state of an object, including position, velocity, and angular velocity. Rotation vectors are optional; if omitted, the visualizer tracks rotation internally using angular velocity. ```json # Physics state { "pos": [ , , ], OPTIONAL "forward": [ , , ], # Forward direction as a normalized vector OPTIONAL "up": [ , , ], # Upward direction as a normalized vector # NOTE: If rotation ("forward" and "up") are not provided, # the visualizer will track its own internal rotation for the object, # and update it with "ang_vel" every frame "vel": [ , , ], "ang_vel": [ , , ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.