In 2023.1.0, the tutorial 4.3, I replaced jetbot robot to carter robot. I changed the corresponding wheel_dof_names to [“joint_wheel_left”, “joint_wheel_right”] and discard the caster dof. However, it always shows the error of apply_action in tensor shape as below.
2023-10-25 02:14:57 [43,987,074ms] [Error] [carb.physx.python] ValueError: shape mismatch: value array of shape (1,2) could not be broadcast to indexing result of shape (1,6)
At:
/home/dell/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/utils/numpy/tensor.py(91): assign
/home/dell/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/articulations/articulation_view.py(965): apply_action
/home/dell/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/controllers/articulation_controller.py(86): apply_action
/home/dell/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/articulations/articulation.py(453): apply_action
/home/dell/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.examples/omni/isaac/examples/user_examples/lightwheel_navigation.py(120): send_robot_actions
I assume that control_actions are applied to the joints with wheel_dof_names and other command such as positions can be “optional”, right? So what the required information? The code is below.
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")
# An open loop controller that uses a unicycle model
self._wheel_radius = 0.4
self._wheel_base = 0.57926
return
def forward(self, command):
# command will have two elements, first element is the forward velocity
# second element is the angular velocity (yaw only).
joint_velocities = [0.0, 0.0]
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)
# A controller has to return an ArticulationAction
return ArticulationAction(joint_velocities=joint_velocities)
class HelloWorld(BaseSample):
def __init__(self) -> None:
super().__init__()
return
def setup_scene(self):
world = self.get_world()
world.scene.add_default_ground_plane()
assets_root_path = get_assets_root_path()
carter_asset_path = assets_root_path + "/Isaac/Robots/Carter/carter_v2.usd"
world.scene.add(
WheeledRobot(
prim_path="/World/Fancy_Robot",
name="fancy_robot",
wheel_dof_names=["joint_wheel_left", "joint_wheel_right"],
create_robot=True,
usd_path=carter_asset_path,
)
)
return
async def setup_post_load(self):
self._world = self.get_world()
self._carter = self._world.scene.get_object("fancy_robot")
self._world.add_physics_callback("sending_actions", callback_fn=self.send_robot_actions)
# Initialize our controller after load and the first reset
self._my_controller = CoolController()
return
def send_robot_actions(self, step_size):
#apply the actions calculated by the controller
self._carter.apply_action(self._my_controller.forward(command=[0.20, np.pi / 4]))
return
Thanks!