Isaac Sim Version
4.0.0
Operating System
Ubuntu 20.04
Topic Description
Hello,
I’ve been working with issac sim for a while trying to randomize the positions of a few carter robots. I’ve been trying to use the isaac sim replicator as outlined here:
However, instead of setting the position to a distribution I set it to a random position in the costmap. I’ve been having a lot of problems with the robots having very weird behavior. I’m tracking the position of the robots in Rviz along with Isaac Sim. Sometimes the robots in Rviz will be on a different place on the map than the one in Isaac Sim. I notice that the robots seem to end up in a different position then what I pass into the position part of the replicator.
Does anyone have any experience with this? I’m not sure if I’m just using the replicator wrong or if there something else wrong with my code. Also, is there a better way to randomize the robots?
def reset_pos(randomization_node):
with dr.trigger.on_rl_frame(num_envs=num_envs):
with dr.gate.on_env_reset():
# dr.physics_view.randomize_rigid_prim_view(
# view_name=object_view1.name,
# operation="additive",
# position=rep.distribution.normal((0.0, 0.0, 0.0), (5.0, 5.0, 0.0)),
# velocity=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
# )
dr.physics_view.randomize_articulation_view(
view_name=carter_view.name,
operation="additive",
# joint_positions=rep.distribution.uniform(tuple([-0.5] * num_dof), tuple([0.5] * num_dof)),
position = random_pos(robots[0],randomization_node),
)
dr.physics_view.randomize_articulation_view(
view_name=carter_view2.name,
operation="additive",
# joint_positions=rep.distribution.uniform(tuple([-0.5] * num_dof2), tuple([0.5] * num_dof2)),
position= random_pos(robots[1],randomization_node),
)
dr.physics_view.randomize_articulation_view(
view_name=carter_view3.name,
operation="additive",
# joint_positions=rep.distribution.uniform(tuple([-0.5] * num_dof3), tuple([0.5] * num_dof3)),
position=random_pos(robots[2],randomization_node),
)
def random_pos(bot,randomization_node):
"""
Generates a random valid position within the costmap.
"""
# Costmap properties
rclpy.spin_once(randomization_node, timeout_sec=0.001)
# time.sleep(5.0)
costmap = randomization_node.get_costmap(bot)
print("checking costmaps")
if costmap == None:
print("No Costmap :(")
if costmap:
width = costmap.info.width
height = costmap.info.height
resolution = costmap.info.resolution
origin = costmap.info.origin
# print(f"width: {width}")
# print(f"height: {height}")
# print(f"resolution: {resolution}")
# print(f"origin: {origin}")
# Generate random coordinates in the grid
x_index = random.randint(0, (width - 1))
y_index = random.randint(0, (height - 1))
# Convert grid coordinates to real-world position
x = origin.position.x + x_index * resolution
y = origin.position.y + y_index * resolution
# x = -x_index * resolution
# y = -y_index * resolution
# Check costmap data to ensure it's valid (free space)
costmap_index = y_index * width + x_index
if costmap.data[costmap_index] == 0 and x > 0 and x < 10: # Assuming 0 is free space
print(f"Costmap Index: {costmap_index}")
print(f"x: {x},y: {y}")
return x ,0, 0
# return x, y, 0
# return [x,y] # Return the random position as (x, y)
return random_pos(bot,randomization_node)
# return [random.randint(0, 50) ,random.randint(0, 50)]
rep.distribution.normal((0.0, 0.0, 0.0), (0.0, 0.0, 0.0))
Thanks!