Skip to content

Commit

Permalink
Fix jetbot env and add jetbot assets
Browse files Browse the repository at this point in the history
  • Loading branch information
ranzuh committed May 10, 2023
1 parent 2de4a0a commit 4d1f088
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
Binary file added assets/jetbot/jetbot_with_lidar_updated2.usd
Binary file not shown.
Binary file added assets/jetbot/obstacles.usd
Binary file not shown.
Binary file added assets/jetbot/target_cube.usd
Binary file not shown.
2 changes: 1 addition & 1 deletion omniisaacgymenvs/cfg/task/Jetbot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sim:
gravity: [0.0, 0.0, -9.81]
add_ground_plane: True
add_distant_light: False
use_flatcache: True
use_flatcache: False
enable_scene_query_support: True
disable_contact_processing: False

Expand Down
28 changes: 17 additions & 11 deletions omniisaacgymenvs/tasks/jetbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(
self._num_observations = self.ranges_count + 2 # +2 for angle and distance (polar coords)
self._num_actions = 2

self._diff_controller = DifferentialController(name="simple_control",wheel_radius=0.03, wheel_base=0.1125)
self._diff_controller = DifferentialController(name="simple_control",wheel_radius=0.0325, wheel_base=0.1125)

RLTask.__init__(self, name, env)

Expand All @@ -104,20 +104,25 @@ def set_up_scene(self, scene) -> None:
def add_prims_to_stage(self, scene):
# applies articulation settings from the task configuration yaml file
#self._sim_config.apply_articulation_settings("Cartpole", get_prim_at_path(cartpole.prim_path), self._sim_config.parse_actor_config("Cartpole"))

asset_path = "/home/eetu/jetbot_isaac/content/jetbot_with_lidar.usd"
add_reference_to_stage(usd_path=asset_path, prim_path=self.default_zero_env_path + "/jetbot_with_lidar")
from pathlib import Path
current_working_dir = Path.cwd()
asset_path = str(current_working_dir.parent) + "/assets/jetbot"

add_reference_to_stage(
usd_path=asset_path + "/jetbot_with_lidar_updated2.usd",
prim_path=self.default_zero_env_path + "/jetbot_with_lidar/jetbot_with_lidar"
)

add_reference_to_stage(
usd_path="/home/eetu/jetbot_isaac/content/obstacles.usd",
usd_path=asset_path + "/obstacles.usd",
prim_path=self.default_zero_env_path + "/obstacles"
)

result, lidar = omni.kit.commands.execute(
"RangeSensorCreateLidar",
path=self.default_zero_env_path + "/jetbot_with_lidar/jetbot_with_lidar/chassis/Lidar",
path=self.default_zero_env_path + "/jetbot_with_lidar/jetbot_with_lidar/chassis/Lidar/Lidar",
parent=None,
min_range=0.1,
min_range=0.10,
max_range=20.0,
draw_points=False,
draw_lines=False,
Expand All @@ -130,10 +135,10 @@ def add_prims_to_stage(self, scene):
yaw_offset=0.0,
enable_semantics=False,
)
lidar.GetPrim().GetAttribute("xformOp:translate").Set(Gf.Vec3d(0.0, 0.0, 0.11))
lidar.GetPrim().GetAttribute("xformOp:translate").Set(Gf.Vec3d(0.0, 0.0, 0.03))

add_reference_to_stage(
usd_path="/home/eetu/jetbot_isaac/content/target_cube.usd",
usd_path=asset_path + "/target_cube.usd",
prim_path=self.default_zero_env_path + "/target_cube",
)

Expand Down Expand Up @@ -200,7 +205,8 @@ def pre_physics_step(self, actions) -> None:

#self._jetbots.apply_action(ArticulationActions(joint_velocities=controls))
#joint_velocities = torch.tensor([[1.0, 1.0], [1.0, 1.0], [1.0, 1.0], [1.0, 1.0]]) * 10
self._jetbots.set_joint_velocities(controls)
#self._jetbots.set_joint_velocities(controls)
self._jetbots.set_joint_velocity_targets(controls)
#self._jetbots.apply_action(self._diff_controller.forward(np.array([0.2, 0.0])))

# may not be needed for obs and actions randomization
Expand Down Expand Up @@ -239,7 +245,7 @@ def post_reset(self):
"""This is run when first starting the simulation before first episode."""
self.lidarInterface = _range_sensor.acquire_lidar_sensor_interface()
jetbot_paths = self._jetbots.prim_paths
self._lidarpaths = [path + "/chassis/Lidar" for path in jetbot_paths]
self._lidarpaths = [path + "/chassis/Lidar/Lidar" for path in jetbot_paths]

# get some initial poses
self.initial_root_pos, self.initial_root_rot = self._jetbots.get_world_poses()
Expand Down

0 comments on commit 4d1f088

Please sign in to comment.