Hi,
I am trying to change the wheel size of my robot using python but I think I don’t know which correct API should I use that can change the shape of my robot’s wheel.
code I’m using:
I am using below code to change the shape of the wheels but getting below errors:
from pxr import UsdGeom, Gf
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.wheeled_robots.robots import WheeledRobot
from omni.isaac.core.utils.types import ArticulationAction
from omni.isaac.core.controllers import BaseController
import numpy as np
class CoolController(BaseController):
def init(self):
super().init(name=“my_cool_controller”)
self._wheel_radius = 0.03 # radius of the wheels
self._wheel_base = 0.1125 # distance between the two wheels
def forward(self, command):
""" Calculate the joint velocities needed to achieve the given command. """
joint_velocities = [0.0, 0.0] # initial velocities for both wheels
joint_velocities[0] = ((2 * command[0]) - (command[1] * self._wheel_base)) / (2 * self._wheel_radius)
joint_velocities[1] = ((2 * command[0]) + (command[1] * self._wheel_base)) / (2 * self._wheel_radius)
return ArticulationAction(joint_velocities=joint_velocities)
class HelloWorld(BaseSample):
def init(self):
super().init()
def setup_scene(self):
""" Sets up the scene with a robot and a ground plane. """
world = self.get_world()
world.scene.add_default_ground_plane()
jetbot_asset_path = "/home/msb/Downloads/ubuntu data/MSB_ISAAC_SIM/Enviroment/simple_robo.usd"
self.jetbot = world.scene.add(
WheeledRobot(
prim_path="/World/Fancy_Robot",
name="fancy_robot",
wheel_dof_names=["left_wheel_joint", "right_wheel_joint"],
create_robot=True,
usd_path=jetbot_asset_path,
)
)
async def setup_post_load(self):
""" Post load setup to initialize the robot and controller. """
self._world = self.get_world()
self._jetbot = self._world.scene.get_object("fancy_robot")
if self._jetbot is None:
print("Error: Robot not found in the scene.")
return
self._world.add_physics_callback("sending_actions", callback_fn=self.send_robot_actions)
self._my_controller = CoolController()
def send_robot_actions(self, step_size):
""" Applies calculated actions to the robot. """
if not self._jetbot:
print("Error: No robot available to send actions.")
return
action = self._my_controller.forward(command=[0.20, np.pi / 4])
self._jetbot.apply_action(action)
Example of how to instantiate and use the HelloWorld class
if name == “main”:
hello_world = HelloWorld()
hello_world.setup_scene() # Set up the scene
hello_world.setup_post_load().result() # Setup after loading the world
error:
If anyone know please let me know.
Thanks
