Complete Restructered Robot Code
Robot into its own Class instead of lose Global Variables that cause circular imports StateClass usage instead of the old RobotState.py New Input Class for Controller and randome intputs
This commit is contained in:
+27
-17
@@ -1,12 +1,13 @@
|
||||
import pybullet as p
|
||||
"""
|
||||
simulation.py - PyBullet Simulation Interface & Standalone Runner
|
||||
"""
|
||||
import time
|
||||
import math
|
||||
import numpy as np
|
||||
import RobotState as rs
|
||||
import GlobalVariables as gv
|
||||
import pybullet as p
|
||||
|
||||
import config as cfg
|
||||
import DataTypes as dt
|
||||
import time
|
||||
import os
|
||||
import math
|
||||
|
||||
|
||||
class Simulation:
|
||||
@@ -54,15 +55,24 @@ class Simulation:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
count = 0
|
||||
current_rad: dt.RadArray = gv.init_deg.to_rad()
|
||||
gv.shared_sim.updatePos(current_rad)
|
||||
from Robot import Robot, PyBulletBackend
|
||||
|
||||
rs.walking()
|
||||
while True:
|
||||
count = +1
|
||||
gv.shared_sim.step()
|
||||
time.sleep(1 / 240)
|
||||
if count > 50:
|
||||
rs.walking()
|
||||
count = 0
|
||||
# 1. Initialize PyBullet simulation environment
|
||||
sim_instance = Simulation()
|
||||
backend = PyBulletBackend(sim_instance)
|
||||
|
||||
# 2. Instantiate Robot with simulation backend
|
||||
robot = Robot(backend=backend)
|
||||
robot.reset_to_init()
|
||||
|
||||
# 3. Command forward movement [vx, vy, omega]
|
||||
robot.vector_dirmov = [1.0, 0.0, 0.0]
|
||||
|
||||
# 4. Main test execution loop
|
||||
try:
|
||||
while True:
|
||||
# Executes state machine logic (Idle -> Walking -> Target Step -> Physics Step)
|
||||
robot.tick()
|
||||
time.sleep(1.0 / 60.0)
|
||||
except KeyboardInterrupt:
|
||||
sim_instance.disconnect()
|
||||
Reference in New Issue
Block a user