file_path
stringlengths 20
207
| content
stringlengths 5
3.85M
| size
int64 5
3.85M
| lang
stringclasses 9
values | avg_line_length
float64 1.33
100
| max_line_length
int64 4
993
| alphanum_fraction
float64 0.26
0.93
|
---|---|---|---|---|---|---|
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_bin_filling.py | # Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.bin_filling import BinFilling
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
class TestBinFillingExampleExtension(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
await update_stage_async()
self._sample = BinFilling()
self._sample.set_world_settings(physics_dt=1.0 / 60.0, stage_units_in_meters=1.0)
await self._sample.load_world_async()
await update_stage_async()
while is_stage_loading():
await update_stage_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await self._sample.clear_async()
await update_stage_async()
self._sample = None
pass
# Run all functions with simulation enabled
async def test_bin_filling(self):
await self._sample.reset_async()
await update_stage_async()
world = self._sample.get_world()
ur10_task = world.get_task(name="bin_filling")
task_params = ur10_task.get_params()
my_ur10 = world.scene.get_object(task_params["robot_name"]["value"])
bin = world.scene.get_object(task_params["bin_name"]["value"])
await self._sample.on_fill_bin_event_async()
await update_stage_async()
# run for 2500 frames and print time
for i in range(2500):
await update_stage_async()
if self._sample._controller.get_current_event() in [4, 5]:
self.assertTrue(my_ur10.gripper.is_closed())
if self._sample._controller.get_current_event() == 5:
self.assertGreater(bin.get_world_pose()[0][-1], 0.15)
self.assertTrue(not my_ur10.gripper.is_closed())
self.assertLess(bin.get_world_pose()[0][-1], 0)
pass
async def test_reset(self):
await self._sample.reset_async()
await update_stage_async()
await self._sample.on_fill_bin_event_async()
await update_stage_async()
for i in range(2500):
await update_stage_async()
await self._sample.reset_async()
await update_stage_async()
await self._sample.on_fill_bin_event_async()
await update_stage_async()
for i in range(2500):
await update_stage_async()
pass
| 3,460 | Python | 40.698795 | 119 | 0.661272 |
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_robo_factory.py | # Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.robo_factory import RoboFactory
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
class TestRoboFactoryExampleExtension(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
await update_stage_async()
self._sample = RoboFactory()
self._sample.set_world_settings(physics_dt=1.0 / 60.0, stage_units_in_meters=1.0)
await self._sample.load_world_async()
await update_stage_async()
while is_stage_loading():
await update_stage_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await self._sample.clear_async()
await update_stage_async()
self._sample = None
pass
# Run all functions with simulation enabled
async def test_stacking(self):
await self._sample.reset_async()
await update_stage_async()
await self._sample._on_start_stacking_event_async()
await update_stage_async()
# run for 2500 frames and print time
for i in range(500):
await update_stage_async()
pass
async def test_reset(self):
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
pass
| 2,553 | Python | 37.696969 | 119 | 0.68821 |
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_robo_party.py | # Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.robo_party import RoboParty
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
class TestRoboPartyExampleExtension(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
await update_stage_async()
self._sample = RoboParty()
self._sample.set_world_settings(physics_dt=1.0 / 60.0, stage_units_in_meters=1.0)
await self._sample.load_world_async()
await update_stage_async()
while is_stage_loading():
await update_stage_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await self._sample.clear_async()
await update_stage_async()
self._sample = None
pass
# Run all functions with simulation enabled
async def test_stacking(self):
await self._sample.reset_async()
await update_stage_async()
await self._sample._on_start_party_event_async()
await update_stage_async()
# run for 2500 frames and print time
for i in range(500):
await update_stage_async()
pass
async def test_reset(self):
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
pass
| 2,542 | Python | 37.530302 | 119 | 0.686861 |
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_simple_stack.py | # Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.simple_stack import SimpleStack
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
class TestSimpleStackExampleExtension(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
await update_stage_async()
self._sample = SimpleStack()
self._sample.set_world_settings(physics_dt=1.0 / 60.0, stage_units_in_meters=1.0)
await self._sample.load_world_async()
await update_stage_async()
while is_stage_loading():
await update_stage_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await self._sample.clear_async()
await update_stage_async()
self._sample = None
pass
# Run all functions with simulation enabled
async def test_stacking(self):
await self._sample.reset_async()
await update_stage_async()
await self._sample._on_stacking_event_async()
await update_stage_async()
# run for 2500 frames and print time
for i in range(500):
await update_stage_async()
pass
async def test_reset(self):
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
pass
| 2,547 | Python | 37.60606 | 119 | 0.687868 |
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_follow_target.py | # Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.follow_target import FollowTarget
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
class TestFollowTargetExampleExtension(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
await update_stage_async()
self._sample = FollowTarget()
self._sample.set_world_settings(physics_dt=1.0 / 60.0, stage_units_in_meters=1.0)
await self._sample.load_world_async()
await update_stage_async()
while is_stage_loading():
await update_stage_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await self._sample.clear_async()
await update_stage_async()
self._sample = None
pass
# Run all functions with simulation enabled
async def test_follow_target(self):
await self._sample.reset_async()
await update_stage_async()
await self._sample._on_follow_target_event_async(True)
await update_stage_async()
# run for 2500 frames and print time
for i in range(500):
await update_stage_async()
pass
# Run all functions with simulation enabled
async def test_add_obstacle(self):
await self._sample.reset_async()
await update_stage_async()
await self._sample._on_follow_target_event_async(True)
await update_stage_async()
# run for 2500 frames and print time
for i in range(500):
await update_stage_async()
if i % 50 == 0:
self._sample._on_add_obstacle_event()
await update_stage_async()
await self._sample.reset_async()
await update_stage_async()
pass
async def test_reset(self):
await self._sample.reset_async()
await update_stage_async()
pass
| 3,000 | Python | 37.474358 | 119 | 0.673667 |
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_kaya_gamepad.py | # Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
import carb
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.kaya_gamepad import KayaGamepad
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
from omni.isaac.core.world.world import World
class TestKayaGamepadSample(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
self._physics_rate = 60
self._provider = carb.input.acquire_input_provider()
self._gamepad = self._provider.create_gamepad("test", "0")
carb.settings.get_settings().set_int("/app/runLoops/main/rateLimitFrequency", int(self._physics_rate))
carb.settings.get_settings().set_bool("/app/runLoops/main/rateLimitEnabled", True)
carb.settings.get_settings().set_int("/persistent/simulation/minFrameRate", int(self._physics_rate))
await create_new_stage_async()
await update_stage_async()
self._sample = KayaGamepad()
World.clear_instance()
self._sample.set_world_settings(physics_dt=1.0 / self._physics_rate, stage_units_in_meters=1.0)
await self._sample.load_world_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await omni.kit.app.get_app().next_update_async()
self._sample._world_cleanup()
self._sample = None
await update_stage_async()
self._provider.destroy_gamepad(self._gamepad)
await update_stage_async()
World.clear_instance()
pass
# # Run all functions with simulation enabled
# async def test_simulation(self):
# await update_stage_async()
# while is_stage_loading():
# await update_stage_async()
# self._provider.set_gamepad_connected(self._gamepad, True)
# self.assertLess(self._sample._kaya.get_world_pose()[0][1], 1)
# await update_stage_async()
# for i in range(100):
# self._provider.buffer_gamepad_event(self._gamepad, carb.input.GamepadInput.LEFT_STICK_UP, 1.0)
# await update_stage_async()
# self._provider.set_gamepad_connected(self._gamepad, False)
# await update_stage_async()
# self.assertGreater(self._sample._kaya.get_world_pose()[0][1], 64.0)
# pass
| 3,334 | Python | 44.684931 | 119 | 0.686863 |
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_hello_world.py | # Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.hello_world import HelloWorld
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
class TestHelloWorldExampleExtension(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
await update_stage_async()
self._sample = HelloWorld()
self._sample.set_world_settings(physics_dt=1.0 / 60.0, stage_units_in_meters=1.0)
await self._sample.load_world_async()
await update_stage_async()
while is_stage_loading():
await update_stage_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await self._sample.clear_async()
await update_stage_async()
self._sample = None
pass
async def test_reset(self):
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
pass
| 2,168 | Python | 38.436363 | 119 | 0.700646 |
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_omnigraph_keyboard.py | # Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
import omni.kit
import asyncio
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
from omni.isaac.examples.omnigraph_keyboard import OmnigraphKeyboard
from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async
class TestOmnigraphKeyboardExampleExtension(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
await create_new_stage_async()
await update_stage_async()
self._sample = OmnigraphKeyboard()
self._sample.set_world_settings(physics_dt=1.0 / 60.0, stage_units_in_meters=1.0)
await self._sample.load_world_async()
await update_stage_async()
while is_stage_loading():
await update_stage_async()
return
# After running each test
async def tearDown(self):
# In some cases the test will end before the asset is loaded, in this case wait for assets to load
while is_stage_loading():
print("tearDown, assets still loading, waiting to finish...")
await asyncio.sleep(1.0)
await self._sample.clear_async()
await update_stage_async()
self._sample = None
pass
async def test_reset(self):
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
await self._sample.reset_async()
await update_stage_async()
await update_stage_async()
pass
| 2,191 | Python | 38.854545 | 119 | 0.704245 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/util.py | import carb
import numpy as np
import math
from omni.isaac.core.utils import prims
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.dynamic_control import _dynamic_control
from omni.isaac.universal_robots import KinematicsSolver
from omni.isaac.motion_generation import WheelBasePoseController
from omni.isaac.wheeled_robots.controllers.differential_controller import DifferentialController
from omni.isaac.core.utils.types import ArticulationAction
from omni.isaac.core.controllers import BaseController
from tf.transformations import euler_from_quaternion, quaternion_from_euler
from omni.isaac.core.prims import GeometryPrim, XFormPrim
class CustomDifferentialController(BaseController):
def __init__(self):
super().__init__(name="my_cool_controller")
# An open loop controller that uses a unicycle model
self._wheel_radius = 0.125
self._wheel_base = 1.152
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, 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)
joint_velocities[2] = ((2 * command[0]) - (command[1] * self._wheel_base)) / (2 * self._wheel_radius)
joint_velocities[3] = ((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)
def turn(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, 0.0, 0.0]
joint_velocities[0] = ((2 * command[0][0]) - (command[1] * self._wheel_base)) / (2 * self._wheel_radius)
joint_velocities[1] = ((2 * command[0][1]) + (command[1] * self._wheel_base)) / (2 * self._wheel_radius)
joint_velocities[2] = ((2 * command[0][2]) - (command[1] * self._wheel_base)) / (2 * self._wheel_radius)
joint_velocities[3] = ((2 * command[0][3]) + (command[1] * self._wheel_base)) / (2 * self._wheel_radius)
# A controller has to return an ArticulationAction
return ArticulationAction(joint_velocities=joint_velocities)
class Utils:
def __init__(self) -> None:
self.world = None
self.delay = 0
self.beta = 1
self.path_plan_counter = 0
self.motion_task_counter = 0
self.motion_task_counterl = 0
self.bool_done = [False]*1000
self.curr_way = False
self.id = None
# Engine cell set up ----------------------------------------------------------------------------
# bring in moving platforms
self.moving_platform = None
self._my_custom_controller = CustomDifferentialController()
self._my_controller = WheelBasePoseController(name="cool_controller", open_loop_wheel_controller=DifferentialController(name="simple_control", wheel_radius=0.125, wheel_base=0.46), is_holonomic=False)
self.my_controller = None
self.screw_my_controller = None
self.articulation_controller = None
self.screw_articulation_controller = None
# Suspension cell set up ------------------------------------------------------------------------
self.my_controller_suspension = None
self.screw_my_controller_suspension = None
self.articulation_controller_suspension = None
self.screw_articulation_controller_suspension = None
# Fuel cell set up ---------------------------------------------------------------------------------
self.my_controller_fuel = None
self.screw_my_controller_fuel = None
self.articulation_controller_fuel = None
self.screw_articulation_controller_fuel = None
# battery cell set up ---------------------------------------------------------------------------------
self.my_controller_battery = None
self.screw_my_controller_battery = None
self.articulation_controller_battery = None
self.screw_articulation_controller_battery = None
# trunk cell set up ---------------------------------------------------------------------------------
self.my_controller_trunk = None
self.screw_my_controller_trunk = None
self.articulation_controller_trunk = None
self.screw_articulation_controller_trunk = None
# wheel cell set up ---------------------------------------------------------------------------------
self.my_controller_wheel = None
self.screw_my_controller_wheel = None
self.articulation_controller_wheel = None
self.screw_articulation_controller_wheel = None
self.my_controller_wheel_01 = None
self.screw_my_controller_wheel_01 = None
self.articulation_controller_wheel_01 = None
self.screw_articulation_controller_wheel_01 = None
# lower_cover cell set up ---------------------------------------------------------------------------------
self.my_controller_lower_cover = None
self.screw_my_controller_lower_cover = None
self.articulation_controller_lower_cover = None
self.screw_articulation_controller_lower_cover = None
self.my_controller_lower_cover_01 = None
self.screw_my_controller_lower_cover_01 = None
self.articulation_controller_lower_cover_01 = None
self.screw_articulation_controller_lower_cover_01 = None
self.my_controller_main_cover = None
self.articulation_controller_main_cover = None
# handle cell set up ---------------------------------------------------------------------------------
self.my_controller_handle = None
self.screw_my_controller_handle = None
self.articulation_controller_handle = None
self.screw_articulation_controller_handle = None
# light cell set up --------------------------------------------------------------------------------
self.my_controller_light = None
self.screw_my_controller_light = None
self.articulation_controller_light = None
self.screw_articulation_controller_light = None
def give_location(self, prim_path):
dc=_dynamic_control.acquire_dynamic_control_interface()
object=dc.get_rigid_body(prim_path)
object_pose=dc.get_rigid_body_pose(object)
return object_pose # position: object_pose.p, rotation: object_pose.r
def move_ur10(self, locations, task_name=""):
print("Motion task counter", self.motion_task_counter)
target_location = locations[self.motion_task_counter]
print("Doing "+str(target_location["index"])+"th motion plan")
controller_name = getattr(self,"my_controller"+task_name)
actions, success = controller_name.compute_inverse_kinematics(
target_position=target_location["position"],
target_orientation=target_location["orientation"],
)
if success:
print("still homing on this location")
articulation_controller_name = getattr(self,"articulation_controller"+task_name)
articulation_controller_name.apply_action(actions)
else:
carb.log_warn("IK did not converge to a solution. No action is being taken.")
# check if reached location
curr_location = self.give_location(f"/World/UR10{task_name}/ee_link")
print("Curr:",curr_location.p)
print("Goal:", target_location["goal_position"])
print(np.mean(np.abs(curr_location.p - target_location["goal_position"])))
diff = np.mean(np.abs(curr_location.p - target_location["goal_position"]))
if diff<0.02:
self.motion_task_counter+=1
# time.sleep(0.3)
print("Completed one motion plan: ", self.motion_task_counter)
def move_ur10_extra(self, locations, task_name=""):
print("Motion task counter", self.motion_task_counterl)
target_location = locations[self.motion_task_counterl]
print("Doing "+str(target_location["index"])+"th motion plan")
controller_name = getattr(self,"my_controller"+task_name)
actions, success = controller_name.compute_inverse_kinematics(
target_position=target_location["position"],
target_orientation=target_location["orientation"],
)
if success:
print("still homing on this location")
articulation_controller_name = getattr(self,"articulation_controller"+task_name)
articulation_controller_name.apply_action(actions)
else:
carb.log_warn("IK did not converge to a solution. No action is being taken.")
# check if reached location
curr_location = self.give_location(f"/World/UR10{task_name}/ee_link")
print("Curr:",curr_location.p)
print("Goal:", target_location["goal_position"])
print(np.mean(np.abs(curr_location.p - target_location["goal_position"])))
diff = np.mean(np.abs(curr_location.p - target_location["goal_position"]))
if diff<0.02:
self.motion_task_counterl+=1
# time.sleep(0.3)
print("Completed one motion plan: ", self.motion_task_counterl)
def do_screw_driving(self, locations, task_name=""):
print(self.motion_task_counter)
target_location = locations[self.motion_task_counter]
print("Doing "+str(target_location["index"])+"th motion plan")
controller_name = getattr(self,"screw_my_controller"+task_name)
actions, success = controller_name.compute_inverse_kinematics(
target_position=target_location["position"],
target_orientation=target_location["orientation"],
)
if success:
print("still homing on this location")
articulation_controller_name = getattr(self,"screw_articulation_controller"+task_name)
# print(articulation_controller_name, task_name, "screw_articulation_controller"+task_name, self.screw_articulation_controller_wheel)
# print(self.articulation_controller_wheel_01)
# print(self.screw_articulation_controller_wheel_01)
articulation_controller_name.apply_action(actions)
else:
carb.log_warn("IK did not converge to a solution. No action is being taken.")
# check if reached location
curr_location = self.give_location(f"/World/Screw_driving_UR10{task_name}/ee_link")
print("Curr:",curr_location.p)
print("Goal:", target_location["goal_position"])
print(np.mean(np.abs(curr_location.p - target_location["goal_position"])))
if np.mean(np.abs(curr_location.p - target_location["goal_position"]))<0.02:
self.motion_task_counter+=1
print("Completed one motion plan: ", self.motion_task_counter)
def do_screw_driving_extra(self, locations, task_name=""):
print(self.motion_task_counterl)
target_location = locations[self.motion_task_counterl]
print("Doing "+str(target_location["index"])+"th motion plan")
controller_name = getattr(self,"screw_my_controller"+task_name)
actions, success = controller_name.compute_inverse_kinematics(
target_position=target_location["position"],
target_orientation=target_location["orientation"],
)
if success:
print("still homing on this location")
articulation_controller_name = getattr(self,"screw_articulation_controller"+task_name)
articulation_controller_name.apply_action(actions)
else:
carb.log_warn("IK did not converge to a solution. No action is being taken.")
# check if reached location
curr_location = self.give_location(f"/World/Screw_driving_UR10{task_name}/ee_link")
print("Curr:",curr_location.p)
print("Goal:", target_location["goal_position"])
print(np.mean(np.abs(curr_location.p - target_location["goal_position"])))
if np.mean(np.abs(curr_location.p - target_location["goal_position"]))<0.02:
self.motion_task_counterl+=1
print("Completed one motion plan: ", self.motion_task_counterl)
def transform_for_screw_ur10(self, position):
position[0]+=0.16171
position[1]+=0.00752
position[2]+=-0
return position
def transform_for_ur10(self, position):
position[0]+=0.16171
position[1]+=0.00752
position[2]+=-0.00419
return position
def transform_for_screw_ur10_suspension(self, position):
position[0]-=0
position[1]+=0
position[2]+=-0
return position
def transform_for_screw_ur10_fuel(self, position):
position[0]+=0.16171
position[1]+=0.00752
position[2]+=-0.00419
return position
def move_mp_wbpc(self, path_plan_last):
print("Using wheel base pose controller")
_, _, goal_position = path_plan_last
position, orientation = self.moving_platform.get_world_pose()
# In the function where you are sending robot commands
print(goal_position)
action = self._my_controller.forward(start_position=position, start_orientation=orientation, goal_position=goal_position["position"]) # Change the goal position to what you want
full_action = ArticulationAction(joint_efforts=np.concatenate([action.joint_efforts, action.joint_efforts]) if action.joint_efforts else None, joint_velocities=np.concatenate([action.joint_velocities, action.joint_velocities]), joint_positions=np.concatenate([action.joint_positions, action.joint_positions]) if action.joint_positions else None)
self.moving_platform.apply_action(full_action)
print("Current", position)
print("Goal", goal_position["position"])
print(np.mean(np.abs(position-goal_position["position"])))
if np.mean(np.abs(position-goal_position["position"])) <0.033:
self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
def move_mp(self, path_plan):
if not path_plan:
return
# if len(path_plan)-1 == self.path_plan_counter and path_plan[self.path_plan_counter][0]!="rotate" and path_plan[self.path_plan_counter][0]!="wait":
# self.move_mp_wbpc(path_plan[self.path_plan_counter])
# return
current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
move_type, goal = path_plan[self.path_plan_counter][0], path_plan[self.path_plan_counter][1]
if move_type == "translate":
goal_pos, axis, _ = goal
print(current_mp_position[axis], goal_pos, abs(current_mp_position[axis]-goal_pos))
# getting current z angle of mp in degrees
curr_euler_orientation = euler_from_quaternion(current_mp_orientation)[0]
print(curr_euler_orientation)
if curr_euler_orientation<0:
curr_euler_orientation = math.pi*2 + curr_euler_orientation
curr_euler_degree_orientation = curr_euler_orientation*(180/math.pi)
print(curr_euler_degree_orientation)
# logic for determining to reverse or not
if axis == 0:
# if :
# if goal_pos<current_mp_position[axis]:
# reverse = False
# else:
# reverse = True
# elif (curr_euler_degree_orientation-360)<0.1 or (curr_euler_degree_orientation)<0.1:
if abs(curr_euler_degree_orientation-180)<30:
if goal_pos>current_mp_position[axis]:
reverse = False
else:
reverse = True
else:
if goal_pos<current_mp_position[axis]:
reverse = False
else:
reverse = True
else:
if abs(curr_euler_degree_orientation-270)<30:
if goal_pos<current_mp_position[axis]:
reverse = False
else:
reverse = True
else:
if goal_pos>current_mp_position[axis]:
reverse = False
else:
reverse = True
# check if reverse swap happened
if not self.bool_done[0]:
print("iniitial\n\n")
self.bool_done[0]=True
self.curr_way = reverse
self.speed = 0.5
if self.curr_way != reverse:
self.speed/=1.0001
print(self.speed)
if reverse:
self.moving_platform.apply_action(self._my_custom_controller.forward(command=[-self.speed,0])) # 0.5
else:
self.moving_platform.apply_action(self._my_custom_controller.forward(command=[self.speed,0]))
if abs(current_mp_position[axis]-goal_pos)<0.001: # 0.002
self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
self.speed = 0.5
elif move_type == "rotate":
goal_ori, error_threshold, rotate_right = goal
curr_euler_orientation = euler_from_quaternion(current_mp_orientation)[0]
goal_euler_orientation = euler_from_quaternion(goal_ori)[0]
print(current_mp_orientation, goal_ori)
print(curr_euler_orientation, goal_euler_orientation)
if curr_euler_orientation<0:
curr_euler_orientation = math.pi*2 + curr_euler_orientation
if goal_euler_orientation<0:
goal_euler_orientation = math.pi*2 + goal_euler_orientation
print(curr_euler_orientation, goal_euler_orientation)
if goal_euler_orientation > curr_euler_orientation:
if curr_euler_orientation+math.pi < goal_euler_orientation:
rotate_right = False
else:
rotate_right = True
else:
if goal_euler_orientation+math.pi > curr_euler_orientation:
rotate_right = False
else:
rotate_right = True
print("Rotate right:","True" if rotate_right else "False")
if rotate_right:
self.moving_platform.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/4])) # 2
else:
self.moving_platform.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],-np.pi/4]))
curr_error = abs(curr_euler_orientation-goal_euler_orientation)
print(curr_error)
if curr_error <=0.001: # 0.002
self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
else:
self.beta*=1.00001
elif move_type == "wait":
print("Waiting ...")
self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0,0]))
if self.delay>60:
print("Done waiting")
self.delay=0
self.path_plan_counter+=1
self.delay+=1
def add_part(self, part_name, prim_name, scale, position, orientation):
world = self.get_world()
base_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/atvsstlfiles/"
add_reference_to_stage(usd_path=base_asset_path+f"{part_name}/{part_name}.usd", prim_path=f"/mock_robot/platform/{prim_name}") # gives asset ref path
part= world.scene.add(XFormPrim(prim_path=f'/mock_robot_{self.id}/platform/{prim_name}', name=f"q{prim_name}")) # declares in the world
## add part
part.set_local_scale(scale)
part.set_local_pose(translation=position, orientation=orientation)
def add_part_custom(self, parent_prim_name, part_name, prim_name, scale, position, orientation):
base_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/atvsstlfiles/"
add_reference_to_stage(usd_path=base_asset_path+f"{part_name}/{part_name}.usd", prim_path=f"/{parent_prim_name}/{prim_name}") # gives asset ref path
part= self.world.scene.add(XFormPrim(prim_path=f'/{parent_prim_name}/{prim_name}', name=f"q{prim_name}")) # declares in the world
## add part
part.set_local_scale(scale)
part.set_local_pose(translation=position, orientation=orientation)
return part
def add_part_without_parent(self, part_name, prim_name, scale, position, orientation):
world = self.get_world()
base_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/atvsstlfiles/"
add_reference_to_stage(usd_path=base_asset_path+f"{part_name}/{part_name}.usd", prim_path=f"/World/{prim_name}") # gives asset ref path
part= world.scene.add(XFormPrim(prim_path=f'/World/{prim_name}', name=f"q{prim_name}")) # declares in the world
## add part
part.set_local_scale(scale)
part.set_local_pose(translation=position, orientation=orientation)
return part
def remove_part(self, parent_prim_name, child_prim_name):
prim_path = f"/{parent_prim_name}/{child_prim_name}" if parent_prim_name else f"/{child_prim_name}"
# world = self.get_world()
prims.delete_prim(prim_path)
def check_prim_exists(self, prim_path):
curr_prim = self.world.stage.GetPrimAtPath("/"+prim_path)
if curr_prim.IsValid():
return True
return False
def move_mp_battery(self, path_plan):
if not path_plan:
return
current_mp_position, current_mp_orientation = self.battery_bringer.get_world_pose()
move_type, goal = path_plan[self.path_plan_counter]
if move_type == "translate":
goal_pos, axis, reverse = goal
print(current_mp_position[axis], goal_pos, abs(current_mp_position[axis]-goal_pos))
if reverse:
self.battery_bringer.apply_action(self._my_custom_controller.forward(command=[-0.5,0]))
else:
self.battery_bringer.apply_action(self._my_custom_controller.forward(command=[0.5,0]))
if abs(current_mp_position[axis]-goal_pos)<0.01:
self.battery_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "rotate":
goal_ori, error_threshold, rotate_right = goal
if rotate_right:
self.battery_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/2]))
else:
self.battery_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],-np.pi/2]))
curr_error = np.mean(np.abs(current_mp_orientation-goal_ori))
print(current_mp_orientation, goal_ori, curr_error)
if curr_error< error_threshold:
self.battery_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "wait":
print("Waiting ...")
self.battery_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
if self.delay>60:
print("Done waiting")
self.delay=0
self.path_plan_counter+=1
self.delay+=1
def move_mp_fuel(self, path_plan):
if not path_plan:
return
current_mp_position, current_mp_orientation = self.fuel_bringer.get_world_pose()
move_type, goal = path_plan[self.path_plan_counter]
if move_type == "translate":
goal_pos, axis, reverse = goal
print(current_mp_position[axis], goal_pos, abs(current_mp_position[axis]-goal_pos))
if reverse:
self.fuel_bringer.apply_action(self._my_custom_controller.forward(command=[-0.5,0]))
else:
self.fuel_bringer.apply_action(self._my_custom_controller.forward(command=[0.5,0]))
if abs(current_mp_position[axis]-goal_pos)<0.01:
self.fuel_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "rotate":
goal_ori, error_threshold, rotate_right = goal
if rotate_right:
self.fuel_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/2]))
else:
self.fuel_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],-np.pi/2]))
curr_error = np.mean(np.abs(current_mp_orientation-goal_ori))
print(current_mp_orientation, goal_ori, curr_error)
if curr_error< error_threshold:
self.fuel_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "wait":
print("Waiting ...")
self.fuel_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
if self.delay>60:
print("Done waiting")
self.delay=0
self.path_plan_counter+=1
self.delay+=1
def move_mp_suspension(self, path_plan):
if not path_plan:
return
current_mp_position, current_mp_orientation = self.suspension_bringer.get_world_pose()
move_type, goal = path_plan[self.path_plan_counter]
if move_type == "translate":
goal_pos, axis, reverse = goal
print(current_mp_position[axis], goal_pos, abs(current_mp_position[axis]-goal_pos))
if reverse:
self.suspension_bringer.apply_action(self._my_custom_controller.forward(command=[-0.5,0]))
else:
self.suspension_bringer.apply_action(self._my_custom_controller.forward(command=[0.5,0]))
if abs(current_mp_position[axis]-goal_pos)<0.01:
self.suspension_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "rotate":
goal_ori, error_threshold, rotate_right = goal
if rotate_right:
self.suspension_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/2]))
else:
self.suspension_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],-np.pi/2]))
curr_error = np.mean(np.abs(current_mp_orientation-goal_ori))
print(current_mp_orientation, goal_ori, curr_error)
if curr_error< error_threshold:
self.suspension_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "wait":
print("Waiting ...")
self.suspension_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
if self.delay>60:
print("Done waiting")
self.delay=0
self.path_plan_counter+=1
self.delay+=1
def move_mp_engine(self, path_plan):
if not path_plan:
return
current_mp_position, current_mp_orientation = self.engine_bringer.get_world_pose()
move_type, goal = path_plan[self.path_plan_counter]
if move_type == "translate":
goal_pos, axis, reverse = goal
print(current_mp_position[axis], goal_pos, abs(current_mp_position[axis]-goal_pos))
if reverse:
self.engine_bringer.apply_action(self._my_custom_controller.forward(command=[-0.5,0]))
else:
self.engine_bringer.apply_action(self._my_custom_controller.forward(command=[0.5,0]))
if abs(current_mp_position[axis]-goal_pos)<0.01:
self.engine_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "rotate":
goal_ori, error_threshold, rotate_right = goal
if rotate_right:
self.engine_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/2]))
else:
self.engine_bringer.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],-np.pi/2]))
curr_error = np.mean(np.abs(current_mp_orientation-goal_ori))
print(current_mp_orientation, goal_ori, curr_error)
if curr_error< error_threshold:
self.engine_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
self.path_plan_counter+=1
elif move_type == "wait":
print("Waiting ...")
self.engine_bringer.apply_action(self._my_custom_controller.forward(command=[0,0]))
if self.delay>60:
print("Done waiting")
self.delay=0
self.path_plan_counter+=1
self.delay+=1 | 29,871 | Python | 47.651466 | 353 | 0.597637 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/suspension_task.py | from omni.isaac.core.prims import GeometryPrim, XFormPrim
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.universal_robots.controllers.pick_place_controller import PickPlaceController
from omni.isaac.wheeled_robots.robots import WheeledRobot
from omni.isaac.core.utils.types import ArticulationAction
# This extension includes several generic controllers that could be used with multiple robots
from omni.isaac.motion_generation import WheelBasePoseController
# Robot specific controller
from omni.isaac.wheeled_robots.controllers.differential_controller import DifferentialController
from omni.isaac.core.controllers import BaseController
from omni.isaac.core.tasks import BaseTask
from omni.isaac.manipulators import SingleManipulator
from omni.isaac.manipulators.grippers import SurfaceGripper
import numpy as np
from omni.isaac.core.objects import VisualCuboid, DynamicCuboid
from omni.isaac.core.utils import prims
from pxr import UsdLux, Sdf, UsdGeom
import omni.usd
from omni.isaac.dynamic_control import _dynamic_control
from omni.isaac.universal_robots import KinematicsSolver
import carb
from collections import deque, defaultdict
import time
class SuspensionTask(BaseTask):
def __init__(self, name):
super().__init__(name=name, offset=None)
# self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]), np.array([-5.40137, -4.88, 0.03551]), np.array([-5.40137, -17.69, 0.03551]), np.array([-20.45, -17.69, 0.03551]), np.array([-36.03, -17.69, 0.03551]), np.array([-36.03, -4.71, 0.03551]), np.array([-20.84, -4.71, 0.03551]), np.array([-20.84, 7.36, 0.03551]), np.array([-36.06, 7.36, 0.03551]), np.array([-36.06, 19.64, 0.03551]), np.array([-5.40137, 19.64, 0.03551])]
# self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]), np.array([-5.40137, -4.88, 0.03551]), np.array([-5.40137, -17.69, 0.03551]), np.array([-20.45, -17.69, 0.03551]), np.array([-36.03, -17.69, 0.03551]), np.array([-36.03, -4.71, 0.03551]), np.array([-20.84, -4.71, 0.03551]), np.array([-20.84, 7.36, 0.03551]), np.array([-36.06, 7.36, 0.03551]), np.array([-36.06, 19.64, 0.03551]), np.array([-5.40137, 19.64, 0.03551])]
self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]),
np.array([-5.40137, -2.628, 0.03551]),
np.array([-5.40137, -15.69, 0.03551]),
np.array([-20.45, -17.69, 0.03551]),
np.array([-36.03, -17.69, 0.03551]),
np.array([-36.03, -4.71, 0.03551]),
np.array([-20.84, -4.71, 0.03551]),
np.array([-20.84, 7.36, 0.03551]),
np.array([-36.06, 7.36, 0.03551]),
np.array([-36.06, 19.64, 0.03551]),
np.array([-5.40137, 19.64, 0.03551])]
self.eb_goal_position = np.array([-4.39666, 7.64828, 0.035])
self.ur10_suspension_goal_position = np.array([])
# self.mp_goal_orientation = np.array([1, 0, 0, 0])
self._task_event = 0
self.task_done = [False]*120
self.motion_event = 0
self.motion_done = [False]*120
self._bool_event = 0
self.count=0
self.delay=0
return
def set_up_scene(self, scene):
super().set_up_scene(scene)
assets_root_path = get_assets_root_path() # http://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/Isaac/2022.2.1
asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/photos/real_microfactory_1_2.usd"
robot_arm_path = assets_root_path + "/Isaac/Robots/UR10/ur10.usd"
# adding UR10_suspension for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_suspension")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_suspension/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_suspension/ee_link", translate=0.1611, direction="x")
self.ur10_suspension = scene.add(
SingleManipulator(prim_path="/World/UR10_suspension", name="my_ur10_suspension", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-6.10078, -5.19303, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_suspension.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_suspension for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_suspension")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_suspension/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_suspension/ee_link", translate=0, direction="x")
self.screw_ur10_suspension = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_suspension", name="my_screw_ur10_suspension", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-3.78767, -5.00871, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_suspension.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
large_robot_asset_path = small_robot_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform/mobile_platform.usd"
# add floor
add_reference_to_stage(usd_path=asset_path, prim_path="/World/Environment")
# # add moving platform
# self.moving_platform = scene.add(
# WheeledRobot(
# prim_path="/mock_robot",
# name="moving_platform",
# wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
# create_robot=True,
# usd_path=large_robot_asset_path,
# position=np.array([-5.26025, 1.25718, 0.03551]),
# orientation=np.array([0.5, 0.5, -0.5, -0.5]),
# )
# )
self.suspension_bringer = scene.add(
WheeledRobot(
prim_path="/suspension_bringer",
name="suspension_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-7.60277, -5.70312, 0.035]),
orientation=np.array([0,0,0.70711, 0.70711]),
)
)
return
def get_observations(self):
# current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
current_eb_position, current_eb_orientation = self.suspension_bringer.get_world_pose()
current_joint_positions_ur10_suspension = self.ur10_suspension.get_joint_positions()
observations= {
# "task_event": self._task_event,
"suspension_task_event": self._task_event,
# self.moving_platform.name: {
# "position": current_mp_position,
# "orientation": current_mp_orientation,
# "goal_position": self.mp_goal_position
# },
self.suspension_bringer.name: {
"position": current_eb_position,
"orientation": current_eb_orientation,
"goal_position": self.eb_goal_position
},
self.ur10_suspension.name: {
"joint_positions": current_joint_positions_ur10_suspension,
},
self.screw_ur10_suspension.name: {
"joint_positions": current_joint_positions_ur10_suspension,
}
}
return observations
def get_params(self):
params_representation = {}
params_representation["arm_name"] = {"value": self.ur10_suspension.name, "modifiable": False}
params_representation["screw_arm"] = {"value": self.screw_ur10_suspension.name, "modifiable": False}
# params_representation["mp_name"] = {"value": self.moving_platform.name, "modifiable": False}
params_representation["eb_name"] = {"value": self.suspension_bringer.name, "modifiable": False}
return params_representation
def check_prim_exists(self, prim):
if prim:
return True
return False
def give_location(self, prim_path):
dc=_dynamic_control.acquire_dynamic_control_interface()
object=dc.get_rigid_body(prim_path)
object_pose=dc.get_rigid_body_pose(object)
return object_pose # position: object_pose.p, rotation: object_pose.r
def pre_step(self, control_index, simulation_time):
# current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
current_eb_position, current_eb_orientation = self.suspension_bringer.get_world_pose()
ee_pose = self.give_location("/World/UR10_suspension/ee_link")
screw_ee_pose = self.give_location("/World/Screw_driving_UR10_suspension/ee_link")
# iteration 1
if self._task_event == 0:
if self.task_done[self._task_event]:
self._task_event = 101
self.task_done[self._task_event] = True
elif self._task_event == 101:
# if self.task_done[self._task_event] and current_mp_position[1]<-5.3:
self._task_event = 151
self._bool_event+=1
# self.task_done[self._task_event] = True
elif self._task_event == 151:
if np.mean(np.abs(ee_pose.p - np.array([-5.00127, -4.80822, 0.53949])))<0.02:
self._task_event = 171
self._bool_event+=1
elif self._task_event == 171:
if np.mean(np.abs(screw_ee_pose.p - np.array([-3.70349, -4.41856, 0.56125])))<0.058:
self._task_event=102
elif self._task_event == 102:
if self.task_done[self._task_event]:
if self.delay == 100:
self._task_event +=1
self.delay=0
else:
self.delay+=1
self.task_done[self._task_event] = True
elif self._task_event == 103:
pass
return
def post_reset(self):
self._task_event = 0
return | 10,957 | Python | 52.194175 | 441 | 0.612668 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/fuel_task.py | from omni.isaac.core.prims import GeometryPrim, XFormPrim
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.universal_robots.controllers.pick_place_controller import PickPlaceController
from omni.isaac.wheeled_robots.robots import WheeledRobot
from omni.isaac.core.utils.types import ArticulationAction
# This extension includes several generic controllers that could be used with multiple robots
from omni.isaac.motion_generation import WheelBasePoseController
# Robot specific controller
from omni.isaac.wheeled_robots.controllers.differential_controller import DifferentialController
from omni.isaac.core.controllers import BaseController
from omni.isaac.core.tasks import BaseTask
from omni.isaac.manipulators import SingleManipulator
from omni.isaac.manipulators.grippers import SurfaceGripper
import numpy as np
from omni.isaac.core.objects import VisualCuboid, DynamicCuboid
from omni.isaac.core.utils import prims
from pxr import UsdLux, Sdf, UsdGeom
import omni.usd
from omni.isaac.dynamic_control import _dynamic_control
from omni.isaac.universal_robots import KinematicsSolver
import carb
from collections import deque, defaultdict
import time
class FuelTask(BaseTask):
def __init__(self, name):
super().__init__(name=name, offset=None)
# self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]), np.array([-5.40137, -4.88, 0.03551]), np.array([-5.40137, -17.69, 0.03551]), np.array([-20.45, -17.69, 0.03551]), np.array([-36.03, -17.69, 0.03551]), np.array([-36.03, -4.71, 0.03551]), np.array([-20.84, -4.71, 0.03551]), np.array([-20.84, 7.36, 0.03551]), np.array([-36.06, 7.36, 0.03551]), np.array([-36.06, 19.64, 0.03551]), np.array([-5.40137, 19.64, 0.03551])]
# self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]), np.array([-5.40137, -4.88, 0.03551]), np.array([-5.40137, -17.69, 0.03551]), np.array([-20.45, -17.69, 0.03551]), np.array([-36.03, -17.69, 0.03551]), np.array([-36.03, -4.71, 0.03551]), np.array([-20.84, -4.71, 0.03551]), np.array([-20.84, 7.36, 0.03551]), np.array([-36.06, 7.36, 0.03551]), np.array([-36.06, 19.64, 0.03551]), np.array([-5.40137, 19.64, 0.03551])]
self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]),
np.array([-5.40137, -2.628, 0.03551]),
np.array([-5.40137, -15.69, 0.03551]),
np.array([-20.45, -17.69, 0.03551]),
np.array([-36.03, -17.69, 0.03551]),
np.array([-36.03, -4.71, 0.03551]),
np.array([-20.84, -4.71, 0.03551]),
np.array([-20.84, 7.36, 0.03551]),
np.array([-36.06, 7.36, 0.03551]),
np.array([-36.06, 19.64, 0.03551]),
np.array([-5.40137, 19.64, 0.03551])]
self.eb_goal_position = np.array([-4.39666, 7.64828, 0.035])
self.ur10_fuel_goal_position = np.array([])
# self.mp_goal_orientation = np.array([1, 0, 0, 0])
self._task_event = 0
self.task_done = [False]*120
self.motion_event = 0
self.motion_done = [False]*120
self._bool_event = 0
self.count=0
return
def set_up_scene(self, scene):
super().set_up_scene(scene)
assets_root_path = get_assets_root_path() # http://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/Isaac/2022.2.1
asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/photos/real_microfactory_1_2.usd"
robot_arm_path = assets_root_path + "/Isaac/Robots/UR10_fuel/ur10_fuel.usd"
# adding UR10_fuel for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_fuel")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_fuel/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_fuel/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_fuel/ee_link", translate=0.1611, direction="x")
self.ur10_fuel = scene.add(
SingleManipulator(prim_path="/World/UR10_fuel", name="my_ur10_fuel", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-6.09744, -16.5124, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_fuel.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_fuel for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_fuel")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_fuel/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_fuel/ee_link", translate=0, direction="x")
self.screw_ur10_fuel = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_fuel", name="my_screw_ur10_fuel", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-4.02094, -16.52902, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_fuel.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
large_robot_asset_path = small_robot_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform/mobile_platform.usd"
# add floor
add_reference_to_stage(usd_path=asset_path, prim_path="/World/Environment")
# add moving platform
self.moving_platform = scene.add(
WheeledRobot(
prim_path="/mock_robot",
name="moving_platform",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=large_robot_asset_path,
position=np.array([-5.26025, -9.96157, 0.03551]),
orientation=np.array([0.5, 0.5, -0.5, -0.5]),
)
)
self.engine_bringer = scene.add(
WheeledRobot(
prim_path="/engine_bringer",
name="engine_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-7.47898, -16.15971, 0.035]),
orientation=np.array([0,0,0.70711, 0.70711]),
)
)
return
def get_observations(self):
current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
current_eb_position, current_eb_orientation = self.engine_bringer.get_world_pose()
current_joint_positions_ur10_fuel = self.ur10_fuel.get_joint_positions()
observations= {
"task_event": self._task_event,
"task_event": self._task_event,
self.moving_platform.name: {
"position": current_mp_position,
"orientation": current_mp_orientation,
"goal_position": self.mp_goal_position
},
self.engine_bringer.name: {
"position": current_eb_position,
"orientation": current_eb_orientation,
"goal_position": self.eb_goal_position
},
self.ur10_fuel.name: {
"joint_positions": current_joint_positions_ur10_fuel,
},
self.screw_ur10_fuel.name: {
"joint_positions": current_joint_positions_ur10_fuel,
},
"bool_counter": self._bool_event
}
return observations
def get_params(self):
params_representation = {}
params_representation["arm_name_fuel"] = {"value": self.ur10_fuel.name, "modifiable": False}
params_representation["screw_arm_fuel"] = {"value": self.screw_ur10_fuel.name, "modifiable": False}
params_representation["mp_name"] = {"value": self.moving_platform.name, "modifiable": False}
params_representation["eb_name_fuel"] = {"value": self.engine_bringer.name, "modifiable": False}
return params_representation
def check_prim_exists(self, prim):
if prim:
return True
return False
def give_location(self, prim_path):
dc=_dynamic_control.acquire_dynamic_control_interface()
object=dc.get_rigid_body(prim_path)
object_pose=dc.get_rigid_body_pose(object)
return object_pose # position: object_pose.p, rotation: object_pose.r
def pre_step(self, control_index, simulation_time):
current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
ee_pose = self.give_location("/World/UR10_fuel/ee_link")
screw_ee_pose = self.give_location("/World/Screw_driving_UR10_fuel/ee_link")
# iteration 1
if self._task_event == 0:
if self.task_done[self._task_event]:
self._task_event += 1
self.task_done[self._task_event] = True
elif self._task_event == 1:
if self.task_done[self._task_event] and current_mp_position[1]<-16.69:
self._task_event = 51
self._bool_event+=1
self.task_done[self._task_event] = True
elif self._task_event == 51:
if np.mean(np.abs(ee_pose.p - np.array([-5.005, -16.7606, 0.76714])))<0.02:
self._task_event = 71
self._bool_event+=1
elif self._task_event == 71:
if np.mean(np.abs(ee_pose.p - np.array([-4.18372, 7.03628, 0.44567])))<0.058:
self._task_event=2
pass
elif self._task_event == 2:
pass
return
def post_reset(self):
self._task_event = 0
return | 10,469 | Python | 51.089552 | 441 | 0.611233 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/__init__.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from omni.isaac.examples.hello_world.hello_world import HelloWorld
from omni.isaac.examples.hello_world.hello_world_extension import HelloWorldExtension
| 582 | Python | 47.583329 | 85 | 0.821306 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/hello_world.py | import carb
from omni.isaac.core.prims import GeometryPrim, XFormPrim
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.universal_robots.controllers.pick_place_controller import PickPlaceController
from omni.isaac.wheeled_robots.robots import WheeledRobot
from omni.isaac.core.utils.types import ArticulationAction
# This extension includes several generic controllers that could be used with multiple robots
from omni.isaac.motion_generation import WheelBasePoseController
# Robot specific controller
from omni.isaac.wheeled_robots.controllers.differential_controller import DifferentialController
from omni.isaac.core.controllers import BaseController
from omni.isaac.core.tasks import BaseTask
from omni.isaac.manipulators import SingleManipulator
from omni.isaac.manipulators.grippers import SurfaceGripper
import numpy as np
from omni.isaac.core.objects import VisualCuboid, DynamicCuboid
from omni.isaac.core.utils import prims
from pxr import UsdLux, Sdf, UsdGeom
import omni.usd
from omni.isaac.dynamic_control import _dynamic_control
from omni.isaac.universal_robots import KinematicsSolver
from collections import deque, defaultdict
from geometry_msgs.msg import PoseStamped
import rosgraph
from tf.transformations import euler_from_quaternion, quaternion_from_euler
from math import pi
from omni.isaac.examples.hello_world.assembly_task import AssemblyTask
from omni.isaac.examples.hello_world.ATV_task import ATVTask
import time
import asyncio
import rospy
from omni.isaac.examples.hello_world.executor_functions import ExecutorFunctions
from omni.isaac.examples.hello_world.pf_functions import PartFeederFunctions
from omni.isaac.core import SimulationContext
import omni.graph.core as og
# def func():
# try:
# rospy.init_node("hello", anonymous=True, disable_signals=True, log_level=rospy.ERROR)
# except rospy.exceptions.ROSException as e:
# print("Node has already been initialized, do nothing")
# async def my_task():
# from std_msgs.msg import String
# pub = rospy.Publisher("/hello_topic", String, queue_size=10)
# for frame in range(20):
# pub.publish("hello world " + str(frame))
# await asyncio.sleep(1.0)
# pub.unregister()
# pub = None
# asyncio.ensure_future(my_task())
class HelloWorld(BaseSample):
def __init__(self) -> None:
super().__init__()
self.done = False
self.isThere = [False]*1000
return
def setup_scene(self):
world = self.get_world()
# step_size=1
# world.set_physics_step_size(step_size)
# adding light
l = UsdLux.SphereLight.Define(world.stage, Sdf.Path("/World/Lights"))
# l.CreateExposureAttr(...)
l.CreateColorTemperatureAttr(10000)
l.CreateIntensityAttr(7500)
l.CreateRadiusAttr(75)
l.AddTranslateOp()
XFormPrim("/World/Lights").set_local_pose(translation=np.array([0,0,100]))
world.add_task(AssemblyTask(name="assembly_task"))
self.isDone = [False]*1000
self.bool_done = [False]*1000
self.motion_task_counter=0
self.motion_task_counterl=0
self.motion_task_counterr=0
self.path_plan_counter=0
self.delay=0
# ATV declarations -------------------------------------------------------------------------
self.num_of_ATVs = 8
for i in range(self.num_of_ATVs):
world.add_task(ATVTask(name=f"ATV_{i}",offset=np.array([0, i*2, 0])))
# part feeder declarations -------------------------------------------------------------------------
self.num_of_PFs = 5
self.name_of_PFs = [{"name":"engine","prim_name":"engine_small","position":np.array([0.07038, 0.03535, 0.42908]),"orientation":np.array([0, 0.12268, 0, 0.99245]),"mp_pos":np.array([8.61707, 17.63327, 0.03551]),"mp_ori":np.array([0,0,0,1])},
{"name":"trunk","prim_name":"trunk_02","position":np.array([-0.1389, -0.2191, 0.28512]),"orientation":np.array([0.5, 0.5, 0.5, 0.5]),"mp_pos":np.array([-42.76706, 5.21645, 0.03551]),"mp_ori":np.array([1,0,0,0])},
{"name":"wheels","prim_name":"wheel_02","position":np.array([0.45216, -0.32084, 0.28512]),"orientation":np.array([0, 0, 0.70711, 0.70711]),"mp_pos":np.array([-42.71662, 17.56147, 0.03551]),"mp_ori":np.array([1,0,0,0])},
{"name":"main_cover","prim_name":"main_cover","position":np.array([0.74446, -0.26918, -0.03119]),"orientation":np.array([0, 0, -0.70711, -0.70711]),"mp_pos":np.array([-28.65, -31.19876, 0.03551]),"mp_ori":np.array([0.70711, 0, 0, 0.70711])},
{"name":"handle","prim_name":"handle","position":np.array([-0.4248, 0.46934, 0.94076]),"orientation":np.array([0, 1, 0, 0]),"mp_pos":np.array([-42.77298, -7.93, 0.03551]),"mp_ori":np.array([0,0,0,1])}]
for i in range(self.num_of_PFs):
world.add_task(ATVTask(name=f"PF_{i}", offset=np.array([0, i*2, 0]), mp_name=f"pf_{self.name_of_PFs[i]['name']}_{i}",mp_pos=self.name_of_PFs[i]['mp_pos'],mp_ori=self.name_of_PFs[i]['mp_ori']))
print("inside setup_scene", self.motion_task_counter)
# self.schedules = [deque(['790']) for _ in range(self.num_of_ATVs)]
# "1","71","2","72","3","4","6","101","151","171","181","102","301","351","371","381","302","201","251","271","281","202","401","451","471","481","402",
self.schedules = [deque(["1","71","2","72","3","4","6","101","151","171","181","102","301","351","371","381","302","201","251","271","281","202","401","451","471","481","402","501","590","591","505","592","593","502","701","790","791","702","721","731","703","801","851","871","802","901","951","971","902","1000"]) for _ in range(self.num_of_ATVs)]
for i in range(3, len(self.schedules)):
self.schedules[i]=deque(["1","71","2","72","3","4","6","101","151","171","181","102","301","351","371","381","302","201","251","271","281","202","401","402","501","590","591","505","592","593","502","701","790","791","702","721","731","703","801","851","871","802","901","951","971","902","1000"])
# self.schedules = [deque(["701","790","791","702","721","731","703","801","851","871","802","901","951","971","902","1000"]) for _ in range(self.num_of_ATVs)]
# # for i in range(len(self.schedules)):
# # self.schedules[i]=deque([])
# self.schedules[1]=deque(["71","2","72","4","151","171","181","351","371","381","251","271","281","451","471","481","590","591","592","593","701","790","791","702","721","731","703","801","851","871","802","901","951","971","902","1000"])
# self.schedules[0] = deque(["1","6","6","6","6","6","6","6","6","6","6","6","4","6","101","151","171","181","102","301","351","371","381","302","201","251","271","281","202","401","451","471","481","402","501","590","591","505","592","593","502","701","790","791","702","721","731","703","801","851","871","802","901","951","971","902","1000"])
self.wait_queue = [deque([0,1,2,3,4]) for _ in range(self.num_of_ATVs)]
self.pf_schedules = [deque([]) for _ in range(self.num_of_PFs)]
self.right_side = self.left_side = False
# navigation declarations -----------------------------------------------
if not rosgraph.is_master_online():
print("Please run roscore before executing this script")
return
try:
rospy.init_node("set_goal_py",anonymous=True, disable_signals=True, log_level=rospy.ERROR)
except rospy.exceptions.ROSException as e:
print("Node has already been initialized, do nothing")
# FIXME
# self._initial_goal_publisher = rospy.Publisher("initialpose", PoseWithCovarianceStamped, queue_size=1)
# self.__send_initial_pose()
# await asyncio.sleep(1.0)
# self._action_client = actionlib.SimpleActionClient("move_base", MoveBaseAction)
return
async def setup_post_load(self):
self._world = self.get_world()
# part feeders set up ----------------------------------------------------------------------------
self.PF_tasks = []
self.part_feeders = []
self.PF_executions = []
for i in range(self.num_of_PFs):
self.PF_tasks.append(self._world.get_task(f"PF_{i}"))
task_params = self.PF_tasks[i].get_params()
self.part_feeders.append(self._world.scene.get_object(task_params["mp_name"]["value"]))
if self.name_of_PFs[i]['name'] == "engine":
self.add_part_custom("pf_"+self.name_of_PFs[i]["name"]+"/platform","engine_no_rigid", "pf_"+self.name_of_PFs[i]["name"]+f"_{0}", np.array([0.001, 0.001, 0.001]), self.name_of_PFs[i]["position"], self.name_of_PFs[i]["orientation"])
elif self.name_of_PFs[i]['name'] != "wheels":
if self.name_of_PFs[i]['name'] == "main_cover":
self.add_part_custom("pf_"+self.name_of_PFs[i]["name"]+"/platform","main_cover_orange", "pf_"+self.name_of_PFs[i]["name"]+f"_{0}", np.array([0.001, 0.001, 0.001]), self.name_of_PFs[i]["position"], self.name_of_PFs[i]["orientation"])
else:
self.add_part_custom("pf_"+self.name_of_PFs[i]["name"]+"/platform",self.name_of_PFs[i]["name"], "pf_"+self.name_of_PFs[i]["name"]+f"_{0}", np.array([0.001, 0.001, 0.001]), self.name_of_PFs[i]["position"], self.name_of_PFs[i]["orientation"])
else:
# self.add_part_custom("pf_"+self.name_of_PFs[i]["name"]+"/platform","FWheel", "pf_"+self.name_of_PFs[i]["name"]+f"_1_{0}", np.array([0.001, 0.001, 0.001]), self.name_of_PFs[i]["position"], self.name_of_PFs[i]["orientation"])
# self.add_part_custom("pf_"+self.name_of_PFs[i]["name"]+"/platform","FWheel", "pf_"+self.name_of_PFs[i]["name"]+f"_2_{0}", np.array([0.001, 0.001, 0.001]), self.name_of_PFs[i]["position"], self.name_of_PFs[i]["orientation"])
# self.add_part_custom("pf_"+self.name_of_PFs[i]["name"]+"/platform","FWheel", "pf_"+self.name_of_PFs[i]["name"]+f"_3_{0}", np.array([0.001, 0.001, 0.001]), self.name_of_PFs[i]["position"], self.name_of_PFs[i]["orientation"])
# self.add_part_custom("pf_"+self.name_of_PFs[i]["name"]+"/platform","FWheel", "pf_"+self.name_of_PFs[i]["name"]+f"_4_{0}", np.array([0.001, 0.001, 0.001]), self.name_of_PFs[i]["position"], self.name_of_PFs[i]["orientation"])
self.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_1_{0}", np.array([0.001, 0.001, 0.001]), np.array([0.42089, -0.1821, 0.56097]), np.array([0.5, -0.5, 0.5, 0.5]))
self.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_2_{0}", np.array([0.001, 0.001, 0.001]), np.array([-0.04856, -0.1821, 0.56097]), np.array([0.5, -0.5, 0.5, 0.5]))
self.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_3_{0}", np.array([0.001, 0.001, 0.001]), np.array([0.42089, -0.1821, 0.41917]), np.array([0.5, -0.5, 0.5, 0.5]))
self.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_4_{0}", np.array([0.001, 0.001, 0.001]), np.array([-0.04856, -0.1821, 0.41917]), np.array([0.5, -0.5, 0.5, 0.5]))
pf = PartFeederFunctions()
self.PF_executions.append(pf)
# mobile platform set up -------------------------------------------------------------------------
self.ATV_tasks = []
self.moving_platforms = []
self.ATV_executions = []
for i in range(self.num_of_ATVs):
self.ATV_tasks.append(self._world.get_task(f"ATV_{i}"))
task_params = self.ATV_tasks[i].get_params()
self.moving_platforms.append(self._world.scene.get_object(task_params["mp_name"]["value"]))
self.add_part_custom(f"mock_robot_{i}/platform","FFrame", f"frame_{i}", np.array([0.001, 0.001, 0.001]), np.array([0.45216, -0.32084, 0.28512]), np.array([0, 0, 0.70711, 0.70711]))
atv = ExecutorFunctions()
self.ATV_executions.append(atv)
# og.Controller.set(og.Controller.attribute(f"/mock_robot_{i}/TwistSub" + "/node_namespace.inputs:value"), f"mp{i+1}")
# og.Controller.set(og.Controller.attribute(f"/mock_robot_{i}/LidarPub" + "/node_namespace.inputs:value"), f"mp{i+1}")
# og.Controller.set(og.Controller.attribute(f"/mock_robot_{i}/TfAndOdomPub" + "/node_namespace.inputs:value"), f"mp{i+1}")
# Engine cell set up ----------------------------------------------------------------------------
task_params = self._world.get_task("assembly_task").get_params()
# bring in moving platforms
# self.moving_platform = self._world.scene.get_object(task_params["mp_name"]["value"])
self.engine_bringer = self._world.scene.get_object(task_params["eb_name"]["value"])
self._world.add_physics_callback("sending_actions", callback_fn=self.send_robot_actions)
# Initialize our controller after load and the first reset
# self._my_custom_controller = CustomDifferentialController()
# self._my_controller = WheelBasePoseController(name="cool_controller", open_loop_wheel_controller=DifferentialController(name="simple_control", wheel_radius=0.125, wheel_base=0.46), is_holonomic=False)
self.ur10 = self._world.scene.get_object(task_params["arm_name"]["value"])
self.screw_ur10 = self._world.scene.get_object(task_params["screw_arm"]["value"])
self.my_controller = KinematicsSolver(self.ur10, attach_gripper=True)
self.screw_my_controller = KinematicsSolver(self.screw_ur10, attach_gripper=True)
self.articulation_controller = self.ur10.get_articulation_controller()
self.screw_articulation_controller = self.screw_ur10.get_articulation_controller()
# self.add_part("FFrame", "frame", np.array([0.001, 0.001, 0.001]), np.array([0.45216, -0.32084, 0.28512]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","engine_no_rigid", "engine_small_0", np.array([0.001, 0.001, 0.001]), np.array([-4.86938, 8.14712, 0.59038]), np.array([0.99457, 0, -0.10411, 0]))
# Suspension cell set up ------------------------------------------------------------------------
# bring in moving platforms
self.suspension_bringer = self._world.scene.get_object(task_params["eb_name_suspension"]["value"])
# static suspensions on the table
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_00", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.83704, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
# self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_01_0", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.69733, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_01", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.69733, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_02", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.54469, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_03", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.3843, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_04", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.22546, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_05", np.array([0.001,0.001,0.001]), np.array([-6.10203, -4.74457, 0.41322]), np.array([0.70711, 0, -0.70711, 0]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_06", np.array([0.001,0.001,0.001]), np.array([-5.96018, -4.74457, 0.41322]), np.array([0.70711, 0, -0.70711, 0]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_07", np.array([0.001,0.001,0.001]), np.array([-5.7941, -4.74457, 0.41322]), np.array([0.70711, 0, -0.70711, 0]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_08", np.array([0.001,0.001,0.001]), np.array([-5.63427, -4.74457, 0.41322]), np.array([0.70711, 0, -0.70711, 0]))
self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack_09", np.array([0.001,0.001,0.001]), np.array([-5.47625, -4.74457, 0.41322]), np.array([0.70711, 0, -0.70711, 0]))
# self.add_part_custom("mock_robot/platform","engine_no_rigid", "engine", np.array([0.001,0.001,0.001]), np.array([-0.16041, -0.00551, 0.46581]), np.array([0.98404, -0.00148, -0.17792, -0.00274]))
# self.add_part("FFrame", "frame", np.array([0.001, 0.001, 0.001]), np.array([0.45216, -0.32084, 0.28512]), np.array([0, 0, 0.70711, 0.70711]))
self.ur10_suspension = self._world.scene.get_object(task_params["arm_name_suspension"]["value"])
self.screw_ur10_suspension = self._world.scene.get_object(task_params["screw_arm_suspension"]["value"])
self.my_controller_suspension = KinematicsSolver(self.ur10_suspension, attach_gripper=True)
self.screw_my_controller_suspension = KinematicsSolver(self.screw_ur10_suspension, attach_gripper=True)
self.articulation_controller_suspension = self.ur10_suspension.get_articulation_controller()
self.screw_articulation_controller_suspension = self.screw_ur10_suspension.get_articulation_controller()
# Fuel cell set up ---------------------------------------------------------------------------------
# bring in moving platforms
self.fuel_bringer = self._world.scene.get_object(task_params["eb_name_fuel"]["value"])
# self.add_part_custom("fuel_bringer/platform","fuel", "fuel", np.array([0.001,0.001,0.001]), np.array([-0.1769, 0.13468, 0.24931]), np.array([0.5,0.5,-0.5,-0.5]))
# self.add_part_custom("World/Environment","fuel", "fuel_01_0", np.array([0.001,0.001,0.001]), np.array([-7.01712, -15.89918, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.offset = -0.35894
self.add_part_custom("World/Environment","fuel", "fuel_00", np.array([0.001,0.001,0.001]), np.array([-6.96448, -16.13794+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","fuel_yellow", "fuel_01", np.array([0.001,0.001,0.001]), np.array([-6.96448, -15.83793+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","fuel", "fuel_02", np.array([0.001,0.001,0.001]), np.array([-6.96448, -15.53714+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","fuel_yellow", "fuel_03", np.array([0.001,0.001,0.001]), np.array([-6.96448, -15.23127+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","fuel", "fuel_04", np.array([0.001,0.001,0.001]), np.array([-7.22495, -16.13794+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","fuel_yellow", "fuel_05", np.array([0.001,0.001,0.001]), np.array([-7.22495, -15.83793+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","fuel", "fuel_06", np.array([0.001,0.001,0.001]), np.array([-7.22495, -15.53714+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","fuel_yellow", "fuel_07", np.array([0.001,0.001,0.001]), np.array([-7.22495, -15.23127+self.offset, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
# self.add_part_custom("World/Environment","fuel", "fuel_3", np.array([0.001,0.001,0.001]), np.array([-6.54859, -15.46717, 0.41958]), np.array([0, 0, -0.70711, -0.70711]))
# self.add_part_custom("World/Environment","fuel", "fuel_4", np.array([0.001,0.001,0.001]), np.array([-6.14395, -15.47402, 0.41958]), np.array([0, 0, -0.70711, -0.70711]))
# self.add_part_custom("mock_robot/platform","FSuspensionBack", "xFSuspensionBack", np.array([0.001,0.001,0.001]), np.array([-0.90761, 0.03096, 0.69056]), np.array([0.48732, -0.51946, 0.50085, -0.49176]))
# self.add_part_custom("mock_robot/platform","engine_no_rigid", "engine", np.array([0.001,0.001,0.001]), np.array([-0.16041, -0.00551, 0.46581]), np.array([0.98404, -0.00148, -0.17792, -0.00274]))
# self.add_part_custom("mock_robot/platform","fuel", "xfuel", np.array([0.001,0.001,0.001]), np.array([0.11281, -0.08612, 0.59517]), np.array([0, 0, -0.70711, -0.70711]))
# Initialize our controller after load and the first reset
self.ur10_fuel = self._world.scene.get_object(task_params["arm_name_fuel"]["value"])
self.screw_ur10_fuel = self._world.scene.get_object(task_params["screw_arm_fuel"]["value"])
self.my_controller_fuel = KinematicsSolver(self.ur10_fuel, attach_gripper=True)
self.screw_my_controller_fuel = KinematicsSolver(self.screw_ur10_fuel, attach_gripper=True)
self.articulation_controller_fuel = self.ur10_fuel.get_articulation_controller()
self.screw_articulation_controller_fuel = self.screw_ur10_fuel.get_articulation_controller()
# battery cell set up ---------------------------------------------------------------------------------
# bring in moving platforms
self.battery_bringer = self._world.scene.get_object(task_params["eb_name_battery"]["value"])
# self.add_part_custom("World/Environment","battery", "battery_01_0", np.array([0.001,0.001,0.001]), np.array([-16.47861, -15.68368, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_00", np.array([0.001,0.001,0.001]), np.array([-16.66421, -15.68368, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_01", np.array([0.001,0.001,0.001]), np.array([-16.47861, -15.68368, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_02", np.array([0.001,0.001,0.001]), np.array([-16.29557, -15.68368, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_03", np.array([0.001,0.001,0.001]), np.array([-16.11273, -15.68368, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_04", np.array([0.001,0.001,0.001]), np.array([-16.66421, -15.55639, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_05", np.array([0.001,0.001,0.001]), np.array([-16.47861, -15.55639, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_06", np.array([0.001,0.001,0.001]), np.array([-16.29557, -15.55639, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
self.add_part_custom("World/Environment","battery", "battery_07", np.array([0.001,0.001,0.001]), np.array([-16.11273, -15.55639, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
# part feeding battery --------------------------------------
# self.add_part_custom("battery_bringer/platform","battery", "battery_01", np.array([0.001,0.001,0.001]), np.array([-0.23374, 0.08958, 0.2623]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("battery_bringer/platform","battery", "battery_02", np.array([0.001,0.001,0.001]), np.array([-0.23374, -0.13743, 0.2623]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("battery_bringer/platform","battery", "battery_03", np.array([0.001,0.001,0.001]), np.array([0.04161, -0.13743, 0.2623]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("battery_bringer/platform","battery", "battery_04", np.array([0.001,0.001,0.001]), np.array([0.30769, -0.13743, 0.2623]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("battery_bringer/platform","battery", "battery_05", np.array([0.001,0.001,0.001]), np.array([0.03519, 0.08958, 0.2623]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("battery_bringer/platform","battery", "battery_06", np.array([0.001,0.001,0.001]), np.array([0.30894, 0.08958, 0.2623]), np.array([0, 0, 0.70711, 0.70711]))
# Initialize our controller after load and the first reset
self.ur10_battery = self._world.scene.get_object(task_params["arm_name_battery"]["value"])
self.screw_ur10_battery = self._world.scene.get_object(task_params["screw_arm_battery"]["value"])
self.my_controller_battery = KinematicsSolver(self.ur10_battery, attach_gripper=True)
self.screw_my_controller_battery = KinematicsSolver(self.screw_ur10_battery, attach_gripper=True)
self.articulation_controller_battery = self.ur10_battery.get_articulation_controller()
self.screw_articulation_controller_battery = self.screw_ur10_battery.get_articulation_controller()
# trunk cell set up ---------------------------------------------------------------------------------
# bring in moving platforms
self.trunk_bringer = self._world.scene.get_object(task_params["eb_name_trunk"]["value"])
self.add_part_custom("World/Environment","trunk", "trunk_01", np.array([0.001,0.001,0.001]), np.array([-27.84904, 3.75405, 0.41467]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","trunk", "trunk_02_0", np.array([0.001,0.001,0.001]), np.array([-27.84904, 4.26505, 0.41467]), np.array([0, 0, -0.70711, -0.70711]))
# Initialize our controller after load and the first reset
self.ur10_trunk = self._world.scene.get_object(task_params["arm_name_trunk"]["value"])
self.screw_ur10_trunk = self._world.scene.get_object(task_params["screw_arm_trunk"]["value"])
self.my_controller_trunk = KinematicsSolver(self.ur10_trunk, attach_gripper=True)
self.screw_my_controller_trunk = KinematicsSolver(self.screw_ur10_trunk, attach_gripper=True)
self.articulation_controller_trunk = self.ur10_trunk.get_articulation_controller()
self.screw_articulation_controller_trunk = self.screw_ur10_trunk.get_articulation_controller()
# wheel cell set up ---------------------------------------------------------------------------------
# bring in moving platforms
self.wheel_bringer = self._world.scene.get_object(task_params["eb_name_wheel"]["value"])
self.add_part_custom("World/Environment","FWheel", "wheel_01_0", np.array([0.001,0.001,0.001]), np.array([-15.17319, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","FWheel", "wheel_02_0", np.array([0.001,0.001,0.001]), np.array([-15.17319, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","FWheel", "wheel_03_0", np.array([0.001,0.001,0.001]), np.array([-18.97836, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.add_part_custom("World/Environment","FWheel", "wheel_04_0", np.array([0.001,0.001,0.001]), np.array([-18.97836, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
# Initialize our controller after load and the first reset
self.ur10_wheel = self._world.scene.get_object(task_params["arm_name_wheel"]["value"])
self.screw_ur10_wheel = self._world.scene.get_object(task_params["screw_arm_wheel"]["value"])
self.my_controller_wheel = KinematicsSolver(self.ur10_wheel, attach_gripper=True)
self.screw_my_controller_wheel = KinematicsSolver(self.screw_ur10_wheel, attach_gripper=True)
self.articulation_controller_wheel = self.ur10_wheel.get_articulation_controller()
self.screw_articulation_controller_wheel = self.screw_ur10_wheel.get_articulation_controller()
self.ur10_wheel_01 = self._world.scene.get_object(task_params["arm_name_wheel_01"]["value"])
self.screw_ur10_wheel_01 = self._world.scene.get_object(task_params["screw_arm_wheel_01"]["value"])
self.my_controller_wheel_01 = KinematicsSolver(self.ur10_wheel_01, attach_gripper=True)
self.screw_my_controller_wheel_01 = KinematicsSolver(self.screw_ur10_wheel_01, attach_gripper=True)
self.articulation_controller_wheel_01 = self.ur10_wheel_01.get_articulation_controller()
self.screw_articulation_controller_wheel_01 = self.screw_ur10_wheel_01.get_articulation_controller()
# lower_cover cell set up ---------------------------------------------------------------------------------
# bring in moving platforms
# self.lower_cover_bringer = self._world.scene.get_object(task_params["eb_name_lower_cover"]["value"])
# self.add_part_custom("World/Environment","lower_cover", "lower_cover_01_0", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.57458, 0.40595]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("World/Environment","lower_cover", "lower_cover_02", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.30883, 0.40595]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("World/Environment","lower_cover", "lower_cover_03", np.array([0.001,0.001,0.001]), np.array([-25.86789, -15.30883, 0.40595]), np.array([0, 0, 0.70711, 0.70711]))
# self.add_part_custom("World/Environment","lower_cover", "lower_cover_04_0", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.13631, 0.40595]), np.array([0, 0, -0.70711, -0.70711]))
# self.add_part_custom("World/Environment","lower_cover", "lower_cover_05", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.3805, 0.40595]), np.array([0, 0, -0.70711, -0.70711]))
# self.add_part_custom("World/Environment","lower_cover", "lower_cover_06", np.array([0.001,0.001,0.001]), np.array([-25.88587, -19.3805, 0.40595]), np.array([0, 0, -0.70711, -0.70711]))
# right lower covers
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_3", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.47486, 0.40595]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_2", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.47486, 0.44595]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_1", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.47486, 0.48595]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_0", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.47486, 0.52595]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_7", np.array([0.001,0.001,0.001]), np.array([-25.86789, -15.47486, 0.40595]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_6", np.array([0.001,0.001,0.001]), np.array([-25.86789, -15.47486, 0.44595]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_5", np.array([0.001,0.001,0.001]), np.array([-25.86789, -15.47486, 0.48595]), np.array([0, 0, 0.70711, 0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverr_4", np.array([0.001,0.001,0.001]), np.array([-25.86789, -15.47486, 0.52595]), np.array([0, 0, 0.70711, 0.70711]))
# left lower covers
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_3", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.25546, 0.40595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_2", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.25546, 0.44595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_1", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.25546, 0.48595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_0", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.25546, 0.52595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_7", np.array([0.001,0.001,0.001]), np.array([-25.92747, -19.25546, 0.40595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_6", np.array([0.001,0.001,0.001]), np.array([-25.92747, -19.25546, 0.44595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_5", np.array([0.001,0.001,0.001]), np.array([-25.92747, -19.25546, 0.48595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","lower_cover", "lower_coverl_4", np.array([0.001,0.001,0.001]), np.array([-25.92747, -19.25546, 0.52595]), np.array([0, 0, -0.70711, -0.70711]))
self.add_part_custom("World/Environment","main_cover", "main_cover_0", np.array([0.001,0.001,0.001]), np.array([-18.7095-11.83808, -15.70872, 0.28822]), np.array([0.70711, 0.70711,0,0]))
# Initialize our controller after load and the first reset
self.ur10_lower_cover = self._world.scene.get_object(task_params["arm_name_lower_cover"]["value"])
self.screw_ur10_lower_cover = self._world.scene.get_object(task_params["screw_arm_lower_cover"]["value"])
self.my_controller_lower_cover = KinematicsSolver(self.ur10_lower_cover, attach_gripper=True)
self.screw_my_controller_lower_cover = KinematicsSolver(self.screw_ur10_lower_cover, attach_gripper=True)
self.articulation_controller_lower_cover = self.ur10_lower_cover.get_articulation_controller()
self.screw_articulation_controller_lower_cover = self.screw_ur10_lower_cover.get_articulation_controller()
self.ur10_lower_cover_01 = self._world.scene.get_object(task_params["arm_name_lower_cover_01"]["value"])
self.screw_ur10_lower_cover_01 = self._world.scene.get_object(task_params["screw_arm_lower_cover_01"]["value"])
self.my_controller_lower_cover_01 = KinematicsSolver(self.ur10_lower_cover_01, attach_gripper=True)
self.screw_my_controller_lower_cover_01 = KinematicsSolver(self.screw_ur10_lower_cover_01, attach_gripper=True)
self.articulation_controller_lower_cover_01 = self.ur10_lower_cover_01.get_articulation_controller()
self.screw_articulation_controller_lower_cover_01 = self.screw_ur10_lower_cover_01.get_articulation_controller()
self.ur10_main_cover = self._world.scene.get_object(task_params["arm_name_main_cover"]["value"])
self.my_controller_main_cover = KinematicsSolver(self.ur10_main_cover, attach_gripper=True)
self.articulation_controller_main_cover = self.ur10_main_cover.get_articulation_controller()
# handle cell set up ---------------------------------------------------------------------------------
# bring in moving platforms
self.handle_bringer = self._world.scene.get_object(task_params["eb_name_handle"]["value"])
self.add_part_custom("World/Environment","handle", "handle_0", np.array([0.001,0.001,0.001]), np.array([-29.70213, -7.25934, 1.08875]), np.array([0, 0.70711, 0.70711, 0]))
# Initialize our controller after load and the first reset
self.ur10_handle = self._world.scene.get_object(task_params["arm_name_handle"]["value"])
self.screw_ur10_handle = self._world.scene.get_object(task_params["screw_arm_handle"]["value"])
self.my_controller_handle = KinematicsSolver(self.ur10_handle, attach_gripper=True)
self.screw_my_controller_handle = KinematicsSolver(self.screw_ur10_handle, attach_gripper=True)
self.articulation_controller_handle = self.ur10_handle.get_articulation_controller()
self.screw_articulation_controller_handle = self.screw_ur10_handle.get_articulation_controller()
# self.add_part_custom("World/UR10_main_cover/ee_link","main_cover", f"qmain_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.71735, 0.26961, -0.69234]), np.array([0.5, 0.5, -0.5, 0.5]))
# light cell set up ---------------------------------------------------------------------------------
# bring in moving platforms
self.light_bringer = self._world.scene.get_object(task_params["eb_name_light"]["value"])
self.light_offset = 0.19384
# self.add_part_custom("World/Environment","FFrontLightAssembly", "light_00", np.array([0.001,0.001,0.001]), np.array([-18.07685, -6.94324 + self.light_offset, -0.71703]), np.array([0.28511, -0.28511, -0.64708, -0.64708]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_00", np.array([0.001,0.001,0.001]), np.array([-18.07685, -6.94324, -0.71703]), np.array([0.28511, -0.28511, -0.64708, -0.64708]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_01", np.array([0.001,0.001,0.001]), np.array([-18.07685, -7.14276, -0.71703]), np.array([0.28511, -0.28511, -0.64708, -0.64708]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_02", np.array([0.001,0.001,0.001]), np.array([-18.07685, -7.35866, -0.71703]), np.array([0.28511, -0.28511, -0.64708, -0.64708]))
# self.add_part_custom("World/Environment","FFrontLightAssembly", "light_03", np.array([0.001,0.001,0.001]), np.array([-18.07685, -7.56251, -0.71703]), np.array([0.28511, -0.28511, -0.64708, -0.64708]))
# self.add_part_custom("World/Environment","FFrontLightAssembly", "light_03", np.array([0.001,0.001,0.001]), np.array([-18.21921, -7.19762, -0.71703]), np.array([0.65916, 0.25595, -0.65916, -0.25595]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_03", np.array([0.001,0.001,0.001]), np.array([-18.02266, -7.19762, -0.71703]), np.array([0.65916, 0.25595, -0.65916, -0.25595]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_04", np.array([0.001,0.001,0.001]), np.array([-17.82314, -7.19762, -0.71703]), np.array([0.65916, 0.25595, -0.65916, -0.25595]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_05", np.array([0.001,0.001,0.001]), np.array([-17.60725, -7.19762, -0.71703]), np.array([0.65916, 0.25595, -0.65916, -0.25595]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_06", np.array([0.001,0.001,0.001]), np.array([-17.40341, -7.19762, -0.71703]), np.array([0.65916, 0.25595, -0.65916, -0.25595]))
self.add_part_custom("World/Environment","FFrontLightAssembly", "light_07", np.array([0.001,0.001,0.001]), np.array([-17.40341+self.light_offset, -7.19762, -0.71703]), np.array([0.65916, 0.25595, -0.65916, -0.25595]))
# self.add_part_custom("mock_robot/platform","handle", "xhandle", np.array([0.001,0.001,0.001]), np.array([0.82439, 0.44736, 1.16068]), np.array([0.20721, 0.68156, -0.67309, -0.19874]))
# self.add_part_custom("mock_robot/platform","main_cover", "xmain_cover", np.array([0.001,0.001,0.001]), np.array([-0.81508, 0.27909, 0.19789]), np.array([0.70711, 0.70711, 0, 0]))
# Initialize our controller after load and the first reset
self.ur10_light = self._world.scene.get_object(task_params["arm_name_light"]["value"])
self.screw_ur10_light = self._world.scene.get_object(task_params["screw_arm_light"]["value"])
self.my_controller_light = KinematicsSolver(self.ur10_light, attach_gripper=True)
self.screw_my_controller_light = KinematicsSolver(self.screw_ur10_light, attach_gripper=True)
self.articulation_controller_light = self.ur10_light.get_articulation_controller()
self.screw_articulation_controller_light = self.screw_ur10_light.get_articulation_controller()
# temporary additions -------------------------------------------------
# self.add_part_custom("mock_robot/platform","FWheel", "xwheel_02", np.array([0.001,0.001,0.001]), np.array([-0.80934, 0.35041, 0.43888]), np.array([0.5, -0.5, 0.5, -0.5]))
# self.add_part_custom("mock_robot/platform","FWheel", "xwheel_04", np.array([0.001,0.001,0.001]), np.array([-0.80845, -0.22143, 0.43737]), np.array([0.5, -0.5, 0.5, -0.5]))
# self.add_part_custom("mock_robot/platform","FWheel", "xwheel_01", np.array([0.001,0.001,0.001]), np.array([0.1522, 0.33709, 0.56377]), np.array([0.5, -0.5, 0.5, -0.5]))
# self.add_part_custom("mock_robot/platform","FWheel", "xwheel_03", np.array([0.001,0.001,0.001]), np.array([0.15255, -0.1948, 0.56377]), np.array([0.5, -0.5, 0.5, -0.5]))
# self.add_part_custom("mock_robot/platform","trunk", "xtrunk", np.array([0.001,0.001,0.001]), np.array([-0.79319, -0.21112, 0.70114]), np.array([0.5, 0.5, 0.5, 0.5]))
# self.add_part_custom("mock_robot/platform","battery", "xbattery", np.array([0.001,0.001,0.001]), np.array([-0.20126, 0.06146, 0.58443]), np.array([0.4099, 0.55722, -0.58171, -0.42791]))
# self.add_part_custom("mock_robot/platform","fuel", "xfuel", np.array([0.001,0.001,0.001]), np.array([0.11281, -0.08612, 0.59517]), np.array([0, 0, -0.70711, -0.70711]))
# self.add_part_custom("mock_robot/platform","FSuspensionBack", "xFSuspensionBack", np.array([0.001,0.001,0.001]), np.array([-0.87892, 0.0239, 0.82432]), np.array([0.40364, -0.58922, 0.57252, -0.40262]))
# self.add_part_custom("mock_robot/platform","engine_no_rigid", "engine", np.array([0.001,0.001,0.001]), np.array([-0.16041, -0.00551, 0.46581]), np.array([0.98404, -0.00148, -0.17792, -0.00274]))
# # part feeder stuff ----------------------------
# self.add_part_custom("fuel_bringer/platform","fuel", "fuel_05", np.array([0.001,0.001,0.001]), np.array([-0.17458, 0.136, 0.26034]), np.array([0.5 ,0.5, -0.5, -0.5]))
# self.add_part_custom("fuel_bringer/platform","fuel", "fuel_06", np.array([0.001,0.001,0.001]), np.array([0.10727, 0.136, 0.26034]), np.array([0.5 ,0.5, -0.5, -0.5]))
# self.add_part_custom("fuel_bringer/platform","fuel", "fuel_07", np.array([0.001,0.001,0.001]), np.array([0.375, 0.136, 0.26034]), np.array([0.5 ,0.5, -0.5, -0.5]))
# self.add_part_custom("suspension_bringer/platform","FSuspensionBack", "FSuspensionBack_10", np.array([0.001,0.001,0.001]), np.array([0.16356, -0.19391, 0.25373]), np.array([0.70711, 0, -0.70711, 0]))
# self.add_part_custom("suspension_bringer/platform","FSuspensionBack", "FSuspensionBack_11", np.array([0.001,0.001,0.001]), np.array([0.31896, -0.19391, 0.25373]), np.array([0.70711, 0, -0.70711, 0]))
# self.add_part_custom("suspension_bringer/platform","FSuspensionBack", "FSuspensionBack_12", np.array([0.001,0.001,0.001]), np.array([0.47319, -0.19391, 0.25373]), np.array([0.70711, 0, -0.70711, 0]))
# self.add_part_custom("suspension_bringer/platform","FSuspensionBack", "FSuspensionBack_13", np.array([0.001,0.001,0.001]), np.array([0.6372, -0.19391, 0.25373]), np.array([0.70711, 0, -0.70711, 0]))
# self.add_part_custom("suspension_bringer/platform","FSuspensionBack", "FSuspensionBack_14", np.array([0.001,0.001,0.001]), np.array([0.80216, -0.19391, 0.25373]), np.array([0.70711, 0, -0.70711, 0]))
# self.add_part_custom("engine_bringer/platform","engine_no_rigid", "engine_11", np.array([0.001,0.001,0.001]), np.array([0, 0, 0.43148]), np.array([0.99457, 0, -0.10407, 0]))
# ATV executor class declaration -------------------------------------------------
self.suspension = [[{"index":0, "position": np.array([0.72034, 0.08607, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -5.27931, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":1, "position": np.array([0.72034, 0.08607, 0.33852-0.16]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -5.27931, 0.58122]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":2, "position": np.array([0.72034, 0.08607, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -5.27931, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}],
[{"index":0, "position": np.array([0.72034, -0.05477, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.822, -5.13962, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":1, "position": np.array([0.72034, -0.05477, 0.33852-0.16]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.822, -5.13962, 0.58122]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":2, "position": np.array([0.72034, -0.05477, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.822, -5.13962, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}],
[{"index":0, "position": np.array([0.72034, -0.20689, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.98634, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":1, "position": np.array([0.72034, -0.20689, 0.33852-0.16]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.98634, 0.58122]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":2, "position": np.array([0.72034, -0.20689, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.98634, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}],
[{"index":0, "position": np.array([0.72034, -0.36659, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.82664, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":1, "position": np.array([0.72034, -0.36659, 0.33852-0.16]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.82664, 0.58122]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":2, "position": np.array([0.72034, -0.36659, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.82664, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}],
[{"index":0, "position": np.array([0.72034, -0.52521, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.66802, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":1, "position": np.array([0.72034, -0.52521, 0.33852-0.16]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.66802, 0.58122]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":2, "position": np.array([0.72034, -0.52521, 0.33852-0.16+0.2]), "orientation": np.array([0.5,-0.5,0.5,0.5]), "goal_position":np.array([-6.8209, -4.66802, 0.58122+0.2]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}],
[{"index":0, "position": np.array([0.44319, -0.60758, 0.33852-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.54418, -4.58567, 0.58122+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.44319, -0.60758, 0.33852-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.54418, -4.58567, 0.58122]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.44319, -0.60758, 0.33852-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.54418, -4.58567, 0.58122+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
[{"index":0, "position": np.array([0.30166, -0.60758, 0.33852-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.40265, -4.58567, 0.58122+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.30166, -0.60758, 0.33852-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.40265, -4.58567, 0.58122]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.30166, -0.60758, 0.33852-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.40265, -4.58567, 0.58122+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
[{"index":0, "position": np.array([0.1356, -0.60758, 0.33852-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.23659, -4.58567, 0.58122+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.1356, -0.60758, 0.33852-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.23659, -4.58567, 0.58122]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.1356, -0.60758, 0.33852-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.23659, -4.58567, 0.58122+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
]
self.battery = [[{"index":0, "position": np.array([0.05713, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.61088, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.05713, -0.61362, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.61088, -15.71631, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.05713, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.61088, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([-0.12728, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.12728, -0.61362, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.71631, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.12728, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([-0.31243, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.24132, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.31243, -0.61362, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.24132, -15.71631, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.31243, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.24132, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([-0.49671, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.05704, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.49671, -0.61362, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.05704, -15.71631, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.49671, -0.61362, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.05704, -15.71631, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([0.05713, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.61088, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.05713, -0.74178, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.61088, -15.58815, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.05713, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.61088, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([-0.12728, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.12728, -0.74178, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.58815, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.12728, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([-0.31243, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.24132, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.31243, -0.74178, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.24132, -15.58815, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.31243, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.24132, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([-0.49671, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.05704, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.49671, -0.74178, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.05704, -15.58815, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.49671, -0.74178, 0.4+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.05704, -15.58815, 0.64303+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
]
self.fuel = [[{"index":0, "position": np.array([0.71705+0.16, 0.06232-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443, -16.22609+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16, 0.06232-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -16.22609+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16, 0.06232-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -16.22609+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}],
[{"index":0, "position": np.array([0.71705+0.16, -0.2367-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443, -15.92707+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16, -0.2367-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.92707+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16, -0.2367-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.92707+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}],
[{"index":0, "position": np.array([0.71705+0.16, -0.53766-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443, -15.62611+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16, -0.53766-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.62611+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16, -0.53766-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.62611+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}],
[{"index":0, "position": np.array([0.71705+0.16, -0.8428-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443, -15.32097+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16, -0.8428-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.32097+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16, -0.8428-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.32097+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}],
[{"index":0, "position": np.array([0.71705+0.16+0.26557, 0.06232-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443-0.26557, -16.22609+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16+0.26557, 0.06232-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -16.22609+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16+0.26557, 0.06232-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -16.22609+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}
# {"index":2, "position": np.array([0.87135+0.16+0.26557, 0.06232-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -16.22609+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}
],
[{"index":0, "position": np.array([0.71705+0.16+0.26557, -0.2367-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443-0.26557, -15.92707+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16+0.26557, -0.2367-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -15.92707+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16+0.26557, -0.2367-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -15.92707+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}],
[{"index":0, "position": np.array([0.71705+0.16+0.26557, -0.53766-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443-0.26557, -15.62611+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16+0.26557, -0.53766-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -15.62611+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16+0.26557, -0.53766-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -15.62611+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}],
[{"index":0, "position": np.array([0.71705+0.16+0.26557, -0.8428-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443-0.26557, -15.32097+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":1, "position": np.array([0.87135+0.16+0.26557, -0.8428-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -15.32097+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":2, "position": np.array([0.87135+0.16+0.26557, -0.8428-self.offset, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -15.32097+self.offset, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}
# {"index":2, "position": np.array([0.87135+0.16+0.26557, -0.8428-self.offset, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873-0.26557, -15.32097+self.offset, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}
],
]
self.lower_coverr = [
[{"index":0, "position": np.array([-0.49105, 0.8665, -0.16+0.56397+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.80567+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.49105, 0.8665, -0.16+0.56397]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.80567]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.49105, 0.8665, -0.16+0.56397+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.80567+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
[{"index":0, "position": np.array([-0.49105, 0.8665, -0.16+0.52368+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.76538+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.49105, 0.8665, -0.16+0.52368]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.76538]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.49105, 0.8665, -0.16+0.52368+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.76538+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
[{"index":0, "position": np.array([-0.49105, 0.8665, -0.16+0.48417+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.72587+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.49105, 0.8665, -0.16+0.48417]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.72587]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.49105, 0.8665, -0.16+0.48417+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.72587+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
[{"index":0, "position": np.array([-0.49105, 0.8665, -0.16+0.4434+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.6851+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.49105, 0.8665, -0.16+0.4434]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.6851]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.49105, 0.8665, -0.16+0.4434+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.3925, 0.6851+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
[{"index":0, "position": np.array([-0.10504, 0.8665, -0.16+0.56397+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.80567+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.10504, 0.8665, -0.16+0.56397]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.80567]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.10504, 0.8665, -0.16+0.56397+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.80567+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
[{"index":0, "position": np.array([-0.10504, 0.8665, -0.16+0.52368+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.76538+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.10504, 0.8665, -0.16+0.52368]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.76538]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.10504, 0.8665, -0.16+0.52368+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.76538+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
[{"index":0, "position": np.array([-0.10504, 0.8665, -0.16+0.48417+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.72587+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.10504, 0.8665, -0.16+0.48417]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.72587]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.10504, 0.8665, -0.16+0.48417+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.72587+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
[{"index":0, "position": np.array([-0.10504, 0.8665, -0.16+0.4434+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.6851+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-0.10504, 0.8665, -0.16+0.4434]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.6851]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-0.10504, 0.8665, -0.16+0.4434+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.16393, -15.3925, 0.6851+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}],
]
self.lower_coverl = [
[{"index":0, "position": np.array([0.49458, 0.86119, -0.16+0.56518+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.80656+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.49458, 0.86119, -0.16+0.56518]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.80656]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.49458, 0.86119, -0.16+0.56518+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.80656+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
[{"index":0, "position": np.array([0.49458, 0.86119, -0.16+0.52494+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.76632+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.49458, 0.86119, -0.16+0.52494]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.76632]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.49458, 0.86119, -0.16+0.52494+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.76632+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
[{"index":0, "position": np.array([0.49458, 0.86119, -0.16+0.48451+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.72589+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.49458, 0.86119, -0.16+0.48451]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.72589]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.49458, 0.86119, -0.16+0.48451+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.72589+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
[{"index":0, "position": np.array([0.49458, 0.86119, -0.16+0.44428+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.68566+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.49458, 0.86119, -0.16+0.44428]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.68566]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.49458, 0.86119, -0.16+0.44428+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.18024, 0.68566+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
[{"index":0, "position": np.array([0.1613, 0.86119, -0.16+0.56518+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.80656+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.1613, 0.86119, -0.16+0.56518]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.80656]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.1613, 0.86119, -0.16+0.56518+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.80656+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
[{"index":0, "position": np.array([0.1613, 0.86119, -0.16+0.52494+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.76632+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.1613, 0.86119, -0.16+0.52494]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.76632]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.1613, 0.86119, -0.16+0.52494+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.76632+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
[{"index":0, "position": np.array([0.1613, 0.86119, -0.16+0.48451+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.72589+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.1613, 0.86119, -0.16+0.48451]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.72589]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.1613, 0.86119, -0.16+0.48451+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.72589+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
[{"index":0, "position": np.array([0.1613, 0.86119, -0.16+0.44428+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.68566+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.1613, 0.86119, -0.16+0.44428]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.68566]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":2, "position": np.array([0.1613, 0.86119, -0.16+0.44428+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.22055, -19.18024, 0.68566+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}],
]
self.light = [
# [{"index":0, "position": np.array([0.5517, 0.26622-self.light_offset, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -6.81919+self.light_offset, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# {"index":1, "position": np.array([0.5517, 0.26622-self.light_offset, -0.16+0.34371]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -6.81919+self.light_offset, 0.58583]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# {"index":2, "position": np.array([0.5517, 0.26622-self.light_offset, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -6.81919+self.light_offset, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([0.5517, 0.26622, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -6.81919, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.5517, 0.26622, -0.16+0.34371]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -6.81919, 0.58583]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.5517, 0.26622, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -6.81919, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([0.5517, 0.46812, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.02109, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.5517, 0.46812, -0.16+0.34371]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.02109, 0.58583]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.5517, 0.46812, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.02109, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
[{"index":0, "position": np.array([0.5517, 0.68287, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.23584, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.5517, 0.68287, -0.16+0.34371]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.23584, 0.58583]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.5517, 0.68287, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.23584, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
# [
# {"index":0, "position": np.array([0.50855, 0.76133, -0.16+0.58629]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.43924, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# # {"index":0, "position": np.array([-0.57726, -0.00505, -0.16+0.65911]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.25466, -6.54783, 0.90123]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":1, "position": np.array([0.5517, 0.88627, -0.16+0.34371]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.43924, 0.58583]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# {"index":2, "position": np.array([0.5517, 0.88627, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.43924, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}],
# [{"index":0, "position": np.array([0.31451+self.light_offset, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.14657-self.light_offset, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":1, "position": np.array([0.31451+self.light_offset, 0.9514, -0.16+0.34371]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.14657-self.light_offset, -7.50448, 0.58583]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":2, "position": np.array([0.31451+self.light_offset, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.14657-self.light_offset, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
[{"index":0, "position": np.array([0.31451, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.14657, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.31451, 0.9514, -0.16+0.34371]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.14657, -7.50448, 0.58583]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.31451, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.14657, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
[{"index":0, "position": np.array([0.11405, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.94611, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.11405, 0.9514, -0.16+0.34371]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.94611, -7.50448, 0.58583]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.11405, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.94611, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
[{"index":0, "position": np.array([-0.10054, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.73152, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([-0.10054, 0.9514, -0.16+0.34371]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.73152, -7.50448, 0.58583]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([-0.10054, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.73152, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
[{"index":0, "position": np.array([-0.30438, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.52768, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([-0.30438, 0.9514, -0.16+0.34371]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.52768, -7.50448, 0.58583]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([-0.30438, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.52768, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
[{"index":0, "position": np.array([-0.30438-self.light_offset, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.52768+self.light_offset, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([-0.30438-self.light_offset, 0.9514, -0.16+0.34371]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.52768+self.light_offset, -7.50448, 0.58583]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([-0.30438-self.light_offset, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.52768+self.light_offset, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}],
]
for i,ATV in enumerate(self.ATV_executions):
# id ----------------
ATV.id = i
# no part feeding parts
ATV.suspension = self.suspension[i]
ATV.battery = self.battery[i]
ATV.fuel = self.fuel[i]
ATV.light = self.light[i]
ATV.lower_cover = [self.lower_coverr[i], self.lower_coverl[i]]
# ATV declarations ----------------------------------------------------------
ATV.moving_platform = self.moving_platforms[i]
# Engine cell setup -------------------------
ATV.my_controller = self.my_controller
ATV.screw_my_controller = self.screw_my_controller
ATV.articulation_controller = self.articulation_controller
ATV.screw_articulation_controller = self.screw_articulation_controller
# Suspension cell set up ------------------------------------------------------------------------
ATV.my_controller_suspension = self.my_controller_suspension
ATV.screw_my_controller_suspension = self.screw_my_controller_suspension
ATV.articulation_controller_suspension = self.articulation_controller_suspension
ATV.screw_articulation_controller_suspension = self.screw_articulation_controller_suspension
# Fuel cell set up ---------------------------------------------------------------------------------
ATV.my_controller_fuel = self.my_controller_fuel
ATV.screw_my_controller_fuel = self.screw_my_controller_fuel
ATV.articulation_controller_fuel = self.articulation_controller_fuel
ATV.screw_articulation_controller_fuel = self.screw_articulation_controller_fuel
# battery cell set up ---------------------------------------------------------------------------------
ATV.my_controller_battery = self.my_controller_battery
ATV.screw_my_controller_battery = self.screw_my_controller_battery
ATV.articulation_controller_battery = self.articulation_controller_battery
ATV.screw_articulation_controller_battery = self.screw_articulation_controller_battery
# trunk cell set up ---------------------------------------------------------------------------------
ATV.my_controller_trunk = self.my_controller_trunk
ATV.screw_my_controller_trunk = self.screw_my_controller_trunk
ATV.articulation_controller_trunk = self.articulation_controller_trunk
ATV.screw_articulation_controller_trunk = self.screw_articulation_controller_trunk
# wheel cell set up ---------------------------------------------------------------------------------
ATV.my_controller_wheel = self.my_controller_wheel
ATV.screw_my_controller_wheel = self.screw_my_controller_wheel
ATV.articulation_controller_wheel = self.articulation_controller_wheel
ATV.screw_articulation_controller_wheel = self.screw_articulation_controller_wheel
ATV.my_controller_wheel_01 = self.my_controller_wheel_01
ATV.screw_my_controller_wheel_01 = self.screw_my_controller_wheel_01
ATV.articulation_controller_wheel_01 = self.articulation_controller_wheel_01
ATV.screw_articulation_controller_wheel_01 = self.screw_articulation_controller_wheel_01
# lower_cover cell set up ---------------------------------------------------------------------------------
ATV.my_controller_lower_cover = self.my_controller_lower_cover
ATV.screw_my_controller_lower_cover = self.screw_my_controller_lower_cover
ATV.articulation_controller_lower_cover = self.articulation_controller_lower_cover
ATV.screw_articulation_controller_lower_cover = self.screw_articulation_controller_lower_cover
ATV.my_controller_lower_cover_01 = self.my_controller_lower_cover_01
ATV.screw_my_controller_lower_cover_01 = self.screw_my_controller_lower_cover_01
ATV.articulation_controller_lower_cover_01 = self.articulation_controller_lower_cover_01
ATV.screw_articulation_controller_lower_cover_01 = self.screw_articulation_controller_lower_cover_01
ATV.my_controller_main_cover = self.my_controller_main_cover
ATV.articulation_controller_main_cover = self.articulation_controller_main_cover
# handle cell set up ---------------------------------------------------------------------------------
ATV.my_controller_handle = self.my_controller_handle
ATV.screw_my_controller_handle = self.screw_my_controller_handle
ATV.articulation_controller_handle = self.articulation_controller_handle
ATV.screw_articulation_controller_handle = self.screw_articulation_controller_handle
# light cell set up --------------------------------------------------------------------------------
ATV.my_controller_light = self.my_controller_light
ATV.screw_my_controller_light = self.screw_my_controller_light
ATV.articulation_controller_light = self.articulation_controller_light
ATV.screw_articulation_controller_light = self.screw_articulation_controller_light
ATV.world = self._world
ATV.declare_utils()
# PF executor class declaration -------------------------------------------------
for i,PF in enumerate(self.PF_executions):
# id ----------------
PF.id = 0
# PF declarations ----------------------------------------------------------
PF.moving_platform = self.part_feeders[i]
# Engine cell setup -------------------------
PF.my_controller = self.my_controller
PF.screw_my_controller = self.screw_my_controller
PF.articulation_controller = self.articulation_controller
PF.screw_articulation_controller = self.screw_articulation_controller
# Suspension cell set up ------------------------------------------------------------------------
PF.my_controller_suspension = self.my_controller_suspension
PF.screw_my_controller_suspension = self.screw_my_controller_suspension
PF.articulation_controller_suspension = self.articulation_controller_suspension
PF.screw_articulation_controller_suspension = self.screw_articulation_controller_suspension
# Fuel cell set up ---------------------------------------------------------------------------------
PF.my_controller_fuel = self.my_controller_fuel
PF.screw_my_controller_fuel = self.screw_my_controller_fuel
PF.articulation_controller_fuel = self.articulation_controller_fuel
PF.screw_articulation_controller_fuel = self.screw_articulation_controller_fuel
# battery cell set up ---------------------------------------------------------------------------------
PF.my_controller_battery = self.my_controller_battery
PF.screw_my_controller_battery = self.screw_my_controller_battery
PF.articulation_controller_battery = self.articulation_controller_battery
PF.screw_articulation_controller_battery = self.screw_articulation_controller_battery
# trunk cell set up ---------------------------------------------------------------------------------
PF.my_controller_trunk = self.my_controller_trunk
PF.screw_my_controller_trunk = self.screw_my_controller_trunk
PF.articulation_controller_trunk = self.articulation_controller_trunk
PF.screw_articulation_controller_trunk = self.screw_articulation_controller_trunk
# wheel cell set up ---------------------------------------------------------------------------------
PF.my_controller_wheel = self.my_controller_wheel
PF.screw_my_controller_wheel = self.screw_my_controller_wheel
PF.articulation_controller_wheel = self.articulation_controller_wheel
PF.screw_articulation_controller_wheel = self.screw_articulation_controller_wheel
PF.my_controller_wheel_01 = self.my_controller_wheel_01
PF.screw_my_controller_wheel_01 = self.screw_my_controller_wheel_01
PF.articulation_controller_wheel_01 = self.articulation_controller_wheel_01
PF.screw_articulation_controller_wheel_01 = self.screw_articulation_controller_wheel_01
# lower_cover cell set up ---------------------------------------------------------------------------------
PF.my_controller_lower_cover = self.my_controller_lower_cover
PF.screw_my_controller_lower_cover = self.screw_my_controller_lower_cover
PF.articulation_controller_lower_cover = self.articulation_controller_lower_cover
PF.screw_articulation_controller_lower_cover = self.screw_articulation_controller_lower_cover
PF.my_controller_lower_cover_01 = self.my_controller_lower_cover_01
PF.screw_my_controller_lower_cover_01 = self.screw_my_controller_lower_cover_01
PF.articulation_controller_lower_cover_01 = self.articulation_controller_lower_cover_01
PF.screw_articulation_controller_lower_cover_01 = self.screw_articulation_controller_lower_cover_01
PF.my_controller_main_cover = self.my_controller_main_cover
PF.articulation_controller_main_cover = self.articulation_controller_main_cover
# handle cell set up ---------------------------------------------------------------------------------
PF.my_controller_handle = self.my_controller_handle
PF.screw_my_controller_handle = self.screw_my_controller_handle
PF.articulation_controller_handle = self.articulation_controller_handle
PF.screw_articulation_controller_handle = self.screw_articulation_controller_handle
# light cell set up --------------------------------------------------------------------------------
PF.my_controller_light = self.my_controller_light
PF.screw_my_controller_light = self.screw_my_controller_light
PF.articulation_controller_light = self.articulation_controller_light
PF.screw_articulation_controller_light = self.screw_articulation_controller_light
PF.world = self._world
PF.declare_utils()
return
async def setup_post_reset(self):
self._my_controller.reset()
await self._world.play_async()
return
def give_location(self, prim_path):
dc=_dynamic_control.acquire_dynamic_control_interface()
object=dc.get_rigid_body(prim_path)
object_pose=dc.get_rigid_body_pose(object)
return object_pose # position: object_pose.p, rotation: object_pose.r
def _check_goal_reached(self, goal_pose):
# Cannot get result from ROS because /move_base/result also uses move_base_msgs module
mp_position, mp_orientation = self.moving_platforms[0].get_world_pose()
_, _, mp_yaw = euler_from_quaternion(mp_orientation)
_, _, goal_yaw = euler_from_quaternion(goal_pose[3:])
# FIXME: pi needed for yaw tolerance here because map rotated 180 degrees
if np.allclose(mp_position[:2], goal_pose[:2], atol=self._xy_goal_tolerance) \
and abs(mp_yaw-goal_yaw) <= pi + self._yaw_goal_tolerance:
print("Goal "+str(goal_pose)+" reached!")
# This seems to crash Isaac sim...
# self.get_world().remove_physics_callback("mp_nav_check")
# Goal hardcoded for now
def _send_navigation_goal(self, x=None, y=None, a=None):
# x, y, a = -18, 14, 3.14
# x,y,a = -4.65, 5.65,3.14
orient_x, orient_y, orient_z, orient_w = quaternion_from_euler(0, 0, a)
pose = [x, y, 0, orient_x, orient_y, orient_z, orient_w]
goal_msg = PoseStamped()
goal_msg.header.frame_id = "map"
goal_msg.header.stamp = rospy.get_rostime()
print("goal pose: "+str(pose))
goal_msg.pose.position.x = pose[0]
goal_msg.pose.position.y = pose[1]
goal_msg.pose.position.z = pose[2]
goal_msg.pose.orientation.x = pose[3]
goal_msg.pose.orientation.y = pose[4]
goal_msg.pose.orientation.z = pose[5]
goal_msg.pose.orientation.w = pose[6]
world = self.get_world()
self._goal_pub.publish(goal_msg)
# self._check_goal_reached(pose)
world = self.get_world()
if not world.physics_callback_exists("mp_nav_check"):
world.add_physics_callback("mp_nav_check", lambda step_size: self._check_goal_reached(pose))
# Overwrite check with new goal
else:
world.remove_physics_callback("mp_nav_check")
world.add_physics_callback("mp_nav_check", lambda step_size: self._check_goal_reached(pose))
def move_to_engine_cell(self):
# # print("sending nav goal")
if not self.bool_done[123]:
self._send_navigation_goal(-4.65, 5.65, 3.14)
self.bool_done[123] = True
return False
def send_robot_actions(self, step_size):
current_observations = self._world.get_observations()
# print("\n\n\n\nCurrent observations:",current_observations)
# naming convention
# {product number}_{station name}_{operation}_{part}_{task number}
# p1_stationB_install_chain_engine_31
task_to_func_map = {
"0":"move_to_engine_cell_nav",
"1": "move_to_engine_cell",
"71":"arm_place_engine",
"2":"screw_engine",
"72":"arm_remove_engine",
"3":"turn_mobile_platform",
"4":"screw_engine_two",
"6":"wait",
"101":"move_to_suspension_cell",
"151":"arm_place_suspension",
"171":"screw_suspension",
"181":"arm_remove_suspension",
"102":"wait",
"301":"move_to_battery_cell",
"351":"arm_place_battery",
"371":"screw_battery",
"381":"arm_remove_battery",
"302":"wait",
"305":"move_mp_to_battery_cell",
"306":"battery_part_feeding",
"307":"moving_part_feeders",
"201":"move_to_fuel_cell",
"251":"arm_place_fuel",
"271":"screw_fuel",
"281":"arm_remove_fuel",
"202":"wait",
"401":"move_to_trunk_cell",
"451":"arm_place_trunk",
"471":"screw_trunk",
"481":"arm_remove_trunk",
"402":"wait",
"501":"move_to_wheel_cell",
"590":"arm_place_fwheel_together",
"591":"screw_fwheel_together",
"505":"move_ahead_in_wheel_cell",
"592":"arm_place_bwheel_together",
"593":"screw_bwheel_together",
"502":"wait",
"701":"move_to_lower_cover_cell",
"790":"arm_place_lower_cover_together",
"791":"screw_lower_cover_together",
"702":"wait",
"721":"move_to_main_cover_cell",
"731":"arm_place_main_cover",
"703":"wait",
"801":"move_to_handle_cell",
"851":"arm_place_handle",
"871":"screw_handle",
"802":"wait",
"901":"move_to_light_cell",
"951":"arm_place_light",
"971":"screw_light",
"902":"wait",
"1000":"go_to_end_goal",
"1100":"move_to_contingency_cell",
"1101":"disassemble",
"1102":"carry_on"
}
# schedule = deque(["1","71","2","72","3","4","6","101","151","171","181","102","301","351","371","381","302","201","251","271","281","202","401","451","471","481","402","501","590","591","505","592","593","502","701","790","791","702","721","731","703","801","851","871","881","802","901","951","971","902"])
# schedule = deque(["1","71","2","72","3","4","6","101","102","301","302","201","202","401","402","501","505","502","701","721","703","801","851","871","881","802","901","902"])
# schedule = deque(["1","71"])
sc = SimulationContext()
print("Time:", sc.current_time)
time_threshold = 180
for i in range(len(self.schedules)):
# # wait for part feeder check
# if i>0:
# # print("ATV "+str(i)+":", self.schedules[i][0], self.schedules[i-1][0], self.schedules[i][0] == self.schedules[i-1][0])
# isWait = self.wait_for_parts(i)
# if isWait and self.schedules[i][0]=="401":
# print("ATV "+str(i)+": ", self.schedules[i])
# print("Wait status:",isWait)
# self.ATV_executions[i].wait_infinitely()
# continue
# if self.schedules[i-1] and self.schedules[i] and (self.schedules[i][0] == self.schedules[i-1][0] and self.schedules[i-1][0]!="401"):
# isWait=True
# if isWait and sc.current_time>i*time_threshold:
# print("ATV "+str(i)+": ", self.schedules[i])
# print("Waiting for next mp to move...")
# else:
# if isWait and sc.current_time>i*time_threshold:
# print("ATV "+str(i)+": ", self.schedules[i])
# print("Waiting for part...")
# else:
# isWait = False
if self.schedules[i] and sc.current_time>i*time_threshold:
# if self.schedules[i] and sc.current_time>i*50:
print("ATV "+str(i)+": ", self.schedules[i])
curr_schedule = self.schedules[i][0]
curr_schedule_function = getattr(self.ATV_executions[i], task_to_func_map[curr_schedule])
function_done = curr_schedule_function()
if function_done:
print("Done with", task_to_func_map[curr_schedule])
self.schedules[i].popleft()
# updating visited status for each ATV
if self.schedules[i]:
new_schedule = self.schedules[i][0]
if not self.ATV_executions[i].visited["engine"] and any(int(new_schedule) >= x for x in [0,1,2,3,4,6,71,72]):
self.ATV_executions[i].visited["engine"]=True
# if i==0:
if not self.ATV_executions[i].visited["trunk"] and any(int(new_schedule) >= x for x in [401,451,471,481,402]):
self.ATV_executions[i].visited["trunk"]=True
if not self.ATV_executions[i].visited["wheels"] and any(int(new_schedule) >= x for x in [501,590,591,505,592,593,502]):
self.ATV_executions[i].visited["wheels"]=True
# if not self.ATV_executions[i].visited["cover"] and any(int(new_schedule) >= x for x in [701,790,791,702,721,731,703]):
# self.ATV_executions[i].visited["cover"]=True
# if not self.ATV_executions[i].visited["handle"] and any(int(new_schedule) >= x for x in [801,851,871,802]):
# self.ATV_executions[i].visited["handle"]=True
pf_to_function = {"6":"wait",
"81":"move_pf_engine",
"82":"place_engine",
"83":"move_pf_engine_back",
"181":"move_pf_trunk",
"182":"place_trunk",
"183":"move_pf_trunk_back",
"281":"move_pf_wheels",
"282":"place_wheels",
"283":"place_wheels_01",
"284":"move_pf_wheels_back",
"381":"move_pf_main_cover",
"382":"place_main_cover",
"383":"move_pf_main_cover_back",
"481":"move_pf_handle",
"482":"place_handle",
"483":"move_pf_handle_back"}
for i in range(len(self.pf_schedules)):
# for i in range(5):
if not self.check_prim_exists_extra("World/Environment/"+self.name_of_PFs[i]["prim_name"]) and not self.pf_schedules[i]:
if self.name_of_PFs[i]["name"]=="engine":
self.pf_schedules[i] = deque(["81","82","83"])
elif self.name_of_PFs[i]["name"]=="trunk":
self.pf_schedules[i] = deque(["181","182","183"])
elif self.name_of_PFs[i]["name"]=="wheels":
self.pf_schedules[i] = deque(["281","282","283","284"])
elif self.name_of_PFs[i]["name"]=="main_cover":
self.pf_schedules[i] = deque(["381","382","383"])
elif self.name_of_PFs[i]["name"]=="handle":
self.pf_schedules[i] = deque(["481","482","483"])
print("PF "+self.name_of_PFs[i]["name"]+": ", self.pf_schedules[i])
if self.pf_schedules[i]:
# print("PF "+str(i)+": ", self.pf_schedules[i])
curr_schedule = self.pf_schedules[i][0]
curr_schedule_function = getattr(self.PF_executions[i], pf_to_function[curr_schedule])
function_done = curr_schedule_function()
if function_done:
print("Done with", pf_to_function[curr_schedule])
self.pf_schedules[i].popleft()
# for i in range(1,self.num_of_ATVs):
# if self.schedules[i-1] and self.schedules[i]:
# # print("Task "+str(i), int(self.schedules[i-1][0])//100, int(self.schedules[i][0])//100)
# if int(self.schedules[i-1][0])//100 > int(self.schedules[i][0])//100:
# self.ATV_executions[i].spawn_new_parts()
# else:
# # print("Task "+str(i), "F", int(self.schedules[i][0])//100)
# self.ATV_executions[i].spawn_new_parts()
return
def add_part_custom(self, parent_prim_name, part_name, prim_name, scale, position, orientation):
base_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/atvsstlfiles/"
add_reference_to_stage(usd_path=base_asset_path+f"{part_name}/{part_name}.usd", prim_path=f"/{parent_prim_name}/{prim_name}") # gives asset ref path
part= self._world.scene.add(XFormPrim(prim_path=f'/{parent_prim_name}/{prim_name}', name=f"q{prim_name}")) # declares in the world
## add part
part.set_local_scale(scale)
part.set_local_pose(translation=position, orientation=orientation)
return part
def wait(self):
print("Waiting ...")
if self.delay>100:
print("Done waiting")
self.delay=0
return True
self.delay+=1
return False
def check_prim_exists_extra(self, prim_path):
for i in range(self.num_of_ATVs+3):
curr_prim = self._world.stage.GetPrimAtPath("/"+prim_path+f"_{i}")
if curr_prim.IsValid():
return True
return False
def check_prim_exists(self, prim_path):
curr_prim = self._world.stage.GetPrimAtPath("/"+prim_path)
if curr_prim.IsValid():
return True
return False
def wait_for_parts(self, id):
curr_pf = self.wait_queue[id][0]
name = self.name_of_PFs[curr_pf]['name']
prim_name = self.name_of_PFs[curr_pf]['prim_name']
print(id)
print(curr_pf,name,prim_name)
isWait = False
if name=='main_cover':
isWait |= not self.check_prim_exists(f"World/Environment/{prim_name}_{id}") and not self.ATV_executions[id].visited["cover"] and self.ATV_executions[id-1].visited["cover"]
if name!='trunk':
isWait |= not self.check_prim_exists(f"World/Environment/{prim_name}_{id}") and not self.ATV_executions[id].visited[f"{name}"] and self.ATV_executions[id-1].visited[f"{name}"]
# elif name=='wheels':
# isWait |= not self.check_prim_exists(f"World/Environment/{prim_name}_{id}") and not self.ATV_executions[id].visited[f"{name}"] and self.ATV_executions[id-1].visited[f"{name}"] and self.check_prim_exists(f"World/Environment/{prim_name}_{id-1}")
if self.check_prim_exists(f"World/Environment/{prim_name}_{id}"):
if name =='trunk' and self.check_prim_exists(f"mock_robot_{id}/platform/xtrunk_{id}"):
self.wait_queue[id].popleft()
else:
self.wait_queue[id].popleft()
# isWait |= not self.check_prim_exists(f"World/Environment/trunk_02_{id}") and not self.ATV_executions[id].visited["trunk"] and self.ATV_executions[id-1].visited["trunk"]
print(isWait)
# isWait |= not self.check_prim_exists(f"World/Environment/wheel_02_{id}") and not self.ATV_executions[id].visited["wheels"] and self.ATV_executions[id-1].visited["wheels"]
# isWait |= not self.check_prim_exists(f"World/Environment/main_cover_{id}") and not self.ATV_executions[id].visited["cover"] and self.ATV_executions[id-1].visited["cover"]
# isWait |= not self.check_prim_exists(f"World/Environment/handle_{id}") and not self.ATV_executions[id].visited["handle"] and self.ATV_executions[id-1].visited["handle"]
return isWait | 112,601 | Python | 88.22504 | 357 | 0.577242 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/assembly_task.py | from omni.isaac.core.prims import GeometryPrim, XFormPrim
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.universal_robots.controllers.pick_place_controller import PickPlaceController
from omni.isaac.wheeled_robots.robots import WheeledRobot
from omni.isaac.core.utils.types import ArticulationAction
# This extension includes several generic controllers that could be used with multiple robots
from omni.isaac.motion_generation import WheelBasePoseController
# Robot specific controller
from omni.isaac.wheeled_robots.controllers.differential_controller import DifferentialController
from omni.isaac.core.controllers import BaseController
from omni.isaac.core.tasks import BaseTask
from omni.isaac.manipulators import SingleManipulator
from omni.isaac.manipulators.grippers import SurfaceGripper
import numpy as np
from omni.isaac.core.objects import VisualCuboid, DynamicCuboid
from omni.isaac.core.utils import prims
from pxr import UsdLux, Sdf, UsdGeom
import omni.usd
from omni.isaac.dynamic_control import _dynamic_control
from omni.isaac.universal_robots import KinematicsSolver
import carb
from collections import deque, defaultdict
import time
class AssemblyTask(BaseTask):
def __init__(self, name):
super().__init__(name=name, offset=None)
# self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]), np.array([-5.40137, -4.88, 0.03551]), np.array([-5.40137, -17.69, 0.03551]), np.array([-20.45, -17.69, 0.03551]), np.array([-36.03, -17.69, 0.03551]), np.array([-36.03, -4.71, 0.03551]), np.array([-20.84, -4.71, 0.03551]), np.array([-20.84, 7.36, 0.03551]), np.array([-36.06, 7.36, 0.03551]), np.array([-36.06, 19.64, 0.03551]), np.array([-5.40137, 19.64, 0.03551])]
# self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]), np.array([-5.40137, -4.88, 0.03551]), np.array([-5.40137, -17.69, 0.03551]), np.array([-20.45, -17.69, 0.03551]), np.array([-36.03, -17.69, 0.03551]), np.array([-36.03, -4.71, 0.03551]), np.array([-20.84, -4.71, 0.03551]), np.array([-20.84, 7.36, 0.03551]), np.array([-36.06, 7.36, 0.03551]), np.array([-36.06, 19.64, 0.03551]), np.array([-5.40137, 19.64, 0.03551])]
self.mp_goal_position = [np.array([-5.40137, 5.54515, 0.03551]),
np.array([-5.40137, -2.628, 0.03551]),
np.array([-5.40137, -15.69, 0.03551]),
np.array([-20.45, -17.69, 0.03551]),
np.array([-36.03, -17.69, 0.03551]),
np.array([-36.03, -4.71, 0.03551]),
np.array([-20.84, -4.71, 0.03551]),
np.array([-20.84, 7.36, 0.03551]),
np.array([-36.06, 7.36, 0.03551]),
np.array([-36.06, 19.64, 0.03551]),
np.array([-5.40137, 19.64, 0.03551])]
self.eb_goal_position = np.array([-4.39666, 7.64828, 0.035])
self.ur10_goal_position = np.array([])
# self.mp_goal_orientation = np.array([1, 0, 0, 0])
self._task_event = 0
self.task_done = [False]*1000
self.motion_event = 0
self.motion_done = [False]*1000
self._bool_event = 0
self.count=0
# self.num_of_ATVs = 2
return
def set_up_scene(self, scene):
super().set_up_scene(scene)
assets_root_path = get_assets_root_path() # http://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/Isaac/2022.2.1
asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/photos/real_microfactory_show_without_robots_l.usd"
robot_arm_path = assets_root_path + "/Isaac/Robots/UR10/ur10.usd"
# adding UR10 for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/version3_j_hook/version3_j_hook.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10/ee_link", translate=0.1611, direction="x")
self.ur10 = scene.add(
SingleManipulator(prim_path="/World/UR10", name="my_ur10", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-4.98573, 6.97238, 0.24168]), orientation=np.array([0.70711, 0, 0, 0.70711]), scale=np.array([1,1,1]))
)
self.ur10.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10 for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10/ee_link", translate=0, direction="x")
self.screw_ur10 = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10", name="my_screw_ur10", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-4.73889, 4.66511, 0.24168]), orientation=np.array([0.70711, 0, 0, 0.70711]), scale=np.array([1,1,1]))
)
self.screw_ur10.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# Floorplan = 0, -4.26389, 0
# Station_ = 1.50338, -4.95641, 0
# large_robot_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/Collected_full_warehouse_microfactory/Collected_mobile_platform/mobile_platform1.usd"
# small_robot_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/Collected_full_warehouse_microfactory/Collected_mobile_platform/mobile_platform1.usd"
large_robot_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform_unfinished/mobile_platform_flattened.usd"
small_robot_asset_path= "/home/lm-2023/Isaac_Sim/isaac sim samples/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform_unfinished/mobile_platform_flattened.usd"
# large_robot_asset_path = "/home/lm-2023/Isaac_Sim/navigation/Collected_real_microfactory_show/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform/mobile_platform_ag.usd"
# add floor
add_reference_to_stage(usd_path=asset_path, prim_path="/World/Environment")
# # add moving platform
# self.moving_platform = scene.add(
# WheeledRobot(
# prim_path=f"/mock_robot",
# name=f"moving_platform",
# wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
# create_robot=True,
# usd_path=large_robot_asset_path,
# # position=np.array([2.5, 5.65, 0.03551]), orientation=np.array([0,0,0,1]), # start position
# position=np.array([-0.378, 5.65, 0.03551]), orientation=np.array([0,0,0,1]), # start position
# # position=np.array([-4.78521, -10.1757,0.03551]), orientation=np.array([0.70711, 0, 0, -0.70711]),# initial before fuel cell
# # position=np.array([-9.60803, -17.35671, 0.03551]), orientation=np.array([0, 0, 0, 1]),# initial before battery cell
# # position=np.array([-32.5, 3.516, 0.03551]), orientation=np.array([0.70711, 0, 0, 0.70711]),# initial before trunk cell
# # position=np.array([-19.86208, 9.65617, 0.03551]), orientation=np.array([1, 0, 0, 0]),# initial before wheel cell
# # position=np.array([-20.84299, 6.46358, 0.03551]), orientation=np.array([-0.70711, 0, 0, -0.70711]),# initial before wheel cell
# # position=np.array([-21.13755, -15.54504, 0.03551]), orientation=np.array([0.70711, 0, 0, -0.70711]),# initial before cover cell
# # position=np.array([-27.52625, -7.11835, 0.03551]), orientation=np.array([0.70711, 0, 0, -0.70711]),# initial before light cell
# )
# )
# # Second view from contingency
# self.moving_platform = scene.add(
# WheeledRobot(
# prim_path="/mock_robot",
# name="moving_platform",
# wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
# create_robot=True,
# usd_path=large_robot_asset_path,
# position=np.array([-3.28741, 10.79225, 0.03551]),
# orientation=np.array([0.5, 0.5,-0.5, -0.5]),
# )
# )
self.engine_bringer = scene.add(
WheeledRobot(
prim_path="/engine_bringer",
name="engine_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
# position=np.array([-6.919, 7.764, 0.03551]), orientation=np.array([0.70711,0, 0,-0.70711]),
position=np.array([-9.76, 10.697, 0.03551]), orientation=np.array([0, 0,0 ,-1]),
)
)
# Suspension task assembly ---------------------------------------------
# adding UR10_suspension for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_suspension")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_suspension/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_suspension/ee_link", translate=0.1611, direction="x")
self.ur10_suspension = scene.add(
SingleManipulator(prim_path="/World/UR10_suspension", name="my_ur10_suspension", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-6.10078, -5.19303, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_suspension.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_suspension for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_suspension")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_suspension/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_suspension/ee_link", translate=0, direction="x")
self.screw_ur10_suspension = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_suspension", name="my_screw_ur10_suspension", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-3.78767, -5.00871, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_suspension.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
self.suspension_bringer = scene.add(
WheeledRobot(
prim_path="/suspension_bringer",
name="suspension_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-0.927, -1.334, 0.035]), orientation=np.array([0, 0, 0, -1]), # initial position
# position=np.array([3.19, -6.04631, 0.035]), orientation=np.array([0, 0, 0, -1]), # for part feeding
)
)
# Fuel task assembly --------------------------------------------------
# adding UR10_fuel for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_fuel")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_fuel/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_fuel/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_fuel/ee_link", translate=0.1611, direction="x")
self.ur10_fuel = scene.add(
SingleManipulator(prim_path="/World/UR10_fuel", name="my_ur10_fuel", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-6.09744, -16.16324, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_fuel.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_fuel for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_fuel")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_fuel/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_fuel/ee_link", translate=0, direction="x")
self.screw_ur10_fuel = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_fuel", name="my_screw_ur10_fuel", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-4.24592, -15.9399, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_fuel.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
self.fuel_bringer = scene.add(
WheeledRobot(
prim_path="/fuel_bringer",
name="fuel_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-0.8, -12.874, 0.035]), orientation=np.array([0, 0, 0, 1]), # initial position
# position=np.array([3.19, -17.511, 0.035]), orientation=np.array([0, 0, 0, 1]), # for part feeding
)
)
# battery task assembly --------------------------------------------------
# adding UR10_battery for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_battery")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_battery/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_battery/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_battery/ee_link", translate=0.1611, direction="x")
self.ur10_battery = scene.add(
SingleManipulator(prim_path="/World/UR10_battery", name="my_ur10_battery", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-16.55392, -16.32998, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_battery.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_battery for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_battery")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_battery/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_battery/ee_link", translate=0, direction="x")
self.screw_ur10_battery = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_battery", name="my_screw_ur10_battery", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-16.35174, -18.16947, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_battery.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
self.battery_bringer = scene.add(
WheeledRobot(
prim_path="/battery_bringer",
name="battery_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-18.36667, -15.53466, 0.035]), orientation=np.array([0.70711,0, 0,-0.70711]),
# position=np.array([-17.409, -25.38847, 0.035]), orientation=np.array([0.70711,0, 0,-0.70711]),
)
)
# trunk task assembly --------------------------------------------------
# adding UR10_trunk for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_trunk")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_trunk/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_trunk/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_trunk/ee_link", translate=0.1611, direction="x")
self.ur10_trunk = scene.add(
SingleManipulator(prim_path="/World/UR10_trunk", name="my_ur10_trunk", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-27.1031, 4.48605, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_trunk.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_trunk for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_trunk")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_trunk/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_trunk/ee_link", translate=0, direction="x")
self.screw_ur10_trunk = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_trunk", name="my_screw_ur10_trunk", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-27.29981, 6.46287+0.08474, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_trunk.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
self.trunk_bringer = scene.add(
WheeledRobot(
prim_path="/trunk_bringer",
name="trunk_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-30.518, 3.516, 0.035]),
orientation=np.array([1,0,0,0]),
)
)
# wheel task assembly --------------------------------------------------
# adding UR10_wheel for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_wheel")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_wheel/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_wheel/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_wheel/ee_link", translate=0, direction="x")
self.ur10_wheel = scene.add(
SingleManipulator(prim_path="/World/UR10_wheel", name="my_ur10_wheel", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-15.8658, 4.89369, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_wheel.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_wheel for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_wheel")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_wheel/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_wheel/ee_link", translate=0, direction="x")
self.screw_ur10_wheel = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_wheel", name="my_screw_ur10_wheel", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-15.86269, 6.30393, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_wheel.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_wheel_01 for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_wheel_01")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_wheel_01/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_wheel_01/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_wheel_01/ee_link", translate=0, direction="x")
self.ur10_wheel_01 = scene.add(
SingleManipulator(prim_path="/World/UR10_wheel_01", name="my_ur10_wheel_01", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-17.92841, 4.88203, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_wheel_01.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_wheel_01 for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_wheel_01")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_wheel_01/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_wheel_01/ee_link", translate=0, direction="x")
self.screw_ur10_wheel_01 = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_wheel_01", name="my_screw_ur10_wheel_01", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-17.93068, 6.29611, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_wheel_01.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
self.wheel_bringer = scene.add(
WheeledRobot(
prim_path="/wheel_bringer",
name="wheel_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-19.211, 3.516, 0.035]),
orientation=np.array([1,0,0,0]),
)
)
# main and lower cover task assembly --------------------------------------------------
# adding UR10_main_cover for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_main_cover")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/Cover_Gripper/Cover_Gripper.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_main_cover/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_main_cover/ee_link", translate=0.1611, direction="x")
self.ur10_main_cover = scene.add(
SingleManipulator(prim_path="/World/UR10_main_cover", name="my_ur10_main_cover", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-17.73638-11.83808,-17.06779, 0.81965]), orientation=np.array([0.70711, 0, 0, -0.70711]), scale=np.array([1,1,1]))
)
self.ur10_main_cover.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_lower_cover for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_lower_cover")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_lower_cover/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_lower_cover/ee_link", translate=0, direction="x")
self.ur10_lower_cover = scene.add(
SingleManipulator(prim_path="/World/UR10_lower_cover", name="my_ur10_lower_cover", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-26.05908, -16.25914, 0.24133]), orientation=np.array([1,0,0,0]), scale=np.array([1,1,1]))
)
self.ur10_lower_cover.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_lower_cover_01 for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_lower_cover_01")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_lower_cover_01/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_lower_cover_01/ee_link", translate=0, direction="x")
self.ur10_lower_cover_01 = scene.add(
SingleManipulator(prim_path="/World/UR10_lower_cover_01", name="my_ur10_lower_cover_01", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-26.05908, -18.31912, 0.24133]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_lower_cover_01.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_lower_cover for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_lower_cover")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_lower_cover/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_lower_cover/ee_link", translate=0, direction="x")
self.screw_ur10_lower_cover = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_lower_cover", name="my_screw_ur10_lower_cover", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-27.48836, -16.25905, 0.24133]), orientation=np.array([1,0,0,0]), scale=np.array([1,1,1]))
)
self.screw_ur10_lower_cover.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_lower_cover_01 for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_lower_cover_01")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_lower_cover_01/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_lower_cover_01/ee_link", translate=0, direction="x")
self.screw_ur10_lower_cover_01 = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_lower_cover_01", name="my_screw_ur10_lower_cover_01", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-27.47893, -18.31682, 0.24133]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.screw_ur10_lower_cover_01.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# handle task assembly --------------------------------------------------
# adding UR10_handle for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_handle")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_handle/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_handle/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_handle/ee_link", translate=0, direction="x")
self.ur10_handle = scene.add(
SingleManipulator(prim_path="/World/UR10_handle", name="my_ur10_handle", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-28.50252, -7.19638, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_handle.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_handle for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_handle")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_handle/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_handle/ee_link", translate=0, direction="x")
self.screw_ur10_handle = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_handle", name="my_screw_ur10_handle", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-26.69603, -6.99305, 0.24168]), orientation=np.array([0, 0, 0, 1]), scale=np.array([1,1,1]))
)
self.screw_ur10_handle.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
self.handle_bringer = scene.add(
WheeledRobot(
prim_path="/handle_bringer",
name="handle_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-30.61162, -6.93058, 0.035]),
orientation=np.array([0.70711, 0, 0, -0.70711]),
)
)
# light task assembly --------------------------------------------------
# adding UR10_light for pick and place
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_light")
# gripper_usd = assets_root_path + "/Isaac/Robots/UR10_light/Props/short_gripper.usd"
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/RG2_v2/RG2_v2.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/UR10_light/ee_link")
gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_light/ee_link", translate=0, direction="x")
self.ur10_light = scene.add(
SingleManipulator(prim_path="/World/UR10_light", name="my_ur10_light", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-17.83209, -6.55292, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.ur10_light.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
# adding UR10_light for screwing in part
add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_light")
gripper_usd = "/home/lm-2023/Isaac_Sim/isaac sim samples/real_microfactory/Materials/robot_tools/screw_driver_link/screw_driver_link.usd"
add_reference_to_stage(usd_path=gripper_usd, prim_path="/World/Screw_driving_UR10_light/ee_link")
screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_light/ee_link", translate=0, direction="x")
self.screw_ur10_light = scene.add(
SingleManipulator(prim_path="/World/Screw_driving_UR10_light", name="my_screw_ur10_light", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-18.03193, -5.1195, 0.24168]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1]))
)
self.screw_ur10_light.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0]))
self.light_bringer = scene.add(
WheeledRobot(
prim_path="/light_bringer",
name="light_bringer",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=small_robot_asset_path,
position=np.array([-18.20414, -2.99376, 0.035]),
orientation=np.array([1,0,0,0]),
)
)
return
def get_observations(self):
# current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
current_eb_position, current_eb_orientation = self.engine_bringer.get_world_pose()
current_joint_positions_ur10 = self.ur10.get_joint_positions()
current_eb_position_suspension, current_eb_orientation_suspension = self.suspension_bringer.get_world_pose()
current_joint_positions_ur10_suspension = self.ur10_suspension.get_joint_positions()
current_eb_position_fuel, current_eb_orientation_fuel = self.fuel_bringer.get_world_pose()
current_joint_positions_ur10_fuel = self.ur10_fuel.get_joint_positions()
current_eb_position_battery, current_eb_orientation_battery = self.battery_bringer.get_world_pose()
current_joint_positions_ur10_battery = self.ur10_battery.get_joint_positions()
current_eb_position_trunk, current_eb_orientation_trunk = self.trunk_bringer.get_world_pose()
current_joint_positions_ur10_trunk = self.ur10_trunk.get_joint_positions()
current_eb_position_wheel, current_eb_orientation_wheel = self.wheel_bringer.get_world_pose()
current_joint_positions_ur10_wheel = self.ur10_wheel.get_joint_positions()
current_joint_positions_ur10_wheel_01 = self.ur10_wheel_01.get_joint_positions()
# current_eb_position_lower_cover, current_eb_orientation_lower_cover = self.lower_cover_bringer.get_world_pose()
current_joint_positions_ur10_lower_cover = self.ur10_lower_cover.get_joint_positions()
current_joint_positions_ur10_main_cover = self.ur10_main_cover.get_joint_positions()
current_joint_positions_ur10_lower_cover_01 = self.ur10_lower_cover_01.get_joint_positions()
current_eb_position_handle, current_eb_orientation_handle = self.handle_bringer.get_world_pose()
current_joint_positions_ur10_handle = self.ur10_handle.get_joint_positions()
current_eb_position_light, current_eb_orientation_light = self.light_bringer.get_world_pose()
current_joint_positions_ur10_light = self.ur10_light.get_joint_positions()
observations= {
"task_event": self._task_event,
# self.moving_platform.name: {
# "position": current_mp_position,
# "orientation": current_mp_orientation,
# "goal_position": self.mp_goal_position
# },
self.engine_bringer.name: {
"position": current_eb_position,
"orientation": current_eb_orientation,
"goal_position": self.eb_goal_position
},
self.ur10.name: {
"joint_positions": current_joint_positions_ur10,
},
self.screw_ur10.name: {
"joint_positions": current_joint_positions_ur10,
},
"bool_counter": self._bool_event,
self.suspension_bringer.name: {
"position": current_eb_position_suspension,
"orientation": current_eb_orientation_suspension,
"goal_position": self.eb_goal_position
},
self.ur10_suspension.name: {
"joint_positions": current_joint_positions_ur10_suspension,
},
self.screw_ur10_suspension.name: {
"joint_positions": current_joint_positions_ur10_suspension,
},
self.ur10_fuel.name: {
"joint_positions": current_joint_positions_ur10_fuel,
},
self.screw_ur10_fuel.name: {
"joint_positions": current_joint_positions_ur10_fuel,
},
self.ur10_battery.name: {
"joint_positions": current_joint_positions_ur10_battery,
},
self.screw_ur10_battery.name: {
"joint_positions": current_joint_positions_ur10_battery,
},
self.ur10_trunk.name: {
"joint_positions": current_joint_positions_ur10_trunk,
},
self.screw_ur10_trunk.name: {
"joint_positions": current_joint_positions_ur10_trunk,
},
self.ur10_wheel.name: {
"joint_positions": current_joint_positions_ur10_wheel,
},
self.screw_ur10_wheel.name: {
"joint_positions": current_joint_positions_ur10_wheel,
},
self.ur10_wheel_01.name: {
"joint_positions": current_joint_positions_ur10_wheel_01,
},
self.screw_ur10_wheel_01.name: {
"joint_positions": current_joint_positions_ur10_wheel_01,
},
self.ur10_lower_cover.name: {
"joint_positions": current_joint_positions_ur10_lower_cover,
},
self.screw_ur10_lower_cover.name: {
"joint_positions": current_joint_positions_ur10_lower_cover,
},
self.ur10_lower_cover_01.name: {
"joint_positions": current_joint_positions_ur10_lower_cover_01,
},
self.screw_ur10_lower_cover_01.name: {
"joint_positions": current_joint_positions_ur10_lower_cover_01,
},
self.ur10_main_cover.name: {
"joint_positions": current_joint_positions_ur10_main_cover,
},
self.ur10_handle.name: {
"joint_positions": current_joint_positions_ur10_handle,
},
self.screw_ur10_handle.name: {
"joint_positions": current_joint_positions_ur10_handle,
},
self.ur10_light.name: {
"joint_positions": current_joint_positions_ur10_light,
},
self.screw_ur10_light.name: {
"joint_positions": current_joint_positions_ur10_light,
}
}
return observations
def get_params(self):
params_representation = {}
params_representation["arm_name"] = {"value": self.ur10.name, "modifiable": False}
params_representation["screw_arm"] = {"value": self.screw_ur10.name, "modifiable": False}
# params_representation["mp_name"] = {"value": self.moving_platform.name, "modifiable": False}
params_representation["eb_name"] = {"value": self.engine_bringer.name, "modifiable": False}
# suspension task
params_representation["arm_name_suspension"] = {"value": self.ur10_suspension.name, "modifiable": False}
params_representation["screw_arm_suspension"] = {"value": self.screw_ur10_suspension.name, "modifiable": False}
params_representation["eb_name_suspension"] = {"value": self.suspension_bringer.name, "modifiable": False}
# fuel task
params_representation["arm_name_fuel"] = {"value": self.ur10_fuel.name, "modifiable": False}
params_representation["screw_arm_fuel"] = {"value": self.screw_ur10_fuel.name, "modifiable": False}
params_representation["eb_name_fuel"] = {"value": self.fuel_bringer.name, "modifiable": False}
# battery task
params_representation["arm_name_battery"] = {"value": self.ur10_battery.name, "modifiable": False}
params_representation["screw_arm_battery"] = {"value": self.screw_ur10_battery.name, "modifiable": False}
params_representation["eb_name_battery"] = {"value": self.battery_bringer.name, "modifiable": False}
# trunk task
params_representation["arm_name_trunk"] = {"value": self.ur10_trunk.name, "modifiable": False}
params_representation["screw_arm_trunk"] = {"value": self.screw_ur10_trunk.name, "modifiable": False}
params_representation["eb_name_trunk"] = {"value": self.trunk_bringer.name, "modifiable": False}
# wheel task
params_representation["arm_name_wheel"] = {"value": self.ur10_wheel.name, "modifiable": False}
params_representation["screw_arm_wheel"] = {"value": self.screw_ur10_wheel.name, "modifiable": False}
params_representation["arm_name_wheel_01"] = {"value": self.ur10_wheel_01.name, "modifiable": False}
params_representation["screw_arm_wheel_01"] = {"value": self.screw_ur10_wheel_01.name, "modifiable": False}
params_representation["eb_name_wheel"] = {"value": self.wheel_bringer.name, "modifiable": False}
# lower_cover task
params_representation["arm_name_main_cover"] = {"value": self.ur10_main_cover.name, "modifiable": False}
params_representation["arm_name_lower_cover"] = {"value": self.ur10_lower_cover.name, "modifiable": False}
params_representation["screw_arm_lower_cover"] = {"value": self.screw_ur10_lower_cover.name, "modifiable": False}
params_representation["arm_name_lower_cover_01"] = {"value": self.ur10_lower_cover_01.name, "modifiable": False}
params_representation["screw_arm_lower_cover_01"] = {"value": self.screw_ur10_lower_cover_01.name, "modifiable": False}
# params_representation["eb_name_lower_cover"] = {"value": self.lower_cover_bringer.name, "modifiable": False}
# handle task
params_representation["arm_name_handle"] = {"value": self.ur10_handle.name, "modifiable": False}
params_representation["screw_arm_handle"] = {"value": self.screw_ur10_handle.name, "modifiable": False}
params_representation["eb_name_handle"] = {"value": self.handle_bringer.name, "modifiable": False}
# front light task
params_representation["arm_name_light"] = {"value": self.ur10_light.name, "modifiable": False}
params_representation["screw_arm_light"] = {"value": self.screw_ur10_light.name, "modifiable": False}
params_representation["eb_name_light"] = {"value": self.light_bringer.name, "modifiable": False}
return params_representation
def check_prim_exists(self, prim):
if prim:
return True
return False
def give_location(self, prim_path):
dc=_dynamic_control.acquire_dynamic_control_interface()
object=dc.get_rigid_body(prim_path)
object_pose=dc.get_rigid_body_pose(object)
return object_pose # position: object_pose.p, rotation: object_pose.r
def pre_step(self, control_index, simulation_time):
# current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
return
def post_reset(self):
self._task_event = 0
return | 45,638 | Python | 67.941088 | 441 | 0.63079 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/hello_world_extension.py | # Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
import os
from omni.isaac.examples.base_sample import BaseSampleExtension
from omni.isaac.examples.hello_world import HelloWorld
class HelloWorldExtension(BaseSampleExtension):
def on_startup(self, ext_id: str):
super().on_startup(ext_id)
super().start_extension(
menu_name="",
submenu_name="",
name="cell 1 engine",
title="Hello World Example",
doc_link="https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_core_hello_world.html",
overview="This Example introduces the user on how to do cool stuff with Isaac Sim through scripting in asynchronous mode.",
file_path=os.path.abspath(__file__),
sample=HelloWorld(),
)
return
| 1,206 | Python | 42.107141 | 135 | 0.705638 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/ATV_task.py | from omni.isaac.core.prims import GeometryPrim, XFormPrim
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.utils.nucleus import get_assets_root_path
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.universal_robots.controllers.pick_place_controller import PickPlaceController
from omni.isaac.wheeled_robots.robots import WheeledRobot
from omni.isaac.core.utils.types import ArticulationAction
# This extension includes several generic controllers that could be used with multiple robots
from omni.isaac.motion_generation import WheelBasePoseController
# Robot specific controller
from omni.isaac.wheeled_robots.controllers.differential_controller import DifferentialController
from omni.isaac.core.controllers import BaseController
from omni.isaac.core.tasks import BaseTask
from omni.isaac.manipulators import SingleManipulator
from omni.isaac.manipulators.grippers import SurfaceGripper
import numpy as np
from omni.isaac.core.objects import VisualCuboid, DynamicCuboid
from omni.isaac.core.utils import prims
from pxr import UsdLux, Sdf, UsdGeom
import omni.usd
from omni.isaac.dynamic_control import _dynamic_control
from omni.isaac.universal_robots import KinematicsSolver
import carb
from collections import deque, defaultdict
import time
class ATVTask(BaseTask):
def __init__(self, name, offset=None, mp_name=None, mp_pos=None, mp_ori=None):
super().__init__(name=name, offset=offset)
self.mp_name = mp_name
self.mp_pos = mp_pos
self.mp_ori = mp_ori
self._task_event = 0
self.task_done = [False]*1000
self._bool_event = 0
self.delay=0
return
def set_up_scene(self, scene):
super().set_up_scene(scene)
large_robot_asset_path = "/home/lm-2023/Isaac_Sim/isaac sim samples/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform_unfinished/mobile_platform_flattened.usd"
# large_robot_asset_path = "/home/lm-2023/Isaac_Sim/navigation/Collected_real_microfactory_show/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform/mobile_platform_ag.usd"
# large_robot_asset_path = "/home/lm-2023/Isaac_Sim/navigation/Collected_real_microfactory_multiple_mp/Collected_real_microfactory_show/Collected_full_warehouse_microfactory/Collected_mobile_platform_improved/Collected_mobile_platform/mobile_platform_ag.usd"
# add floor
# add moving platform
if not self.mp_name:
_,num = self.name.split("_")
self.moving_platform = scene.add(
WheeledRobot(
prim_path=f"/mock_robot_{num}",
name=f"moving_platform_{num}",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=large_robot_asset_path,
# position=np.array([2.5, 5.65, 0.03551]), orientation=np.array([0,0,0,1]), # start position
position=np.array([1.622+int(num)*2, 5.65, 0.03551]), orientation=np.array([0,0,0,1]), # start position
# position=np.array([-4.78521, -10.1757+int(num)*2,0.03551]), orientation=np.array([0.70711, 0, 0, -0.70711]),# initial before fuel cell
# position=np.array([-9.60803, -17.35671+int(num)*2, 0.03551]), orientation=np.array([0, 0, 0, 1]),# initial before battery cell
# position=np.array([-32.5-int(num)*2, 3.516, 0.03551]), orientation=np.array([0.70711, 0, 0, 0.70711]),# initial before trunk cell
# position=np.array([-19.86208-int(num)*2, 9.65617, 0.03551]), orientation=np.array([1, 0, 0, 0]),# initial before wheel cell
# position=np.array([-20.84299, 6.46358, 0.03551]), orientation=np.array([-0.70711, 0, 0, -0.70711]),# initial before wheel cell
# position=np.array([-21.13755, -15.54504+int(num)*2, 0.03551]), orientation=np.array([0.70711, 0, 0, -0.70711]),# initial before cover cell
# position=np.array([-27.52625-int(num)*2, -7.11835, 0.03551]), orientation=np.array([0.70711, 0, 0, -0.70711]),# initial before light cell
)
)
else:
pf_name,num = self.mp_name.rsplit("_", 1)
self.moving_platform = scene.add(
WheeledRobot(
prim_path=f"/{pf_name}",
name=f"part_feeder_{num}",
wheel_dof_names=["wheel_tl_joint", "wheel_tr_joint", "wheel_bl_joint", "wheel_br_joint"],
create_robot=True,
usd_path=large_robot_asset_path,
position=self.mp_pos, orientation=self.mp_ori, # start position
)
)
return
def get_observations(self):
current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
observations= {
self.name+"_event": self._task_event,
self.moving_platform.name: {
"position": current_mp_position,
"orientation": current_mp_orientation
}
}
return observations
def get_params(self):
params_representation = {}
params_representation["mp_name"] = {"value": self.moving_platform.name, "modifiable": False}
return params_representation
def give_location(self, prim_path):
dc=_dynamic_control.acquire_dynamic_control_interface()
object=dc.get_rigid_body(prim_path)
object_pose=dc.get_rigid_body_pose(object)
return object_pose # position: object_pose.p, rotation: object_pose.r
def pre_step(self, control_index, simulation_time):
return
def post_reset(self):
self._task_event = 0
return | 5,932 | Python | 49.279661 | 266 | 0.645819 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/pf_functions.py | import numpy as np
from omni.isaac.examples.hello_world.util import Utils
import asyncio
import rospy
from geometry_msgs.msg import PoseStamped
import rosgraph
from tf.transformations import euler_from_quaternion, quaternion_from_euler
from math import pi
class PartFeederFunctions:
def __init__(self) -> None:
self.util = Utils()
self.isDone = [False]*1000
self.bool_done = [False]*1000
self.delay=0
self.right_side = self.left_side = False
self.world = None
self.id = None
# visited array
# meaning of its values:
# False - not visited
# True - visiting or visited
self.visited = {"engine":False, "trunk":False, "wheels":False, "cover":False, "handle":False}
# Engine cell set up ----------------------------------------------------------------------------
# bring in moving platforms
self.moving_platform = None
self.my_controller = None
self.screw_my_controller = None
self.articulation_controller = None
self.screw_articulation_controller = None
# Suspension cell set up ------------------------------------------------------------------------
self.my_controller_suspension = None
self.screw_my_controller_suspension = None
self.articulation_controller_suspension = None
self.screw_articulation_controller_suspension = None
# Fuel cell set up ---------------------------------------------------------------------------------
self.my_controller_fuel = None
self.screw_my_controller_fuel = None
self.articulation_controller_fuel = None
self.screw_articulation_controller_fuel = None
# battery cell set up ---------------------------------------------------------------------------------
self.my_controller_battery = None
self.screw_my_controller_battery = None
self.articulation_controller_battery = None
self.screw_articulation_controller_battery = None
# trunk cell set up ---------------------------------------------------------------------------------
self.my_controller_trunk = None
self.screw_my_controller_trunk = None
self.articulation_controller_trunk = None
self.screw_articulation_controller_trunk = None
# wheel cell set up ---------------------------------------------------------------------------------
self.my_controller_wheel = None
self.screw_my_controller_wheel = None
self.articulation_controller_wheel = None
self.screw_articulation_controller_wheel = None
self.my_controller_wheel_01 = None
self.screw_my_controller_wheel_01 = None
self.articulation_controller_wheel_01 = None
self.screw_articulation_controller_wheel_01 = None
# lower_cover cell set up ---------------------------------------------------------------------------------
self.my_controller_lower_cover = None
self.screw_my_controller_lower_cover = None
self.articulation_controller_lower_cover = None
self.screw_articulation_controller_lower_cover = None
self.my_controller_lower_cover_01 = None
self.screw_my_controller_lower_cover_01 = None
self.articulation_controller_lower_cover_01 = None
self.screw_articulation_controller_lower_cover_01 = None
self.my_controller_main_cover = None
self.articulation_controller_main_cover = None
# handle cell set up ---------------------------------------------------------------------------------
self.my_controller_handle = None
self.screw_my_controller_handle = None
self.articulation_controller_handle = None
self.screw_articulation_controller_handle = None
# light cell set up --------------------------------------------------------------------------------
self.my_controller_light = None
self.screw_my_controller_light = None
self.articulation_controller_light = None
self.screw_articulation_controller_light = None
# Util declarations ----------------------------------------------------------------------------------
def declare_utils(self):
self.util.world = self.world
self.util.id = self.id
# Engine cell set up ----------------------------------------------------------------------------
# bring in moving platforms
self.util.moving_platform = self.moving_platform
self.util.my_controller = self.my_controller
self.util.screw_my_controller = self.screw_my_controller
self.util.articulation_controller = self.articulation_controller
self.util.screw_articulation_controller = self.screw_articulation_controller
# Suspension cell set up ------------------------------------------------------------------------
self.util.my_controller_suspension = self.my_controller_suspension
self.util.screw_my_controller_suspension = self.screw_my_controller_suspension
self.util.articulation_controller_suspension = self.articulation_controller_suspension
self.util.screw_articulation_controller_suspension = self.screw_articulation_controller_suspension
# Fuel cell set up ---------------------------------------------------------------------------------
self.util.my_controller_fuel = self.my_controller_fuel
self.util.screw_my_controller_fuel = self.screw_my_controller_fuel
self.util.articulation_controller_fuel = self.articulation_controller_fuel
self.util.screw_articulation_controller_fuel = self.screw_articulation_controller_fuel
# battery cell set up ---------------------------------------------------------------------------------
self.util.my_controller_battery = self.my_controller_battery
self.util.screw_my_controller_battery = self.screw_my_controller_battery
self.util.articulation_controller_battery = self.articulation_controller_battery
self.util.screw_articulation_controller_battery = self.screw_articulation_controller_battery
# trunk cell set up ---------------------------------------------------------------------------------
self.util.my_controller_trunk = self.my_controller_trunk
self.util.screw_my_controller_trunk = self.screw_my_controller_trunk
self.util.articulation_controller_trunk = self.articulation_controller_trunk
self.util.screw_articulation_controller_trunk = self.screw_articulation_controller_trunk
# wheel cell set up ---------------------------------------------------------------------------------
self.util.my_controller_wheel = self.my_controller_wheel
self.util.screw_my_controller_wheel = self.screw_my_controller_wheel
self.util.articulation_controller_wheel = self.articulation_controller_wheel
self.util.screw_articulation_controller_wheel = self.screw_articulation_controller_wheel
self.util.my_controller_wheel_01 = self.my_controller_wheel_01
self.util.screw_my_controller_wheel_01 = self.screw_my_controller_wheel_01
self.util.articulation_controller_wheel_01 = self.articulation_controller_wheel_01
self.util.screw_articulation_controller_wheel_01 = self.screw_articulation_controller_wheel_01
# lower_cover cell set up ---------------------------------------------------------------------------------
self.util.my_controller_lower_cover = self.my_controller_lower_cover
self.util.screw_my_controller_lower_cover = self.screw_my_controller_lower_cover
self.util.articulation_controller_lower_cover = self.articulation_controller_lower_cover
self.util.screw_articulation_controller_lower_cover = self.screw_articulation_controller_lower_cover
self.util.my_controller_lower_cover_01 = self.my_controller_lower_cover_01
self.util.screw_my_controller_lower_cover_01 = self.screw_my_controller_lower_cover_01
self.util.articulation_controller_lower_cover_01 = self.articulation_controller_lower_cover_01
self.util.screw_articulation_controller_lower_cover_01 = self.screw_articulation_controller_lower_cover_01
self.util.my_controller_main_cover = self.my_controller_main_cover
self.util.articulation_controller_main_cover = self.articulation_controller_main_cover
# handle cell set up ---------------------------------------------------------------------------------
self.util.my_controller_handle = self.my_controller_handle
self.util.screw_my_controller_handle = self.screw_my_controller_handle
self.util.articulation_controller_handle = self.articulation_controller_handle
self.util.screw_articulation_controller_handle = self.screw_articulation_controller_handle
# light cell set up --------------------------------------------------------------------------------
self.util.my_controller_light = self.my_controller_light
self.util.screw_my_controller_light = self.screw_my_controller_light
self.util.articulation_controller_light = self.articulation_controller_light
self.util.screw_articulation_controller_light = self.screw_articulation_controller_light
# if self.id%2!=0:
# self.color_path = ["main_cover","main_cover_orange"]
# else:
# self.color_path = ["main_cover_orange","main_cover"]
def update_color(self):
if self.id%2!=0:
self.color_path = ["main_cover","main_cover_orange"]
else:
self.color_path = ["main_cover_orange","main_cover"]
def spawn_new_parts(self):
if self.id ==2:
# print(not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id}") and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/engine_{self.id-1}"))
pass
if self.id!=0:
# Engine cell set up ----------------------------------------------------------------------------
# if not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id}") and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id-1}") and not self.util.check_prim_exists(f"mock_robot_{self.id}/platform/engine_{self.id}"):
if not self.isDone[0] and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id}") and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/engine_{self.id-1}"):
self.isDone[0] = True
self.util.add_part_custom("World/Environment","engine_no_rigid", f"engine_small_{self.id}", np.array([0.001, 0.001, 0.001]), np.array([-4.86938, 8.14712, 0.59038]), np.array([0.99457, 0, -0.10411, 0]))
# print(" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n --------------------------------------spawned engine "+str(self.id)+" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
# Suspension cell set up ------------------------------------------------------------------------
# if not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id-1}") and not self.util.check_prim_exists(f"mock_robot_{self.id}/platform/xFSuspensionBack_{self.id}"):
if not self.isDone[1] and not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xFSuspensionBack_{self.id-1}"):
self.isDone[1] = True
self.util.add_part_custom("World/Environment","FSuspensionBack", f"FSuspensionBack_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.69733, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
# print(" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n --------------------------------------spawned suspension "+str(self.id)+" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
# Fuel cell set up ---------------------------------------------------------------------------------
if not self.isDone[2] and not self.util.check_prim_exists(f"World/Environment/fuel_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/fuel_01_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xfuel_{self.id-1}"):
self.isDone[2] = True
if self.id%2==0:
self.util.add_part_custom("World/Environment","fuel", f"fuel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-7.01712, -15.89918, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
else:
self.util.add_part_custom("World/Environment","fuel_yellow", f"fuel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-7.01712, -15.89918, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
# battery cell set up ---------------------------------------------------------------------------------
if not self.isDone[3] and not self.util.check_prim_exists(f"World/Environment/battery_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/battery_01_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xbattery_{self.id-1}"):
self.isDone[3] = True
self.util.add_part_custom("World/Environment","battery", f"battery_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-16.47861, -15.68368, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
# trunk cell set up ---------------------------------------------------------------------------------
if not self.isDone[4] and not self.util.check_prim_exists(f"World/Environment/trunk_02_{self.id}") and not self.util.check_prim_exists(f"World/Environment/trunk_02_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xtrunk_{self.id-1}"):
self.isDone[4] = True
self.util.add_part_custom("World/Environment","trunk", f"trunk_02_{self.id}", np.array([0.001,0.001,0.001]), np.array([-27.84904, 4.26505, 0.41467]), np.array([0, 0, -0.70711, -0.70711]))
# wheel cell set up ---------------------------------------------------------------------------------
if not self.isDone[5] and not self.util.check_prim_exists(f"World/Environment/wheel_02_{self.id}") and not self.util.check_prim_exists(f"World/Environment/wheel_02_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xwheel_02_{self.id-1}"):
self.isDone[5] = True
self.util.add_part_custom("World/Environment","FWheel", f"wheel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-15.17319, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.util.add_part_custom("World/Environment","FWheel", f"wheel_02_{self.id}", np.array([0.001,0.001,0.001]), np.array([-15.17319, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.util.add_part_custom("World/Environment","FWheel", f"wheel_03_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.97836, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.util.add_part_custom("World/Environment","FWheel", f"wheel_04_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.97836, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
# lower_cover cell set up ---------------------------------------------------------------------------------
if not self.isDone[6] and not self.util.check_prim_exists(f"World/Environment/main_cover_{self.id}") and not self.util.check_prim_exists(f"World/Environment/main_cover_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xmain_cover_{self.id-1}"):
self.isDone[6] = True
self.util.add_part_custom("World/Environment","lower_cover", f"lower_cover_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.57458, 0.40595]), np.array([0, 0, 0.70711, 0.70711]))
self.util.add_part_custom("World/Environment","lower_cover", f"lower_cover_04_{self.id}", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.13631, 0.40595]), np.array([0, 0, -0.70711, -0.70711]))
if self.id%2==0:
self.util.add_part_custom("World/Environment","main_cover", f"main_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.7095-11.83808, -15.70872, 0.28822]), np.array([0.70711, 0.70711,0,0]))
else:
self.util.add_part_custom("World/Environment","main_cover_orange", f"main_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.7095-11.83808, -15.70872, 0.28822]), np.array([0.70711, 0.70711,0,0]))
# handle cell set up ---------------------------------------------------------------------------------
if not self.isDone[7] and not self.util.check_prim_exists(f"World/Environment/handle_{self.id}") and not self.util.check_prim_exists(f"World/Environment/handle_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xhandle_{self.id-1}"):
self.isDone[7] = True
self.util.add_part_custom("World/Environment","handle", f"handle_{self.id}", np.array([0.001,0.001,0.001]), np.array([-29.70213, -7.25934, 1.08875]), np.array([0, 0.70711, 0.70711, 0]))
# light cell set up ---------------------------------------------------------------------------------
if not self.isDone[8] and not self.util.check_prim_exists(f"World/Environment/light_03_{self.id}") and not self.util.check_prim_exists(f"World/Environment/light_03_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xlight_{self.id-1}"):
self.isDone[8] = True
self.util.add_part_custom("World/Environment","FFrontLightAssembly", f"light_03_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.07685, -7.35866, -0.71703]), np.array([0.28511, -0.28511, -0.64708, -0.64708]))
# ---------------------------------------------------- part feeder functions ------------------------------------------------------------
# -----------------------------engine---------------------------------
def move_pf_engine(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-0.8, 0, False]],
["wait",[]],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, False]],
["wait",[]],
["translate", [13.65, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, True]],
["wait",[]],
["translate", [-4.947, 0, False]],
["wait",[]],
["rotate", [np.array([0.70711,0,0,-0.70711]), 0.0042, False]],
["wait",[]],
["translate", [10.042, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, False]],
["wait",[]],
["translate", [-6.28358, 0, False]],
["wait",[]],
["rotate", [np.array([0.70711,0,0,-0.70711]), 0.0042, False]],
["wait",[]],
["translate", [7.1069, 1, False]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def place_engine(self):
print("doing motion plan")
motion_plan = [{"index":0, "position": np.array([0.16871, 0.73405+0.16, 0.08489]), "orientation": np.array([0.70711, 0, 0, 0.70711]), "goal_position":np.array([-5.71975, 7.14096, 0.32698]), "goal_orientation":np.array([0,0,0,-1])},
{"index":1, "position": np.array([0.16871, 1.09027+0.16, 0.08489]), "orientation": np.array([0.70711, 0, 0, 0.70711]), "goal_position":np.array([-6.07597, 7.14096, 0.32698]), "goal_orientation":np.array([0,0,0,-1])},
{"index":2, "position": np.array([0.16871, 1.09027+0.16, 0.35359]), "orientation": np.array([0.70711, 0, 0, 0.70711]), "goal_position":np.array([-6.07597, 7.14096, 0.59568]), "goal_orientation":np.array([0,0,0,-1])},
{"index":3, "position": np.array([0.71113, 0.57884, 0.65168]), "orientation": np.array([0.94313, 0, 0, 0.33242]), "goal_position":np.array([-5.46465, 7.557, 0.89377]), "goal_orientation":np.array([0.43184, 0, 0, 0.90195])},# -5.56465, 7.68341, 0.89377
{"index":4, "position": np.array([0.97986+0.16, -0.22219, 0.54922]), "orientation": np.array([1,0,0,0]), "goal_position":np.array([-4.76367, 7.95221, 0.79131]), "goal_orientation":np.array([0.70711, 0, 0, 0.70711])},
{"index":5, "position": np.array([0.97986+0.16, -0.22219, 0.23754]), "orientation": np.array([1,0,0,0]), "goal_position":np.array([-4.76367, 7.95221, 0.47963]), "goal_orientation":np.array([0.70711, 0, 0, 0.70711])},
{"index":6, "position": np.array([0.60234+0.16, -0.22219, 0.23754]), "orientation": np.array([1,0,0,0]), "goal_position":np.array([-4.76367, 7.57469, 0.47963]), "goal_orientation":np.array([0.70711, 0, 0, 0.70711])},
{"index":7, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.67382, 7.1364, 1.04897]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.move_ur10(motion_plan)
if self.util.motion_task_counter==2 and not self.bool_done[self.id*10]:
self.bool_done[self.id*10] = True
self.util.remove_part("pf_engine/platform", f"pf_engine_{self.id}")
self.util.add_part_custom("World/UR10/ee_link","engine_no_rigid", f"pf_qengine_small_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.19536, 0.10279, 0.11708]), np.array([0.70177, -0.08674, -0.08674, -0.70177]))
if self.util.motion_task_counter==6 and not self.bool_done[self.id*10+1]:
self.bool_done[self.id*10+1] = True
self.util.remove_part("World/UR10/ee_link", f"pf_qengine_small_{self.id}")
self.util.add_part_custom(f"World/Environment","engine_no_rigid", f"engine_small_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-4.86938, 8.14712, 0.59038]), np.array([0.99457, 0, -0.10411, 0]))
if self.util.motion_task_counter==8:
self.util.motion_task_counter=0
print("Done placing engine")
return True
return False
def move_pf_engine_back(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [9.65, 1, False]],
["wait", []],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, False]],
["wait", []],
["translate", [-4.947, 0, False]],
["wait", []],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, False]],
["wait", []],
["translate", [12.8358, 1, False]],
["wait", []],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, False]],
["wait", []],
["translate", [-1.22, 0, False]],
["wait", []],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait", []],
["translate", [17.63327, 1, False]],
["wait", []],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, False]],
["wait", []],
["translate", [8.61707, 0, False]],
["wait", []]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
self.util.add_part_custom("pf_engine/platform","engine_no_rigid", "pf_engine"+f"_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([0.07038, 0.03535, 0.42908]), np.array([0, 0.12268, 0, 0.99245]))
self.id+=1
return True
return False
# -----------------------------trunk---------------------------------
def move_pf_trunk(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-27.271, 0, False]],
["wait",[]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def place_trunk(self):
motion_plan = [{"index":0, "position": np.array([0.95548, 0.21169, 0.45316+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-28.05854, 4.27434, 0.69518+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.854, -0.22549, 0.56746-0.16]), "orientation": np.array([0.26914, 0.65388, 0.26914, -0.65388]), "goal_position":np.array([-27.95709, 4.7115, 0.80948]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([0.28794, -0.72111, 0.34571+0.2-0.16]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-27.39105, 5.20712, 0.58774+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":3, "position": np.array([0.28794, -0.72111, 0.34571-0.16]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-27.39105, 5.20712, 0.58774]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":4, "position": np.array([0.28794, -0.72111, 0.34571+0.2-0.16]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-27.39105, 5.20712, 0.58774+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":5, "position": np.array([0.854, -0.22549, 0.56746-0.16]), "orientation": np.array([0.26914, 0.65388, 0.26914, -0.65388]), "goal_position":np.array([-27.95709, 4.7115, 0.80948]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":6, "position": np.array([0.95548, 0.21169, 0.45316+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-28.05854, 4.27434, 0.69518+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":7, "position": np.array([0.95548, 0.21169, 0.45316-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-28.05854, 4.27434, 0.69518]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":8, "position": np.array([0.95548, 0.21169, 0.45316+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-28.05854, 4.27434, 0.69518+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":9, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.2673, 3.79761, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.move_ur10(motion_plan, "_trunk")
if self.util.motion_task_counter==4 and not self.bool_done[self.id*10]:
self.bool_done[self.id*10] = True
self.util.remove_part("pf_trunk/platform", f"pf_trunk_{self.id}")
self.util.add_part_custom("World/UR10_trunk/ee_link","trunk", f"pf_qtrunk_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.28167, -0.21084, -0.00861]), np.array([0.70711, 0, 0, 0.70711]))
if self.util.motion_task_counter==8 and not self.bool_done[self.id*10+1]:
self.bool_done[self.id*10+1] = True
self.util.remove_part("World/UR10_trunk/ee_link", f"pf_qtrunk_{self.id}")
self.util.add_part_custom(f"World/Environment","trunk", f"trunk_02_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-27.84904, 4.26505, 0.41467]), np.array([0, 0, -0.70711, -0.70711]))
if self.util.motion_task_counter==10:
self.util.motion_task_counter=0
print("Done placing trunk")
return True
return False
def move_pf_trunk_back(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-42.76, 0, False]],
["wait", []]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
self.util.add_part_custom("pf_trunk/platform","trunk", f"pf_trunk_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([-0.1389, -0.2191, 0.28512]), np.array([0.5, 0.5, 0.5, 0.5]))
self.id+=1
return True
return False
# -----------------------------wheels---------------------------------
def move_pf_wheels(self):
# return True
print(self.util.path_plan_counter)
path_plan = [["translate", [-16.85, 0, False]],
["wait",[]],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait", []],
["translate", [5.00712, 1, False]],
["wait", []],
["rotate", [np.array([1,0,0,0]), 0.0042, False]],]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def place_wheels_1eft(self):
tire_offset = 0.1462+0.2
motion_plan = [
{"index":0, "position": np.array([0.16286, 0.68548, 0.63765-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.02865, 4.20818, 0.87901]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([0.69558, -0.10273, 0.42205+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.5615, 4.99639, 0.66395+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.69558, -0.10273, 0.42205-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.5615, 4.99639, 0.66395]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([0.69558, -0.10273, 0.42205+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.5615, 4.99639, 0.66395+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":4, "position": np.array([0.16286, 0.68548, 0.63765-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.02865, 4.20818, 0.87901]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":5, "position": np.array([-0.87307, -0.01687, 0.436-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057, 0.67736+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":6, "position": np.array([-0.87307, -0.01687, 0.436-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057, 0.67736]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":7, "position": np.array([-0.87307, -0.01687, 0.436-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057, 0.67736+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
]
self.util.move_ur10_extra(motion_plan, "_wheel")
if self.util.motion_task_counterl==3 and not self.bool_done[self.id*10]:
self.bool_done[self.id*10] = True
self.util.remove_part("pf_wheels/platform", f"pf_wheels_1_{self.id}")
self.util.add_part_custom("World/UR10_wheel/ee_link","FWheel", f"pf_qwheels_1_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counterl==7 and not self.bool_done[self.id*10+1]:
self.bool_done[self.id*10+1] = True
self.util.remove_part("World/UR10_wheel/ee_link", f"pf_qwheels_1_{self.id}")
self.util.add_part_custom(f"World/Environment","FWheel", f"wheel_01_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-15.17319, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
if self.util.motion_task_counterl==8:
self.util.motion_task_counterl=0
print("Done placing wheel")
return True
return False
def place_wheels_1eft_01(self):
tire_offset = 0.52214
motion_plan = [
{"index":0, "position": np.array([-0.87307, -0.01687-tire_offset, 0.436-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057+tire_offset, 0.67736+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":1, "position": np.array([0.69558, -0.10273, 0.30352+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.5615, 4.99639, 0.54541+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.69558, -0.10273, 0.30352-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.5615, 4.99639, 0.54541]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([0.69558, -0.10273, 0.30352+0.2-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.5615, 4.99639, 0.54541+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":4, "position": np.array([0.16286, 0.68548, 0.63765-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.02865, 4.20818, 0.87901]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":5, "position": np.array([-0.87307, -0.01687-tire_offset, 0.436-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057+tire_offset, 0.67736+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":6, "position": np.array([-0.87307, -0.01687-tire_offset, 0.436-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057+tire_offset, 0.67736]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":7, "position": np.array([-0.87307, -0.01687-tire_offset, 0.436-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057+tire_offset, 0.67736+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":8, "position": np.array([0.16286, 0.68548, 0.63765-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.02865, 4.20818, 0.87901]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
]
self.util.move_ur10_extra(motion_plan, "_wheel")
if self.util.motion_task_counterl==3 and not self.bool_done[self.id*10+2]:
self.bool_done[self.id*10+2] = True
self.util.remove_part("pf_wheels/platform", f"pf_wheels_3_{self.id}")
self.util.add_part_custom("World/UR10_wheel/ee_link","FWheel", f"pf_qwheels_2_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counterl==7 and not self.bool_done[self.id*10+3]:
self.bool_done[self.id*10+3] = True
self.util.remove_part("World/UR10_wheel/ee_link", f"pf_qwheels_2_{self.id}")
self.util.add_part_custom(f"World/Environment","FWheel", f"wheel_02_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-15.17319, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
if self.util.motion_task_counterl==9:
self.util.motion_task_counterl=0
print("Done placing wheel")
return True
return False
def place_wheels_right(self):
tire_offset = 0.1462+0.2
motion_plan = [
{"index":0, "position": np.array([0.16345, 0.69284, 0.62942-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.09182, 4.18911, 0.87105]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([-0.89369, -0.11909, 0.44644+0.2-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.03464, 5.00114, 0.68807+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":2, "position": np.array([-0.89369, -0.11909, 0.44644-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.03464, 5.00114, 0.68807]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":3, "position": np.array([-0.89369, -0.11909, 0.44644+0.2-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.03464, 5.00114, 0.68807+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([0.16345, 0.69284, 0.62942-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.09182, 4.18911, 0.87105]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":5, "position": np.array([0.86452, -0.02427, 0.4366-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.79301, 4.90626, 0.67823+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":6, "position": np.array([0.86452, -0.02427, 0.4366-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.79301, 4.90626, 0.67823+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":7, "position": np.array([0.86452, -0.02427, 0.4366-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.79301, 4.90626, 0.67823+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
]
self.util.move_ur10(motion_plan, "_wheel_01")
if self.util.motion_task_counter==3 and not self.bool_done[self.id*10+4]:
self.bool_done[self.id*10+4] = True
self.util.remove_part("pf_wheels/platform", f"pf_wheels_2_{self.id}")
self.util.add_part_custom("World/UR10_wheel_01/ee_link","FWheel", f"pf_qwheels_3_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counter==7 and not self.bool_done[self.id*10+5]:
self.bool_done[self.id*10+5] = True
self.util.remove_part("World/UR10_wheel_01/ee_link", f"pf_qwheels_3_{self.id}")
self.util.add_part_custom(f"World/Environment","FWheel", f"wheel_03_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-18.97836, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
if self.util.motion_task_counter==8:
self.util.motion_task_counter=0
print("Done placing wheel")
return True
return False
def place_wheels_right_01(self):
tire_offset = 0.1462+0.2
motion_plan = [
{"index":0, "position": np.array([0.16345, 0.69284, 0.62942-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.09182, 4.18911, 0.87105]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":1, "position": np.array([-0.89369, -0.11909, 0.30402+0.2-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.03464, 5.00114, 0.54564+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":2, "position": np.array([-0.89369, -0.11909, 0.30402-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.03464, 5.00114, 0.54564]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":3, "position": np.array([-0.89369, -0.11909, 0.30402+0.2-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.03464, 5.00114, 0.54564+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":4, "position": np.array([0.16345, 0.69284, 0.62942-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.09182, 4.18911, 0.87105]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":4, "position": np.array([0.86452, -0.54305, 0.4366-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.79301, 5.42505, 0.67823+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":5, "position": np.array([0.86452, -0.54305, 0.4366-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.79301, 5.42505, 0.67823+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":6, "position": np.array([0.86452, -0.54305, 0.4366-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.79301, 5.42505, 0.67823+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":7, "position": np.array([0.16345, 0.69284, 0.62942-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.09182, 4.18911, 0.87105]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}
]
self.util.move_ur10(motion_plan, "_wheel_01")
if self.util.motion_task_counter==3 and not self.bool_done[self.id*10+6]:
self.bool_done[self.id*10+6] = True
self.util.remove_part("pf_wheels/platform", f"pf_wheels_4_{self.id}")
self.util.add_part_custom("World/UR10_wheel_01/ee_link","FWheel", f"pf_qwheels_4_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counter==6 and not self.bool_done[self.id*10+7]:
self.bool_done[self.id*10+7] = True
self.util.remove_part("World/UR10_wheel_01/ee_link", f"pf_qwheels_4_{self.id}")
self.util.add_part_custom(f"World/Environment","FWheel", f"wheel_04_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-18.97836, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
if self.util.motion_task_counter==8:
self.util.motion_task_counter=0
print("Done placing wheel")
return True
return False
def place_wheels(self):
if not self.right_side:
self.right_side = self.place_wheels_right()
if not self.left_side:
self.left_side = self.place_wheels_1eft()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def place_wheels_01(self):
if not self.right_side:
self.right_side = self.place_wheels_right_01()
if not self.left_side:
self.left_side = self.place_wheels_1eft_01()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def move_pf_wheels_back(self):
print(self.util.path_plan_counter)
path_plan = [
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait", []],
["translate", [17.56147, 1, False]],
["wait", []],
["rotate", [np.array([1,0,0,0]), 0.0042, False]],
["wait", []],
["translate", [-42.71662, 0, False]],
["wait", []]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
self.util.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_1_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([0.42089, -0.1821, 0.56097]), np.array([0.5, -0.5, 0.5, 0.5]))
self.util.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_2_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([-0.04856, -0.1821, 0.56097]), np.array([0.5, -0.5, 0.5, 0.5]))
self.util.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_3_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([0.42089, -0.1821, 0.41917]), np.array([0.5, -0.5, 0.5, 0.5]))
self.util.add_part_custom("pf_wheels/platform","FWheel", f"pf_wheels_4_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([-0.04856, -0.1821, 0.41917]), np.array([0.5, -0.5, 0.5, 0.5]))
self.id+=1
return True
return False
# -----------------------------cover---------------------------------
def move_pf_main_cover(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-17.18, 1, False]],
["wait",[]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
self.update_color()
return True
return False
def place_main_cover(self):
motion_plan = [
{"index":0, "position": np.array([0.11095-0.11, 0.94, 0.49096-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 1.31062]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":1, "position": np.array([0.11095-0.11, 0.94, 0.2926-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 1.11226]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":2, "position": np.array([0.11095-0.11, 0.94, 0.19682-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 1.01648]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":3, "position": np.array([0.11095-0.11, 0.94, 0.15697-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 0.97663]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":4, "position": np.array([0.11095-0.11, 0.94, 0.11895-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 0.93861]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":5, "position": np.array([0.11095-0.11, 0.94, 0.07882-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 0.89848]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":6, "position": np.array([0.06726, 0.93507, -0.1155-0.16+0.09]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-28.639, -17.135, 0.705+0.09]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":7, "position": np.array([0.06726, 0.93507, -0.1155-0.16+0.05]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-28.639, -17.135, 0.705+0.05]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":8, "position": np.array([0.06726, 0.93507, -0.1155-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-28.639, -17.135, 0.705]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":9, "position": np.array([0.06726, 0.93507, -0.1155-0.16+0.05]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-28.639, -17.135, 0.705+0.05]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":10, "position": np.array([0.06726, 0.93507, -0.1155-0.16+0.09]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-28.639, -17.135, 0.705+0.09]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":11, "position": np.array([0.11095-0.11, 0.94, 0.07882-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 0.89848]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":12, "position": np.array([0.11095, 0.94627, 0.49096-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995, 1.31062]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":13, "position": np.array([-0.28875, 0.74261, 0.51038-0.16]), "orientation": np.array([0.70458, -0.0597, 0.70458, 0.0597]), "goal_position":np.array([-16.99268-11.83808, -16.77844, 1.33072]), "goal_orientation":np.array([0.54043, 0.456, 0.54043, -0.456])},
{"index":14, "position": np.array([-0.5015, 0.55795, 0.51038-0.16]), "orientation": np.array([0.6954, -0.12814, 0.6954, 0.12814]), "goal_position":np.array([-17.17748-11.83808, -16.5655, 1.33072]), "goal_orientation":np.array([0.58233, 0.40111, 0.58233, -0.40111])},
{'index': 15, 'position': np.array([-0.74286, 0.42878, 0.35038]), 'orientation': np.array([ 0.6511, -0.2758, 0.6511, 0.2758]), 'goal_position': np.array([-29.14515, -16.32381, 1.33072]), 'goal_orientation': np.array([ 0.65542, 0.26538, 0.65542, -0.26538])},
{'index': 16, 'position': np.array([-0.89016, 0.32513, 0.35038]), 'orientation': np.array([ 0.60698, -0.36274, 0.60698, 0.36274]), 'goal_position': np.array([-29.24913, -16.1764 , 1.33072]), 'goal_orientation': np.array([ 0.68569, 0.1727 , 0.68569, -0.1727 ])},
{'index': 17, 'position': np.array([-1.09352, -0.27789, 0.42455]), 'orientation': np.array([ 0.5, -0.5, 0.5, 0.5]), 'goal_position': np.array([-29.85252, -15.97435, 1.40075]), 'goal_orientation': np.array([0.70711, 0. , 0.70711, 0. ])},
{'index': 18, 'position': np.array([-1.09352, -0.27789, 0.03772]), 'orientation': np.array([ 0.5, -0.5, 0.5, 0.5]), 'goal_position': np.array([-29.85252, -15.97435, 1.01392]), 'goal_orientation': np.array([0.70711, 0. , 0.70711, 0. ])},
{'index': 19, 'position': np.array([-1.09352, -0.27789, 0.42455]), 'orientation': np.array([ 0.5, -0.5, 0.5, 0.5]), 'goal_position': np.array([-29.85252, -15.97435, 1.40075]), 'goal_orientation': np.array([0.70711, 0. , 0.70711, 0. ])},
{'index': 20, 'position': np.array([-0.89016, 0.32513, 0.35038]), 'orientation': np.array([ 0.60698, -0.36274, 0.60698, 0.36274]), 'goal_position': np.array([-29.24913, -16.1764 , 1.33072]), 'goal_orientation': np.array([ 0.68569, 0.1727 , 0.68569, -0.1727 ])},
{'index': 21, 'position': np.array([-0.74286, 0.42878, 0.35038]), 'orientation': np.array([ 0.6511, -0.2758, 0.6511, 0.2758]), 'goal_position': np.array([-29.14515, -16.32381, 1.33072]), 'goal_orientation': np.array([ 0.65542, 0.26538, 0.65542, -0.26538])},
{"index": 22, "position": np.array([-0.5015, 0.55795, 0.51038-0.16]), "orientation": np.array([0.6954, -0.12814, 0.6954, 0.12814]), "goal_position":np.array([-17.17748-11.83808, -16.5655, 1.33072]), "goal_orientation":np.array([0.58233, 0.40111, 0.58233, -0.40111])},
{"index": 23, "position": np.array([-0.5015, 0.55795, 0.51038-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.17748-11.83808, -16.5655, 1.33072]), "goal_orientation":np.array([0.58233, 0.40111, 0.58233, -0.40111])}]
# {'index': 23, 'position': np.array([0.16394, 0.68799, 0.44663]), 'orientation': np.array([ 0.70711, 0, 0.70711, 0]), 'goal_position': np.array([-28.88652, -17.23535, 1.42725]), 'goal_orientation': np.array([0.70711, 0. , 0.70711, 0. ])}]
self.util.move_ur10(motion_plan, "_main_cover")
if self.util.motion_task_counter==9 and not self.bool_done[self.id*10]:
self.bool_done[self.id*10] = True
self.util.remove_part("pf_main_cover/platform", f"pf_main_cover_{self.id}")
self.util.add_part_custom("World/UR10_main_cover/ee_link",self.color_path[0], f"pf_qmain_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.71735, 0.26961, -0.69234]), np.array([0.5, 0.5, -0.5, 0.5]))
if self.util.motion_task_counter==19 and not self.bool_done[self.id*10+1]:
self.bool_done[self.id*10+1] = True
self.util.remove_part("World/UR10_main_cover/ee_link", f"pf_qmain_cover_{self.id}")
self.util.add_part_custom("World/Environment",self.color_path[0], f"main_cover_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-18.7095-11.83808, -15.70872, 0.28822]), np.array([0.70711, 0.70711,0,0]))
if self.util.motion_task_counter==24:
self.util.motion_task_counter=0
print("Done placing main_cover")
return True
return False
def move_pf_main_cover_back(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-31.2, 1, False]],
["wait", []]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
self.util.add_part_custom("pf_main_cover/platform",self.color_path[1], f"pf_main_cover_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([0.74446, -0.26918, -0.03119]), np.array([0, 0, -0.70711, -0.70711]))
self.id+=1
return True
return False
# -----------------------------handle---------------------------------
def move_pf_handle(self):
print(self.util.path_plan_counter)
path_plan = [
# ["translate", [-32.52, 0, False]],
# ["wait",[]],
# ["rotate", [np.array([0.70711, 0, 0, 0.70711]), 0.0042, True]],
# ["wait", []],
# ["translate", [-7.93, 1, False]],
# ["wait", []],
# ["rotate", [np.array([0, 0, 0, 1]), 0.0042, False]],
# ["wait", []],
["translate", [-28.661, 0, False]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def place_handle(self):
motion_plan = [{"index":0, "position": np.array([0.15669, 0.84626, 0.19321-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-28.6592, -8.04267, 0.4333+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.15669, 0.84626, 0.19321-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-28.6592, -8.04267, 0.4333]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.15669, 0.84626, 0.19321-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-28.6592, -8.04267, 0.4333+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([0.63197, 0.53467, 0.5295-0.16]), "orientation": np.array([0.67393, -0.21407, 0.67393, 0.21407]), "goal_position":np.array([-29.13451, -7.73107, 0.76958]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":4, "position": np.array([0.83727, -0.35853, 0.3259-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-29.33982, -6.83787, 0.56599+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":5, "position": np.array([0.83727, -0.35853, 0.3259-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-29.33982, -6.83787, 0.56599]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":6, "position": np.array([0.83727, -0.35853, 0.3259-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-29.33982, -6.83787, 0.56599+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":7, "position": np.array([-0.00141, 0.74106, -0.16+0.61331]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-28.5011, -7.93748, 0.85506]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])}]
self.util.move_ur10(motion_plan, "_handle")
if self.util.motion_task_counter==2 and not self.bool_done[self.id*10]:
self.bool_done[self.id*10] = True
self.util.remove_part("pf_handle/platform", f"pf_handle_{self.id}")
self.util.add_part_custom("World/UR10_handle/ee_link","handle", f"pf_qhandle_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.5218, 0.42317, 0.36311]), np.array([0.5, -0.5, 0.5, -0.5]))
if self.util.motion_task_counter==6 and not self.bool_done[self.id*10+1]:
self.bool_done[self.id*10+1] = True
self.util.remove_part("World/UR10_handle/ee_link", f"pf_qhandle_{self.id}")
self.util.add_part_custom(f"World/Environment","handle", f"handle_{self.id+1}", np.array([0.001,0.001,0.001]), np.array([-29.70213, -7.25934, 1.08875]), np.array([0, 0.70711, 0.70711, 0]))
if self.util.motion_task_counter==8:
self.util.motion_task_counter=0
print("Done placing handle")
return True
return False
def move_pf_handle_back(self):
print(self.util.path_plan_counter)
path_plan = [
# ["translate", [-32.52, 0, False]],
# ["wait",[]],
# ["rotate", [np.array([0.70711, 0, 0, 0.70711]), 0.0042, True]],
# ["wait", []],
# ["translate", [-5.63293, 1, False]],
# ["wait", []],
# ["rotate", [np.array([0, 0, 0, 1]), 0.0042, False]],
# ["wait", []],
["translate", [-42.77298, 0, False]],
["wait", []]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
self.util.add_part_custom("pf_handle/platform","handle", f"pf_handle_{self.id+1}", np.array([0.001, 0.001, 0.001]), np.array([-0.4248, 0.46934, 0.94076]), np.array([0, 1, 0, 0]))
self.id+=1
return True
return False | 60,249 | Python | 74.218477 | 307 | 0.546349 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/executor_functions.py | import numpy as np
from omni.isaac.examples.hello_world.util import Utils
import asyncio
import rospy
from geometry_msgs.msg import PoseStamped
import rosgraph
from tf.transformations import euler_from_quaternion, quaternion_from_euler
from math import pi
class ExecutorFunctions:
def __init__(self) -> None:
self.util = Utils()
self.isDone = [False]*1000
self.bool_done = [False]*1000
self.delay=0
self.right_side = self.left_side = False
# disassembly counter
self.disassembly_event=0
self.world = None
self.id = None
# non part feeder parts
self.suspension = None
self.battery = None
self.fuel = None
self.light = None
self.lower_cover = None
# visited array
# meaning of its values:
# False - not visited
# True - visiting or visited
self.visited = {"engine":False, "trunk":False, "wheels":False, "cover":False, "handle":False}
# Engine cell set up ----------------------------------------------------------------------------
# bring in moving platforms
self.moving_platform = None
self.my_controller = None
self.screw_my_controller = None
self.articulation_controller = None
self.screw_articulation_controller = None
# Suspension cell set up ------------------------------------------------------------------------
self.my_controller_suspension = None
self.screw_my_controller_suspension = None
self.articulation_controller_suspension = None
self.screw_articulation_controller_suspension = None
# Fuel cell set up ---------------------------------------------------------------------------------
self.my_controller_fuel = None
self.screw_my_controller_fuel = None
self.articulation_controller_fuel = None
self.screw_articulation_controller_fuel = None
# battery cell set up ---------------------------------------------------------------------------------
self.my_controller_battery = None
self.screw_my_controller_battery = None
self.articulation_controller_battery = None
self.screw_articulation_controller_battery = None
# trunk cell set up ---------------------------------------------------------------------------------
self.my_controller_trunk = None
self.screw_my_controller_trunk = None
self.articulation_controller_trunk = None
self.screw_articulation_controller_trunk = None
# wheel cell set up ---------------------------------------------------------------------------------
self.my_controller_wheel = None
self.screw_my_controller_wheel = None
self.articulation_controller_wheel = None
self.screw_articulation_controller_wheel = None
self.my_controller_wheel_01 = None
self.screw_my_controller_wheel_01 = None
self.articulation_controller_wheel_01 = None
self.screw_articulation_controller_wheel_01 = None
# lower_cover cell set up ---------------------------------------------------------------------------------
self.my_controller_lower_cover = None
self.screw_my_controller_lower_cover = None
self.articulation_controller_lower_cover = None
self.screw_articulation_controller_lower_cover = None
self.my_controller_lower_cover_01 = None
self.screw_my_controller_lower_cover_01 = None
self.articulation_controller_lower_cover_01 = None
self.screw_articulation_controller_lower_cover_01 = None
self.my_controller_main_cover = None
self.articulation_controller_main_cover = None
# handle cell set up ---------------------------------------------------------------------------------
self.my_controller_handle = None
self.screw_my_controller_handle = None
self.articulation_controller_handle = None
self.screw_articulation_controller_handle = None
# light cell set up --------------------------------------------------------------------------------
self.my_controller_light = None
self.screw_my_controller_light = None
self.articulation_controller_light = None
self.screw_articulation_controller_light = None
# self._goal_pub = rospy.Publisher(f"/mp{self.id+1}/move_base_simple/goal", PoseStamped, queue_size=1)
# self._xy_goal_tolerance = 0.25
# self._yaw_goal_tolerance = 0.05
# Util declarations ----------------------------------------------------------------------------------
def declare_utils(self):
self.util.world = self.world
self.util.id = self.id
# Engine cell set up ----------------------------------------------------------------------------
# bring in moving platforms
self.util.moving_platform = self.moving_platform
self.util.my_controller = self.my_controller
self.util.screw_my_controller = self.screw_my_controller
self.util.articulation_controller = self.articulation_controller
self.util.screw_articulation_controller = self.screw_articulation_controller
# Suspension cell set up ------------------------------------------------------------------------
self.util.my_controller_suspension = self.my_controller_suspension
self.util.screw_my_controller_suspension = self.screw_my_controller_suspension
self.util.articulation_controller_suspension = self.articulation_controller_suspension
self.util.screw_articulation_controller_suspension = self.screw_articulation_controller_suspension
# Fuel cell set up ---------------------------------------------------------------------------------
self.util.my_controller_fuel = self.my_controller_fuel
self.util.screw_my_controller_fuel = self.screw_my_controller_fuel
self.util.articulation_controller_fuel = self.articulation_controller_fuel
self.util.screw_articulation_controller_fuel = self.screw_articulation_controller_fuel
# battery cell set up ---------------------------------------------------------------------------------
self.util.my_controller_battery = self.my_controller_battery
self.util.screw_my_controller_battery = self.screw_my_controller_battery
self.util.articulation_controller_battery = self.articulation_controller_battery
self.util.screw_articulation_controller_battery = self.screw_articulation_controller_battery
# trunk cell set up ---------------------------------------------------------------------------------
self.util.my_controller_trunk = self.my_controller_trunk
self.util.screw_my_controller_trunk = self.screw_my_controller_trunk
self.util.articulation_controller_trunk = self.articulation_controller_trunk
self.util.screw_articulation_controller_trunk = self.screw_articulation_controller_trunk
# wheel cell set up ---------------------------------------------------------------------------------
self.util.my_controller_wheel = self.my_controller_wheel
self.util.screw_my_controller_wheel = self.screw_my_controller_wheel
self.util.articulation_controller_wheel = self.articulation_controller_wheel
self.util.screw_articulation_controller_wheel = self.screw_articulation_controller_wheel
self.util.my_controller_wheel_01 = self.my_controller_wheel_01
self.util.screw_my_controller_wheel_01 = self.screw_my_controller_wheel_01
self.util.articulation_controller_wheel_01 = self.articulation_controller_wheel_01
self.util.screw_articulation_controller_wheel_01 = self.screw_articulation_controller_wheel_01
# lower_cover cell set up ---------------------------------------------------------------------------------
self.util.my_controller_lower_cover = self.my_controller_lower_cover
self.util.screw_my_controller_lower_cover = self.screw_my_controller_lower_cover
self.util.articulation_controller_lower_cover = self.articulation_controller_lower_cover
self.util.screw_articulation_controller_lower_cover = self.screw_articulation_controller_lower_cover
self.util.my_controller_lower_cover_01 = self.my_controller_lower_cover_01
self.util.screw_my_controller_lower_cover_01 = self.screw_my_controller_lower_cover_01
self.util.articulation_controller_lower_cover_01 = self.articulation_controller_lower_cover_01
self.util.screw_articulation_controller_lower_cover_01 = self.screw_articulation_controller_lower_cover_01
self.util.my_controller_main_cover = self.my_controller_main_cover
self.util.articulation_controller_main_cover = self.articulation_controller_main_cover
# handle cell set up ---------------------------------------------------------------------------------
self.util.my_controller_handle = self.my_controller_handle
self.util.screw_my_controller_handle = self.screw_my_controller_handle
self.util.articulation_controller_handle = self.articulation_controller_handle
self.util.screw_articulation_controller_handle = self.screw_articulation_controller_handle
# light cell set up --------------------------------------------------------------------------------
self.util.my_controller_light = self.my_controller_light
self.util.screw_my_controller_light = self.screw_my_controller_light
self.util.articulation_controller_light = self.articulation_controller_light
self.util.screw_articulation_controller_light = self.screw_articulation_controller_light
def spawn_new_parts(self):
if self.id ==2:
# print(not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id}") and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/engine_{self.id-1}"))
pass
if self.id!=0:
# Engine cell set up ----------------------------------------------------------------------------
# if not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id}") and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id-1}") and not self.util.check_prim_exists(f"mock_robot_{self.id}/platform/engine_{self.id}"):
if not self.isDone[0] and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id}") and not self.util.check_prim_exists(f"World/Environment/engine_small_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/engine_{self.id-1}"):
self.isDone[0] = True
self.util.add_part_custom("World/Environment","engine_no_rigid", f"engine_small_{self.id}", np.array([0.001, 0.001, 0.001]), np.array([-4.86938, 8.14712, 0.59038]), np.array([0.99457, 0, -0.10411, 0]))
# print(" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n --------------------------------------spawned engine "+str(self.id)+" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
# Suspension cell set up ------------------------------------------------------------------------
# if not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id-1}") and not self.util.check_prim_exists(f"mock_robot_{self.id}/platform/xFSuspensionBack_{self.id}"):
if not self.isDone[1] and not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/FSuspensionBack_01_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xFSuspensionBack_{self.id-1}"):
self.isDone[1] = True
self.util.add_part_custom("World/Environment","FSuspensionBack", f"FSuspensionBack_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-6.66288, -4.69733, 0.41322]), np.array([0.5, 0.5, -0.5, 0.5]))
# print(" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n --------------------------------------spawned suspension "+str(self.id)+" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
# Fuel cell set up ---------------------------------------------------------------------------------
if not self.isDone[2] and not self.util.check_prim_exists(f"World/Environment/fuel_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/fuel_01_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xfuel_{self.id-1}"):
self.isDone[2] = True
if self.id%2==0:
self.util.add_part_custom("World/Environment","fuel", f"fuel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-7.01712, -15.89918, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
else:
self.util.add_part_custom("World/Environment","fuel_yellow", f"fuel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-7.01712, -15.89918, 0.41958]), np.array([0.5, 0.5, -0.5, -0.5]))
# battery cell set up ---------------------------------------------------------------------------------
if not self.isDone[3] and not self.util.check_prim_exists(f"World/Environment/battery_01_{self.id}") and not self.util.check_prim_exists(f"World/Environment/battery_01_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xbattery_{self.id-1}"):
self.isDone[3] = True
self.util.add_part_custom("World/Environment","battery", f"battery_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-16.47861, -15.68368, 0.41467]), np.array([0.70711, 0.70711, 0, 0]))
# trunk cell set up ---------------------------------------------------------------------------------
if not self.isDone[4] and not self.util.check_prim_exists(f"World/Environment/trunk_02_{self.id}") and not self.util.check_prim_exists(f"World/Environment/trunk_02_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xtrunk_{self.id-1}"):
self.isDone[4] = True
self.util.add_part_custom("World/Environment","trunk", f"trunk_02_{self.id}", np.array([0.001,0.001,0.001]), np.array([-27.84904, 4.26505, 0.41467]), np.array([0, 0, -0.70711, -0.70711]))
# wheel cell set up ---------------------------------------------------------------------------------
if not self.isDone[5] and not self.util.check_prim_exists(f"World/Environment/wheel_02_{self.id}") and not self.util.check_prim_exists(f"World/Environment/wheel_02_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xwheel_02_{self.id-1}"):
self.isDone[5] = True
self.util.add_part_custom("World/Environment","FWheel", f"wheel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-15.17319, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.util.add_part_custom("World/Environment","FWheel", f"wheel_02_{self.id}", np.array([0.001,0.001,0.001]), np.array([-15.17319, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.util.add_part_custom("World/Environment","FWheel", f"wheel_03_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.97836, 4.72577, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
self.util.add_part_custom("World/Environment","FWheel", f"wheel_04_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.97836, 5.24566, 0.42127]), np.array([0.5, -0.5, -0.5, -0.5]))
# lower_cover cell set up ---------------------------------------------------------------------------------
if not self.isDone[6] and not self.util.check_prim_exists(f"World/Environment/main_cover_{self.id}") and not self.util.check_prim_exists(f"World/Environment/main_cover_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xmain_cover_{self.id-1}"):
self.isDone[6] = True
self.util.add_part_custom("World/Environment","lower_cover", f"lower_cover_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([-26.2541, -15.57458, 0.40595]), np.array([0, 0, 0.70711, 0.70711]))
self.util.add_part_custom("World/Environment","lower_cover", f"lower_cover_04_{self.id}", np.array([0.001,0.001,0.001]), np.array([-26.26153, -19.13631, 0.40595]), np.array([0, 0, -0.70711, -0.70711]))
if self.id%2==0:
self.util.add_part_custom("World/Environment","main_cover", f"main_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.7095-11.83808, -15.70872, 0.28822]), np.array([0.70711, 0.70711,0,0]))
else:
self.util.add_part_custom("World/Environment","main_cover_orange", f"main_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.7095-11.83808, -15.70872, 0.28822]), np.array([0.70711, 0.70711,0,0]))
# handle cell set up ---------------------------------------------------------------------------------
if not self.isDone[7] and not self.util.check_prim_exists(f"World/Environment/handle_{self.id}") and not self.util.check_prim_exists(f"World/Environment/handle_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xhandle_{self.id-1}"):
self.isDone[7] = True
self.util.add_part_custom("World/Environment","handle", f"handle_{self.id}", np.array([0.001,0.001,0.001]), np.array([-29.70213, -7.25934, 1.08875]), np.array([0, 0.70711, 0.70711, 0]))
# light cell set up ---------------------------------------------------------------------------------
if not self.isDone[8] and not self.util.check_prim_exists(f"World/Environment/light_03_{self.id}") and not self.util.check_prim_exists(f"World/Environment/light_03_{self.id-1}") and self.util.check_prim_exists(f"mock_robot_{self.id-1}/platform/xlight_{self.id-1}"):
self.isDone[8] = True
self.util.add_part_custom("World/Environment","FFrontLightAssembly", f"light_03_{self.id}", np.array([0.001,0.001,0.001]), np.array([-18.07685, -7.35866, -0.71703]), np.array([0.28511, -0.28511, -0.64708, -0.64708]))
def _check_goal_reached(self, goal_pose):
# Cannot get result from ROS because /move_base/result also uses move_base_msgs module
mp_position, mp_orientation = self.moving_platform.get_world_pose()
_, _, mp_yaw = euler_from_quaternion(mp_orientation)
_, _, goal_yaw = euler_from_quaternion(goal_pose[3:])
# FIXME: pi needed for yaw tolerance here because map rotated 180 degrees
if np.allclose(mp_position[:2], goal_pose[:2], atol=self._xy_goal_tolerance) \
and abs(mp_yaw-goal_yaw) <= pi + self._yaw_goal_tolerance:
print(f"Goal for mp_{self.id} "+str(goal_pose)+" reached!")
# This seems to crash Isaac sim...
# self.get_world().remove_physics_callback("mp_nav_check")
# Goal hardcoded for now
def _send_navigation_goal(self, x=None, y=None, a=None):
# x, y, a = -18, 14, 3.14
# x,y,a = -4.65, 5.65,3.14
orient_x, orient_y, orient_z, orient_w = quaternion_from_euler(0, 0, a)
pose = [x, y, 0, orient_x, orient_y, orient_z, orient_w]
goal_msg = PoseStamped()
goal_msg.header.frame_id = "map"
goal_msg.header.stamp = rospy.get_rostime()
print("goal pose: "+str(pose))
goal_msg.pose.position.x = pose[0]
goal_msg.pose.position.y = pose[1]
goal_msg.pose.position.z = pose[2]
goal_msg.pose.orientation.x = pose[3]
goal_msg.pose.orientation.y = pose[4]
goal_msg.pose.orientation.z = pose[5]
goal_msg.pose.orientation.w = pose[6]
world = self.get_world()
self._goal_pub.publish(goal_msg)
# self._check_goal_reached(pose)
world = self.get_world()
if not world.physics_callback_exists(f"mp_nav_check_{self.id}"):
world.add_physics_callback(f"mp_nav_check_{self.id}", lambda step_size: self._check_goal_reached(pose))
# Overwrite check with new goal
else:
world.remove_physics_callback(f"mp_nav_check_{self.id}")
world.add_physics_callback(f"mp_nav_check_{self.id}", lambda step_size: self._check_goal_reached(pose))
def move_to_engine_cell_nav(self):
# # print("sending nav goal")
if not self.bool_done[123]:
self._send_navigation_goal(-4.65, 5.65, 3.14)
self.bool_done[123] = True
return False
def move_to_engine_cell(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-4.98951, 0, False], {"position": np.array([-4.98951, 5.65, 0.03551]), "orientation": np.array([0, 0, 0, 1])}]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_engine(self):
print("doing motion plan")
motion_plan = [{"index":0, "position": np.array([0.97858+0.14-0.3, -0.12572, 0.21991]), "orientation": np.array([1, 0, 0, 0]), "goal_position":np.array([-4.86054, 7.95174-0.3, 0.46095]), "goal_orientation":np.array([0.70711, 0, 0, 0.70711])},
{"index":1, "position": np.array([0.97858+0.14, -0.12572, 0.21991]), "orientation": np.array([1, 0, 0, 0]), "goal_position":np.array([-4.86054, 7.95174, 0.46095]), "goal_orientation":np.array([0.70711, 0, 0, 0.70711])},
{"index":2, "position": np.array([0.93302+0.14, -0.12572, 0.54475]), "orientation": np.array([1, 0, 0, 0]), "goal_position":np.array([-4.86054, 7.90617, 0.78578]), "goal_orientation":np.array([0.70711, 0, 0, 0.70711])},
# {"index":3, "position": np.array([1.00103, -0.12198, 0.24084]), "orientation": np.array([1, 0, 0, 0]), "goal_position":np.array([-4.86409, 7.96971, 0.48132]), "goal_orientation":np.array([0.70711, 0, 0, 0.70711])},
{"index":3, "position": np.array([0.80658+0.15, 0.24732, 0.54475]), "orientation": np.array([0.99217, 0, 0, 0.12489]), "goal_position":np.array([-5.23375, 7.77959, 0.78578]), "goal_orientation":np.array([0.61326, 0, 0, 0.78988])},
{"index":4, "position": np.array([0.65068+0.15, 0.39893, 0.54475]), "orientation": np.array([0.97001, 0, 0, 0.24305]), "goal_position":np.array([-5.38549+0.08, 7.6235, 0.78578]), "goal_orientation":np.array([0.51404, 0, 0, 0.85777])},
{"index":5, "position": np.array([0.53837+0.15, 0.63504, 0.54475]), "orientation": np.array([0.92149, 0, 0, 0.38841]), "goal_position":np.array([-5.62169+0.12, 7.51092, 0.78578]), "goal_orientation":np.array([0.37695, 0, 0, 0.92624])},
{"index":6, "position": np.array([0.33707, 0.82498, 0.54475]), "orientation": np.array([0.77061, 0, 0, 0.6373]), "goal_position":np.array([-5.81157+0.16, 7.30908, 0.78578]), "goal_orientation":np.array([0.09427, 0, 0, 0.99555])},
{"index":7, "position": np.array([0.04974, 0.90202, 0.54475]), "orientation": np.array([0.65945, 0, 0, 0.75175]), "goal_position":np.array([-5.88845+0.16, 7.0215, 0.78578]), "goal_orientation":np.array([0.06527, 0, 0, -0.99787])},
{"index":8, "position": np.array([-0.25724, 0.83912, 0.54475]), "orientation": np.array([0.41054, 0, 0, 0.91184]), "goal_position":np.array([-5.82509+0.12, 6.71424+0.11, 0.78578]), "goal_orientation":np.array([0.35448, 0, 0, -0.93506])},
{"index":9, "position": np.array([-0.54443, 0.27481, 0.37107]), "orientation": np.array([0.14679, 0, 0, 0.98917]), "goal_position":np.array([-5.26026+0.05, 6.42705+0.16, 0.61211]), "goal_orientation":np.array([0.59565, 0, 0, -0.80324])},
{"index":10, "position": np.array([-0.60965, -0.03841, 0.37107]), "orientation": np.array([0,0,0,-1]), "goal_position":np.array([-4.94679, 6.36196+0.16, 0.61211]), "goal_orientation":np.array([0.70711,0,0,-0.70711])},
{"index":11, "position": np.array([-0.67167, -0.03841, 0.16822]), "orientation": np.array([0,0,0,-1]), "goal_position":np.array([-4.94679, 6.29994+0.16, 0.40925]), "goal_orientation":np.array([0.70711, 0, 0, -0.70711])},
{"index":12, "position": np.array([-1.05735, -0.06372, 0.1323]), "orientation": np.array([0,0,0,-1]), "goal_position":np.array([-4.92148, 5.91425+0.16, 0.37333]), "goal_orientation":np.array([0.70711, 0, 0, -0.70711])},
{"index":13, "position": np.array([-1.10475-0.16+0.06, -0.11984, 0.13512]), "orientation": np.array([0,0,0.08495,-0.99639]), "goal_position":np.array([-4.86552, 5.86784+0.06, 0.37552]), "goal_orientation":np.array([0.70455, -0.06007, 0.6007, -0.70455])}]
self.util.move_ur10(motion_plan)
if self.util.motion_task_counter==2 and not self.bool_done[1]:
self.bool_done[1] = True
self.util.remove_part("World/Environment", f"engine_small_{self.id}")
self.util.add_part_custom("World/UR10/ee_link","engine_no_rigid", f"qengine_small_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.17441, 0.00314, 0.11018]), np.array([0.70365, -0.06987, -0.06987, -0.70365]))
if self.util.motion_task_counter==14:
self.util.motion_task_counter=0
print("Done placing engine")
self.util.remove_part("World/UR10/ee_link", f"qengine_small_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","engine_no_rigid", f"engine_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.16041, -0.00551, 0.46581]), np.array([0.98404, -0.00148, -0.17792, -0.00274]))
return True
return False
def screw_engine(self):
# motion_plan = [{"index":0, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":1, "position": np.array([-0.68114, -0.10741, -0.16+0.43038]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":2, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":3, "position": self.util.transform_for_screw_ur10(np.array([0.74286, 0.3942, 0.24203])), "orientation": np.array([0.24137, -0.97029, -0.00397, -0.0163]), "goal_position":np.array([-5.14051,5.40792,0.477701]), "goal_orientation":np.array([0.18255, -0.68481, -0.68739, 0.15875])},
# {"index":4, "position": self.util.transform_for_screw_ur10(np.array([0.60205, 0.3942, 0.24203])), "orientation": np.array([0.24137, -0.97029, -0.00397, -0.0163]), "goal_position":np.array([-5.14051,5.40792-0.14,0.477701]), "goal_orientation":np.array([0.18255, -0.68481, -0.68739, 0.15875])},
# {"index":5, "position": self.util.transform_for_screw_ur10(np.array([0.74286, 0.3942, 0.24203])), "orientation": np.array([0.24137, -0.97029, -0.00397, -0.0163]), "goal_position":np.array([-5.14051,5.40792,0.477701]), "goal_orientation":np.array([0.18255, -0.68481, -0.68739, 0.15875])},
# {"index":6, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":7, "position": np.array([-0.68114, -0.10741, -0.16+0.43038]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":8, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":9, "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
# {"index":10, "position": self.util.transform_for_screw_ur10(np.array([0.96984-0.2, -0.03195, 0.16514])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70384, 5.63505-0.2, 0.40916]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
# {"index":11, "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
# {"index":12, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.42692, 4.82896, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
motion_plan = [{"index":0, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":1, "position": np.array([-0.68114, -0.10741, -0.16+0.43038]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":2, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":3, "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":4, "position": self.util.transform_for_screw_ur10(np.array([0.96984-0.2, -0.03195, 0.16514])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70384, 5.63505-0.2, 0.40916]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":5, "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
]
self.util.do_screw_driving(motion_plan)
if self.util.motion_task_counter==6:
print("Done screwing engine")
self.util.motion_task_counter=0
return True
return False
def arm_remove_engine(self):
motion_plan = [{"index":0, "position": np.array([-0.60965-0.16, -0.03841, 0.37107]), "orientation": np.array([0,0,0,-1]), "goal_position":np.array([-4.94679, 6.36196, 0.61211]), "goal_orientation":np.array([0.70711,0,0,-0.70711])},
{"index":1, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.67382, 7.1364, 1.04897]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.move_ur10(motion_plan)
if self.util.motion_task_counter==2:
print("Done arm removal")
self.util.motion_task_counter=0
return True
return False
def turn_mobile_platform(self):
print(self.util.path_plan_counter)
path_plan = [["rotate", [np.array([1, 0, 0, 0]), 0.0042, True]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def screw_engine_two(self):
# motion_plan = [{"index":0, "position": np.array([-0.68984, 0.06874, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.80693, 3.97591, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":1, "position": np.array([-0.68984, 0.06874, -0.16+0.43038]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.80693, 3.97591, 0.67129]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":2, "position": np.array([-0.68984, 0.06874, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.80693, 3.97591, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":3, "position": self.util.transform_for_screw_ur10(np.array([0.7558-0.2, 0.59565, 0.17559])), "orientation": np.array([0.24137, -0.97029, -0.00397, -0.0163]), "goal_position":np.array([-5.3358, 5.42428-0.2, 0.41358]), "goal_orientation":np.array([0.18255, -0.68481, -0.68739, 0.15875])},
# {"index":4, "position": self.util.transform_for_screw_ur10(np.array([0.92167-0.2, 0.59565, 0.17559])), "orientation": np.array([0.24137, -0.97029, -0.00397, -0.0163]), "goal_position":np.array([-5.3358, 5.59014-0.2, 0.41358]), "goal_orientation":np.array([0.18255, -0.68481, -0.68739, 0.15875])},
# {"index":5, "position": np.array([-0.68984, 0.06874, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.80693, 3.97591, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":6, "position": np.array([-0.68984, 0.06874, -0.16+0.43038]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.80693, 3.97591, 0.67129]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":7, "position": np.array([-0.68984, 0.06874, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.80693, 3.97591, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":8, "position": self.util.transform_for_screw_ur10(np.array([0.7743-0.2, 0.13044, 0.24968])), "orientation": np.array([0.14946, 0.98863, 0.00992, 0.01353]), "goal_position":np.array([-4.8676, 5.44277-0.2, 0.48787]), "goal_orientation":np.array([0.09521, 0.6933, 0.70482, 0.1162])},
# {"index":9, "position": self.util.transform_for_screw_ur10(np.array([0.92789-0.2, 0.13045, 0.24968])), "orientation": np.array([0.14946, 0.98863, 0.00992, 0.01353]), "goal_position":np.array([-4.8676, 5.59636-0.2, 0.48787]), "goal_orientation":np.array([0.09521, 0.6933, 0.70482, 0.1162])},
# {"index":10, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.42692, 4.82896, 1.048836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
motion_plan = [{"index":0 , "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":1, "position": self.util.transform_for_screw_ur10(np.array([0.96984-0.2, -0.03195, 0.16514])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70384, 5.63505-0.2, 0.40916]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":2, "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":3, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([-0.68114, -0.10741, -0.16+0.43038]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":5, "position": np.array([-0.68114, -0.10741, -0.16+0.43038+0.2]), "orientation": np.array([0,-0.70711, 0, 0.70711]), "goal_position":np.array([-4.63079, 3.98461, 0.67129+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":6, "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":7, "position": self.util.transform_for_screw_ur10(np.array([0.96984-0.2, -0.03195, 0.16514])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70384, 5.63505-0.2, 0.40916]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":8, "position": self.util.transform_for_screw_ur10(np.array([0.82391-0.2, -0.02307, 0.15366])), "orientation": np.array([0.34479, 0.93825, -0.02095, 0.019]), "goal_position":np.array([-4.70797, 5.48974-0.2, 0.40163]), "goal_orientation":np.array([0.20664, 0.69092, 0.65241, 0.233])},
{"index":9, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.42692, 4.82896, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.do_screw_driving(motion_plan)
if self.util.motion_task_counter==10:
self.util.motion_task_counter=0
print("Done screwing engine 2nd time")
return True
return False
def wait(self):
print("Waiting ...")
if self.delay>100:
print("Done waiting")
self.delay=0
return True
self.delay+=1
return False
def wait_infinitely(self):
print("Waiting ...")
self.moving_platform.apply_action(self.util._my_custom_controller.forward(command=[0,0]))
return False
# if self.delay>100:
# print("Done waiting")
# self.delay=0
# return True
# self.delay+=1
# return False
def move_to_suspension_cell(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-1, 0, False]],
["wait",[]],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait",[]],
["translate", [2.29, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, -1]), 0.0042, True]], # 503
["wait",[]],
# ["translate", [-4.22, 0, False]],
["translate", [-4.7, 0, False]],
["wait",[]],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, False]],
["wait",[]],
["translate", [-5.3, 1, False], {"position": np.array([-5.3, -4.876, 0.03551]), "orientation": np.array([0, 0, 0, 1])}]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_suspension(self):
motion_plan = [*self.suspension,
{"index":3, "position": np.array([-0.96615-0.16, -0.56853+0.12, 0.31143]), "orientation": np.array([-0.00257, 0.00265, -0.82633, -0.56318]), "goal_position":np.array([-5.13459, -4.62413-0.12, 0.55254]), "goal_orientation":np.array([0.56316, 0.82633, -0.00001, -0.00438])},
{"index":4, "position": np.array([-1.10845-0.16, -0.56853+0.12, 0.31143]), "orientation": np.array([-0.00257, 0.00265, -0.82633, -0.56318]), "goal_position":np.array([-4.99229, -4.62413-0.12, 0.55254]), "goal_orientation":np.array([0.56316, 0.82633, -0.00001, -0.00438])},
{"index":5, "position": np.array([-1.10842-0.16, -0.39583, 0.29724]), "orientation": np.array([-0.00055, 0.0008, -0.82242, -0.56888]), "goal_position":np.array([-5.00127, -4.80822, 0.53949]), "goal_orientation":np.array([0.56437, 0.82479, 0.02914, 0.01902])}]
self.util.move_ur10(motion_plan, "_suspension")
if self.util.motion_task_counter==2 and not self.bool_done[2]:
self.bool_done[2] = True
self.util.remove_part("World/Environment", f"FSuspensionBack_0{self.id}")
self.util.add_part_custom("World/UR10_suspension/ee_link","FSuspensionBack", f"qFSuspensionBack_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.16839, 0.158, -0.44332]), np.array([0,0,0,1]))
if self.util.motion_task_counter==6:
print("Done placing fuel")
self.util.motion_task_counter=0
self.util.remove_part("World/UR10_suspension/ee_link", f"qFSuspensionBack_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","FSuspensionBack", f"xFSuspensionBack_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.87892, 0.0239, 0.82432]), np.array([0.40364, -0.58922, 0.57252, -0.40262]))
return True
return False
def screw_suspension(self):
motion_plan = [{"index":0, "position": self.util.transform_for_screw_ur10_suspension(np.array([-0.56003, 0.05522, -0.16+0.43437+0.25])), "orientation": np.array([0, -0.70711,0,0.70711]), "goal_position":np.array([-3.2273, -5.06269, 0.67593+0.25]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": self.util.transform_for_screw_ur10_suspension(np.array([-0.56003, 0.05522, -0.16+0.43437])), "orientation": np.array([0, -0.70711,0,0.70711]), "goal_position":np.array([-3.2273, -5.06269, 0.67593]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": self.util.transform_for_screw_ur10_suspension(np.array([-0.56003, 0.05522, -0.16+0.43437+0.25])), "orientation": np.array([0, -0.70711,0,0.70711]), "goal_position":np.array([-3.2273, -5.06269, 0.67593+0.25]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":3, "position": self.util.transform_for_screw_ur10_suspension(np.array([0.83141+0.16-0.2, -0.16343, 0.34189])), "orientation": np.array([1,0,0,0]), "goal_position":np.array([-4.61995+0.2, -4.84629, 0.58477]), "goal_orientation":np.array([0,0,0,1])},
{"index":4, "position": self.util.transform_for_screw_ur10_suspension(np.array([0.87215+0.16, -0.16343, 0.34189])), "orientation": np.array([1,0,0,0]), "goal_position":np.array([-4.66069, -4.84629,0.58477]), "goal_orientation":np.array([0,0,0,1])},
{"index":5, "position": self.util.transform_for_screw_ur10_suspension(np.array([0.83141+0.16-0.2, -0.16343, 0.34189])), "orientation": np.array([1,0,0,0]), "goal_position":np.array([-4.61995+0.2, -4.84629, 0.58477]), "goal_orientation":np.array([0,0,0,1])},
{"index":6, "position": self.util.transform_for_screw_ur10_suspension(np.array([-0.55625, -0.1223, -0.16+0.43437+0.2])), "orientation": np.array([0, -0.70711,0,0.70711]), "goal_position":np.array([-3.23108, -4.88517, 0.67593+0.25]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":7, "position": self.util.transform_for_screw_ur10_suspension(np.array([-0.55625, -0.1223, -0.16+0.43437])), "orientation": np.array([0, -0.70711,0,0.70711]), "goal_position":np.array([-3.23108, -4.88517, 0.67593]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":8, "position": self.util.transform_for_screw_ur10_suspension(np.array([-0.55625, -0.1223, -0.16+0.43437+0.2])), "orientation": np.array([0, -0.70711,0,0.70711]), "goal_position":np.array([-3.23108, -4.88517, 0.67593+0.25]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":9, "position": self.util.transform_for_screw_ur10_suspension(np.array([0.81036+0.16-0.1, -0.26815, 0.24723])), "orientation": np.array([0,-1, 0, 0]), "goal_position":np.array([-4.59801+0.1, -4.7396, 0.49012]), "goal_orientation":np.array([0,0,1,0])},
{"index":10, "position": self.util.transform_for_screw_ur10_suspension(np.array([0.91167+0.16, -0.26815, 0.24723])), "orientation": np.array([0,-1, 0, 0]), "goal_position":np.array([-4.69933, -4.7396, 0.49012]), "goal_orientation":np.array([0,0,1,0])},
{"index":11, "position": self.util.transform_for_screw_ur10_suspension(np.array([0.81036+0.16-0.1, -0.26815, 0.24723])), "orientation": np.array([0,-1, 0, 0]), "goal_position":np.array([-4.59801+0.1, -4.7396, 0.49012]), "goal_orientation":np.array([0,0,1,0])},
{"index":12, "position": self.util.transform_for_screw_ur10_suspension(np.array([-0.08295-0.16, -0.58914, 0.32041-0.15])), "orientation": np.array([0,0.70711, 0, -0.70711]), "goal_position":np.array([-3.544, -4.41856, 0.56125]), "goal_orientation":np.array([0.70711,0,0.70711,0])}]
self.util.do_screw_driving(motion_plan, "_suspension")
if self.util.motion_task_counter==13:
print("Done screwing suspension")
self.util.motion_task_counter=0
return True
return False
def arm_remove_suspension(self):
motion_plan = [{"index":0, "position": np.array([-0.95325-0.16, -0.38757, 0.31143]), "orientation": np.array([-0.00257, 0.00265, -0.82633, -0.56318]), "goal_position":np.array([-5.14749, -4.80509, 0.55254]), "goal_orientation":np.array([0.56316, 0.82633, -0.00001, -0.00438])},
{"index":1, "position": np.array([0.03492, 0.9236, 0.80354]), "orientation": np.array([0.70711, 0, 0, 0.70711]), "goal_position":np.array([-6.13579,-5.95519, 1.04451]), "goal_orientation":np.array([0.70711, 0, 0, -0.70711])}]
self.util.move_ur10(motion_plan, "_suspension")
if self.util.motion_task_counter==2:
print("Done arm removal")
self.util.motion_task_counter=0
return True
return False
def move_to_fuel_cell(self):
print(self.util.path_plan_counter)
# path_plan = [["translate", [-5.15, 0, True]],
# ["wait",[]],
# ["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, False]],
# ["wait",[]],
# ["translate", [-15.945, 1, True]]]
path_plan = [["translate", [-9.69, 0, True]],
["wait",[]],
["rotate", [np.array([0.06883, 0, 0, 0.99763]), 0.0042, False]],
["wait",[]],
["translate", [-8.53, 0, True]],
["wait",[]],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, False]],
["wait",[]],
["translate", [-5.15, 0, True]],
["wait",[]],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, False]],
["wait",[]],
["translate", [-15.945, 1, True]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_fuel(self):
motion_plan = [
# {"index":0, "position": np.array([0.71705+0.16, -0.17496, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.81443, -15.98881, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
# {"index":1, "position": np.array([0.87135+0.16, -0.17496, 0.34496]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.98881, 0.58618]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
# {"index":2, "position": np.array([0.87135+0.16, -0.17496, 0.48867]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-6.96873, -15.98881, 0.72989]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
*self.fuel,
{"index":3, "position": np.array([-0.70299-0.16-0.04247, -0.19609, 0.65442]), "orientation": np.array([0, 0, -0.70711, -0.70711]), "goal_position":np.array([-5.39448+0.04247, -15.9671, 0.89604]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":4, "position": np.array([-0.70299-0.16-0.04247, -0.19609, 0.53588]), "orientation": np.array([0, 0, -0.70711, -0.70711]), "goal_position":np.array([-5.39448+0.04247, -15.9671, 0.77749]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])}]
self.util.move_ur10(motion_plan, "_fuel")
if self.util.motion_task_counter==2 and not self.bool_done[4]:
self.bool_done[4] = True
self.util.remove_part("World/Environment", f"fuel_0{self.id}")
if self.id%2==0:
self.util.add_part_custom("World/UR10_fuel/ee_link","fuel", f"qfuel_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.05467, -0.16886, 0.08908]), np.array([0.70711,0,0.70711,0]))
else:
self.util.add_part_custom("World/UR10_fuel/ee_link","fuel_yellow", f"qfuel_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.05467, -0.16886, 0.08908]), np.array([0.70711,0,0.70711,0]))
if self.util.motion_task_counter==5:
print("Done placing fuel")
self.util.motion_task_counter=0
self.util.remove_part("World/UR10_fuel/ee_link", f"qfuel_{self.id}")
if self.id%2==0:
self.util.add_part_custom(f"mock_robot_{self.id}/platform","fuel", f"xfuel_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.11281, -0.08612, 0.59517]), np.array([0, 0, -0.70711, -0.70711]))
else:
self.util.add_part_custom(f"mock_robot_{self.id}/platform","fuel_yellow", f"xfuel_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.11281, -0.08612, 0.59517]), np.array([0, 0, -0.70711, -0.70711]))
return True
return False
def screw_fuel(self):
def transform(points):
points[0]-=0
points[2]-=0.16
return points
motion_plan = [{"index":0, "position": transform(np.array([-0.6864, 0.07591, 0.42514+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.55952, -16.016, 0.666+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":1, "position": transform(np.array([-0.6864, 0.07591, 0.42514])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.55952, -16.016, 0.666]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":2, "position": transform(np.array([-0.6864, 0.07591, 0.42514+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.55952, -16.016, 0.666+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":3, "position": transform(np.array([0.915+0.04247-0.08717, -0.1488, 0.572+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.161-0.04247+0.08717, -15.791, 0.814+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":4, "position": transform(np.array([0.915+0.04247-0.08717, -0.1488, 0.572])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.161-0.04247+0.08717, -15.791, 0.814]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":5, "position": transform(np.array([0.915+0.04247-0.08717, -0.1488, 0.572+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.161-0.04247+0.08717, -15.791, 0.814+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":6, "position": transform(np.array([-0.68202, -0.09908, 0.42514+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.5639, -15.84102, 0.666+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":7, "position": transform(np.array([-0.68202, -0.09908, 0.42514])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.5639, -15.84102, 0.666]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":8, "position": transform(np.array([-0.68202, -0.09908, 0.42514+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.5639, -15.84102, 0.666+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":9, "position": transform(np.array([0.908+0.04247-0.08717, 0.104, 0.572+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.154-0.04247+0.08717, -16.044, 0.814+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":10, "position": transform(np.array([0.908+0.04247-0.08717, 0.104, 0.572])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.154-0.04247+0.08717, -16.044, 0.814]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":11, "position": transform(np.array([0.908+0.04247-0.08717, 0.104, 0.572+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-5.154-0.04247+0.08717, -16.044, 0.814+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":12, "position": transform(np.array([-0.68202, -0.09908, 0.42514+0.3])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.5639, -15.84102, 0.666+0.3]), "goal_orientation":np.array([0,0.70711,0,-0.70711])}]
# motion_plan = [{"index":0, "position": self.util.transform_for_screw_ur10_fuel(transform(np.array([0.74393, 0.15931, 0.61626]))), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-4.76508, -16.68786, 0.85892]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
# {"index":1, "position": self.util.transform_for_screw_ur10_fuel(transform(np.array([0.74393, 0.15931, 0.5447]))), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-4.76508, -16.68786, 0.78736]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
# {"index":2, "position": self.util.transform_for_screw_ur10_fuel(transform(np.array([0.74393, 0.15931, 0.61626]))), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-4.76508, -16.68786, 0.85892]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
# {"index":3, "position": self.util.transform_for_screw_ur10_fuel(transform(np.array([0.74393, 0.4077, 0.61626]))), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-4.76508, -16.93625, 0.85892]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
# {"index":4, "position": self.util.transform_for_screw_ur10_fuel(transform(np.array([0.74393, 0.4077, 0.5447]))), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-4.76508, -16.93625, 0.78736]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
# {"index":5, "position": self.util.transform_for_screw_ur10_fuel(transform(np.array([0.74393, 0.4077, 0.61626]))), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-4.76508, -16.93625, 0.85892]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
# {"index":6, "position": self.util.transform_for_screw_ur10_fuel(transform(np.array([-0.04511, 0.7374, 0.41493]))), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-3.97604, -17.26595,0.6576]), "goal_orientation":np.array([0,-0.70711,0,0.70711])}]
self.util.do_screw_driving(motion_plan,"_fuel")
if self.util.motion_task_counter==13:
print("Done screwing fuel")
self.util.motion_task_counter=0
return True
return False
def arm_remove_fuel(self):
motion_plan = [{"index":0, "position": np.array([-0.70299-0.16-0.04247, -0.19609, 0.65442]), "orientation": np.array([0, 0, -0.70711, -0.70711]), "goal_position":np.array([-5.39448+0.04247, -15.9671, 0.89604]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":1, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-6.2616, -16.8517, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.move_ur10(motion_plan,"_fuel")
if self.util.motion_task_counter==2:
print("Done arm removal")
self.util.motion_task_counter=0
return True
return False
def move_to_battery_cell(self):
print(self.util.path_plan_counter)
path_plan = [
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait",[]],
["translate", [-12.5, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, 1]), 0.503, True]],
["wait",[]],
["translate", [-9.54, 0, False]],
["wait",[]],
["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, False]],
["wait",[]],
["translate", [-17.17, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, -1]), 0.0042, True]],
["wait",[]],
["translate", [-16.7, 0, False]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_battery(self):
motion_plan = [
# {"index":0, "position": np.array([-0.12728, -0.61362, 0.4+0.1-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.71631, 0.64303+0.1]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# {"index":1, "position": np.array([-0.12728, -0.61362, 0.4-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.71631, 0.64303]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# {"index":2, "position": np.array([-0.12728, -0.61362, 0.4+0.1-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.42647, -15.71631, 0.64303+0.1]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
*self.battery,
# {"index":3, "position": np.array([0.87593, -0.08943, 0.60328-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.42989, -16.24038, 0.8463]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":3, "position": np.array([-0.15683+0.05, 0.95185-0.09326, 0.57477+0.1-0.16]), "orientation": np.array([0.81202, 0, 0.58362, 0]), "goal_position":np.array([-16.39705, -17.18895, 0.81657+0.1]), "goal_orientation":np.array([0, -0.58362, 0, 0.81202])},
{"index":4, "position": np.array([-0.15683+0.05, 0.95185-0.09326, 0.57477-0.16]), "orientation": np.array([0.81202, 0, 0.58362, 0]), "goal_position":np.array([-16.39705, -17.18895, 0.81657]), "goal_orientation":np.array([0, -0.58362, 0, 0.81202])}]
self.util.move_ur10(motion_plan, "_battery")
if self.util.motion_task_counter==2 and not self.bool_done[3]:
self.bool_done[3] = True
self.util.remove_part("World/Environment", f"battery_0{self.id}")
self.util.add_part_custom("World/UR10_battery/ee_link","battery", f"qbattery_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.2361, 0.05277, 0.03064]), np.array([0.00253, -0.7071, 0.7071, 0.00253]))
if self.util.motion_task_counter==5:
print("Done placing battery")
self.util.motion_task_counter=0
self.util.remove_part("World/UR10_battery/ee_link", f"qbattery_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","battery", f"xbattery_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.20126, 0.06146, 0.58443]), np.array([0.4099, 0.55722, -0.58171, -0.42791]))
return True
return False
def screw_battery(self):
def transform(points):
points[0]-=0
points[2]-=0.16
return points
motion_plan = [{"index":0, "position": transform(np.array([-0.03593, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.3161, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":2, "position": transform(np.array([-0.03593, 0.62489, 0.44932])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.3161, -18.79419, 0.69132]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":1, "position": transform(np.array([-0.03593, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.3161, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":3, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
{"index":4, "position": transform(np.array([0.255, -1.04157+0, 0.53925])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.60656, -17.12807-0, 0.78133]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
{"index":5, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
{"index":6, "position": transform(np.array([-0.21277, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.13927, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":7, "position": transform(np.array([-0.21277, 0.62489, 0.44932])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.13927, -18.79419, 0.69132]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":8, "position": transform(np.array([-0.21277, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.13927, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
{"index":9, "position": transform(np.array([0.28749, -0.92175+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.24789-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
{"index":10, "position": transform(np.array([0.255, -0.92175+0, 0.53925])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.60656, -17.24789-0, 0.78133]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
{"index":11, "position": transform(np.array([0.28749, -0.92175+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.24789-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
{"index":12, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.515, -18.858, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
# motion_plan = [{"index":0, "position": transform(np.array([-0.03593, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.3161, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
# {"index":1, "position": transform(np.array([-0.03593, 0.62489, 0.44932])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.3161, -18.79419, 0.69132]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
# {"index":2, "position": transform(np.array([-0.03593, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.3161, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
# {"index":3, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":4, "position": transform(np.array([0.255, -1.04157+0, 0.53925])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.60656, -17.12807-0, 0.78133]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":5, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":6, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":7, "position": transform(np.array([0.255, -1.04157+0, 0.53925])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.60656, -17.12807-0, 0.78133]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":8, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":9, "position": transform(np.array([-0.21277, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.13927, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
# {"index":10, "position": transform(np.array([-0.21277, 0.62489, 0.44932])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.13927, -18.79419, 0.69132]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
# {"index":11, "position": transform(np.array([-0.21277, 0.62489, 0.44932+0.1])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.13927, -18.79419, 0.69132+0.1]), "goal_orientation":np.array([0,0.70711,0,-0.70711])},
# {"index":12, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":13, "position": transform(np.array([0.255, -1.04157+0, 0.53925])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.60656, -17.12807-0, 0.78133]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":14, "position": transform(np.array([0.28749, -1.04157+0, 0.61049])), "orientation": np.array([0, 0.58727, 0, -0.80939]), "goal_position":np.array([-16.63905, -17.12807-0, 0.85257]), "goal_orientation":np.array([0.80939, 0, 0.58727, 0])},
# {"index":15, "position": transform(np.array([-0.21277, 0.62489, 0.44932+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.13927, -18.79419, 0.69132+0.2]), "goal_orientation":np.array([0,0.70711,0,-0.70711])}]
self.util.do_screw_driving(motion_plan,"_battery")
if self.util.motion_task_counter==13:
print("Done screwing battery")
self.util.motion_task_counter=0
return True
return False
def arm_remove_battery(self):
motion_plan = [ {"index":0, "position": np.array([-0.15683+0.05, 0.95185, 0.57477+0.1-0.16]), "orientation": np.array([0.81202, 0, 0.58362, 0]), "goal_position":np.array([-16.39705, -17.18895-0.09326, 0.81657+0.1]), "goal_orientation":np.array([0, -0.58362, 0, 0.81202])},
{"index":1, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.7179, -17.0181, 1.04897]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.move_ur10(motion_plan, "_battery")
if self.util.motion_task_counter==2:
print("Done arm removal")
self.util.motion_task_counter=0
return True
return False
def move_mp_to_battery_cell(self):
print(self.util.path_plan_counter)
path_plan = [
["translate", [-16.41, 1, False]]]
self.util.move_mp_battery(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def moving_part_feeders(self):
print(self.util.path_plan_counter)
if not self.bool_done[0]:
path_plan = [
["translate", [-16.41, 1, True]]]
self.util.move_mp_battery(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.bool_done[0]=True
if not self.bool_done[1]:
path_plan = [
["translate", [-6.84552, 0, False]]]
self.util.move_mp_fuel(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.bool_done[1]=True
if not self.bool_done[2]:
path_plan = [
["translate", [-6.491, 0, False]]]
self.util.move_mp_suspension(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.bool_done[2]=True
if not self.bool_done[3]:
path_plan = [
["translate", [-5.07, 0, False]]]
self.util.move_mp_engine(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.bool_done[3]=True
if self.bool_done[0] and self.bool_done[1] and self.bool_done[2] and self.bool_done[3]:
return True
return False
def battery_part_feeding(self):
motion_plan = [{"index":0, "position": np.array([0.73384, 0.33739, 0.27353-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.66717, 0.51553+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.73384, 0.33739, 0.27353-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.66717, 0.51553]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.73384, 0.33739, 0.27353-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.66717, 0.51553+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([-0.07017, -0.70695, 0.4101-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.48356, -15.62279, 0.65211+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":4, "position": np.array([-0.07017, -0.70695, 0.4101-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.48356, -15.62279, 0.65211]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":5, "position": np.array([-0.07017, -0.70695, 0.4101-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.48356, -15.62279, 0.65211+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":6, "position": np.array([0.73384, 0.06664, 0.27353-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.39642, 0.51553+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":7, "position": np.array([0.73384, 0.06664, 0.27353-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.39642, 0.51553]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":8, "position": np.array([0.73384, 0.06664, 0.27353-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.39642, 0.51553+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":9, "position": np.array([-0.36564, -0.70695, 0.4101-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.18809, -15.62279, 0.65211+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":10, "position": np.array([-0.36564, -0.70695, 0.4101-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.18809, -15.62279, 0.65211]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":11, "position": np.array([-0.36564, -0.70695, 0.4101-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-16.18809, -15.62279, 0.65211+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":12, "position": np.array([0.73384, -0.20396, 0.27353-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.12582, 0.51553+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":13, "position": np.array([0.73384, -0.20396, 0.27353-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.12582, 0.51553]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":14, "position": np.array([0.73384, -0.20396, 0.27353-0.16+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.288, -16.12582, 0.51553+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":15, "position": np.array([-0.66681, -0.70695, 0.4101-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-15.88692, -15.62279, 0.65211+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":16, "position": np.array([-0.66681, -0.70695, 0.4101-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-15.88692, -15.62279, 0.65211]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":17, "position": np.array([-0.66681, -0.70695, 0.4101-0.16+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-15.88692, -15.62279, 0.65211+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":18, "position": np.array([-0.15683+0.05, 0.95185-0.09326, 0.57477-0.16]), "orientation": np.array([0.81202, 0, 0.58362, 0]), "goal_position":np.array([-16.39705, -17.18895, 0.81657]), "goal_orientation":np.array([0, -0.58362, 0, 0.81202])}]
self.util.move_ur10(motion_plan, "_battery")
if self.util.motion_task_counter==2 and not self.bool_done[3]:
self.bool_done[3] = True
self.util.remove_part("battery_bringer/platform", "battery_06")
self.util.add_part_custom("World/UR10_battery/ee_link","battery", "qbattery_06", np.array([0.001,0.001,0.001]), np.array([0.2361, 0.05277, 0.03064]), np.array([0, -0.70711, 0.70711, 0]))
if self.util.motion_task_counter==8 and not self.bool_done[4]:
self.bool_done[4] = True
self.util.remove_part("battery_bringer/platform", "battery_05")
self.util.add_part_custom("World/UR10_battery/ee_link","battery", "qbattery_05", np.array([0.001,0.001,0.001]), np.array([0.2361, 0.05277, 0.03064]), np.array([0, -0.70711, 0.70711, 0]))
if self.util.motion_task_counter==14 and not self.bool_done[5]:
self.bool_done[5] = True
self.util.remove_part("battery_bringer/platform", "battery_01")
self.util.add_part_custom("World/UR10_battery/ee_link","battery", "qbattery_01", np.array([0.001,0.001,0.001]), np.array([0.2361, 0.05277, 0.03064]), np.array([0, -0.70711, 0.70711, 0]))
if self.util.motion_task_counter==5 and not self.bool_done[6]:
self.bool_done[6] = True
print("Done placing battery 1")
self.util.remove_part("World/UR10_battery/ee_link", "qbattery_06")
self.util.add_part_custom("World/Environment","battery", "xbattery_06", np.array([0.001,0.001,0.001]), np.array([-16.53656, -15.59236, 0.41568]), np.array([0.70711, 0.70711, 0, 0]))
if self.util.motion_task_counter==11 and not self.bool_done[7]:
self.bool_done[7] = True
print("Done placing battery 2")
self.util.remove_part("World/UR10_battery/ee_link", "qbattery_05")
self.util.add_part_custom("World/Environment","battery", "xbattery_05", np.array([0.001,0.001,0.001]), np.array([-16.23873, -15.59236, 0.41568]), np.array([0.70711, 0.70711, 0, 0]))
if self.util.motion_task_counter==17 and not self.bool_done[8]:
self.bool_done[8] = True
print("Done placing battery 3")
self.util.remove_part("World/UR10_battery/ee_link", "qbattery_01")
self.util.add_part_custom("World/Environment","battery", "xbattery_01", np.array([0.001,0.001,0.001]), np.array([-15.942, -15.59236, 0.41568]), np.array([0.70711, 0.70711, 0, 0]))
if self.util.motion_task_counter == 18:
print("Done placing 3 batterys")
self.util.motion_task_counter=0
return True
return False
def move_to_trunk_cell(self):
print(self.util.path_plan_counter)
path_plan = [
["translate", [-23.49, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, -1]), 0.0042, True]],
["wait",[]],
["translate", [-35.47, 0, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait",[]],
["translate", [5.35, 1, False]],
["wait",[]],
["rotate", [np.array([1, 0, 0, 0]), 0.0032, True]],
["wait",[]],
["translate", [-26.75, 0, False]]]
if self.id==1:
path_plan = [
["translate", [-23.49, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, -1]), 0.0042, True]],
["wait",[]],
["translate", [-35.47, 0, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait",[]],
["translate", [5.45, 1, False]],
["wait",[]],
["rotate", [np.array([1, 0, 0, 0]), 0.0032, True]],
["wait",[]],
["translate", [-26.75, 0, False]]]
if self.id==2:
path_plan = [
["translate", [-23.49, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, -1]), 0.0042, True]],
["wait",[]],
["translate", [-35.47, 0, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, -0.70711]), 0.0042, True]],
["wait",[]],
["translate", [5.45, 1, False]],
["wait",[]],
["rotate", [np.array([1, 0, 0, 0]), 0.0032, True]],
["wait",[]],
["translate", [-26.75, 0, False]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_trunk(self):
motion_plan = [{"index":0, "position": np.array([0.9596, 0.21244, -0.16+0.4547+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-28.06, 4.27349, 0.69642+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.9596, 0.21244, -0.16+0.4547]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-28.06, 4.27349, 0.69642]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.9596, 0.21244, -0.16+0.4547+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-28.06, 4.27349, 0.69642+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([0.74919, -0.50484, -0.16+0.64833]), "orientation": np.array([-0.20088, -0.67797, -0.20088, 0.67797]), "goal_position":np.array([-27.85221, 4.99054, 0.89005]), "goal_orientation":np.array([0.67797, -0.20088, 0.67797, 0.20088])},
# {"index":4, "position": np.array([0.41663, -0.77637, -0.16+0.75942]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-27.519, 5.262, 1.00113]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":4, "position": np.array([0.55084, -0.81339+0.02396+0, -0.16+0.75942]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-27.65404, 5.26-0.02396-0, 1.00113]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":5, "position": np.array([0.42543, -0.81339+0.02396+0, -0.16+0.75942]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-27.52862, 5.26-0.02396-0, 1.00113]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}]
self.util.move_ur10(motion_plan, "_trunk")
if self.util.motion_task_counter==2 and not self.bool_done[5]:
self.bool_done[5] = True
self.util.remove_part("World/Environment", f"trunk_02_{self.id}")
self.util.add_part_custom("World/UR10_trunk/ee_link","trunk", f"qtrunk_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.28167, -0.21084, -0.00861]), np.array([0.70711, 0, 0, 0.70711]))
if self.util.motion_task_counter==6:
print("Done placing trunk")
self.util.motion_task_counter=0
self.util.remove_part("World/UR10_trunk/ee_link", f"qtrunk_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","trunk", f"xtrunk_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.79319, -0.21112, 0.70114]), np.array([0.5, 0.5, 0.5, 0.5]))
return True
return False
def screw_trunk(self):
def transform(points):
points[0]-=0
points[2]-=0
return points
motion_plan = [{"index":0, "position": transform(np.array([-0.15245, -0.65087-0.24329, -0.16+0.43677+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.14748, 7.43945, 0.67876+0.2]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
{"index":1, "position": transform(np.array([-0.15245, -0.65087-0.24329, -0.16+0.43677])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.14748, 7.43945, 0.67876]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
{"index":2, "position": transform(np.array([-0.15245, -0.65087-0.24329, -0.16+0.43677+0.2])), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.14748, 7.43945, 0.67876+0.2]), "goal_orientation":np.array([0,-0.70711,0,0.70711])},
{"index":3, "position": transform(np.array([-0.12592, 1.126+0.16-0.24329+0.02396+0.11321-0.2, 0.48602])), "orientation": np.array([0.5, 0.5, 0.5, 0.5]), "goal_position":np.array([-27.17401, 5.66311-0.02396-0.11321+0.2, 0.7279]), "goal_orientation":np.array([0.5, 0.5, -0.5, -0.5])},
{"index":4, "position": transform(np.array([-0.12592, 1.33575+0.16-0.24329+0.02396+0.11321-0.2, 0.48602])), "orientation": np.array([0.5, 0.5, 0.5, 0.5]), "goal_position":np.array([-27.17401, 5.45335-0.02396-0.11321+0.2, 0.7279]), "goal_orientation":np.array([0.5, 0.5, -0.5, -0.5])},
{"index":5, "position": transform(np.array([-0.12592, 1.126+0.16-0.24329+0.02396+0.11321-0.2, 0.48602])), "orientation": np.array([0.5, 0.5, 0.5, 0.5]), "goal_position":np.array([-27.17401, 5.66311-0.02396-0.11321+0.2, 0.7279]), "goal_orientation":np.array([0.5, 0.5, -0.5, -0.5])},
{"index":6, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.4637, 5.85911, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.do_screw_driving(motion_plan,"_trunk")
if self.util.motion_task_counter==7:
print("Done screwing trunk")
self.util.motion_task_counter=0
return True
return False
def arm_remove_trunk(self):
motion_plan = [{"index":0, "position": np.array([0.42543, -0.81339+0.02396+0, -0.16+0.75942+0.1]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-27.52862, 5.26-0.02396-0, 1.00113+0.1]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.2673, 3.79761, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.move_ur10(motion_plan, "_trunk")
if self.util.motion_task_counter==2:
print("Done arm removal")
self.util.motion_task_counter=0
return True
return False
def move_to_wheel_cell(self):
print(self.util.path_plan_counter)
path_plan = [
["translate", [-21.3, 0, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, -0.70711]), 0.0042, False]],
["wait",[]],
["translate", [9.3, 1, False]],
["wait",[]],
["rotate", [np.array([-1, 0, 0, 0]), 0.0042, True]],
["wait",[]],
["translate", [-16.965, 0, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, True]],
["wait",[]],
# ["translate", [5.39, 1, False]],
["translate", [6, 1, False]]
]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_wheel_01(self):
motion_plan = [{"index":0, "position": np.array([0.86671, -0.02468, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.79517, 4.90661, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.86671, -0.02468, -0.16+0.4353]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.79517, 4.90661, 0.67666]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.86671, -0.02468, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.79517, 4.90661, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([0.00762, 0.77686, -0.16+0.48217]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.935, 4.105, 0.723]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
# {"index":4, "position": np.array([-0.39779, 0.19418, -0.16+0.51592]), "orientation": np.array([0.62501, -0.3307, 0.62501, 0.3307]), "goal_position":np.array([-17.53, 4.68, 0.758]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":5, "position": np.array([-0.35597, -0.15914, -0.16+0.48217]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.572, 5.04127, 0.723]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":6, "position": np.array([-0.48413-0.16, -0.28768, 0.29642]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.446, 5.16, 0.537]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":7, "position": np.array([-0.27412-0.16, -0.61531, 0.25146]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.656, 5.497, 0.492]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":8, "position": np.array([-0.3-0.16, -0.75, 0.2]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.62, 5.63, 0.44]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([-0.33031-0.16, -0.78789, 0.15369]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.596, 5.671, 0.394]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":5, "position": np.array([-0.49798-0.16, -0.78789, 0.15369]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.42945, 5.671, 0.394]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":6, "position": np.array([-0.33031-0.16, -0.78789, 0.15369]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.596, 5.671, 0.394]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":7, "position": np.array([-0.35597, -0.15914, -0.16+0.48217]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.572, 5.04127, 0.723]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":8, "position": np.array([0.00762, 0.77686, -0.16+0.48217]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.935, 4.105, 0.723]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":9, "position": np.array([0.16345, 0.69284, 0.62942-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.09182, 4.18911, 0.87105]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}]
self.util.move_ur10(motion_plan, "_wheel_01")
if self.util.motion_task_counter==2 and not self.bool_done[45]:
self.bool_done[45] = True
self.util.remove_part("World/Environment", f"wheel_03_{self.id}")
self.util.add_part_custom("World/UR10_wheel_01/ee_link","FWheel", f"qwheel_03_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counter==5 and not self.bool_done[6]:
self.bool_done[6] = True
print("Done placing wheel")
self.util.remove_part("World/UR10_wheel_01/ee_link", f"qwheel_03_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","FWheel", f"xwheel_03_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.15255, -0.1948, 0.56377]), np.array([0.5, -0.5, 0.5, -0.5]))
if self.util.motion_task_counter==10:
self.util.motion_task_counter=0
return True
return False
def screw_wheel_01(self):
motion_plan = [{"index":0, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.67966, -0.08619, -0.16+0.44283]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":3, "position": np.array([-0.49561+0.1-0.16, 0.61097, 0.22823]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.68598, 0.46965]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":4, "position": np.array([-0.49561-0.16, 0.61097, 0.22823]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516, 5.68598, 0.46965]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":5, "position": np.array([-0.49561+0.1-0.16, 0.61097, 0.22823]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.68598, 0.46965]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":6, "position": np.array([0.67966, 0.09013, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.20682, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":7, "position": np.array([0.67966, 0.09013, -0.16+0.44283]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.20682, 0.68464]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":8, "position": np.array([0.67966, 0.09013, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.20682, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":9, "position": np.array([-0.49561+0.1-0.16, 0.66261, 0.23808]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.63434, 0.47951]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":10, "position": np.array([-0.49561-0.16, 0.66261, 0.23808]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516, 5.63434, 0.47951]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":11, "position": np.array([-0.49561+0.1-0.16, 0.66261, 0.23808]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.63434, 0.47951]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":12, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":13, "position": np.array([0.67966, -0.08619, -0.16+0.44283]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":14, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":15, "position": np.array([-0.49561+0.1-0.16, 0.6234, 0.27624]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.67355, 0.51766]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":16, "position": np.array([-0.49561-0.16, 0.6234, 0.27624]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516, 5.67355, 0.51766]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":17, "position": np.array([-0.49561+0.1-0.16, 0.6234, 0.27624]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.67355, 0.51766]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":18, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}]
self.util.do_screw_driving(motion_plan,"_wheel_01")
if self.util.motion_task_counter==19:
print("Done screwing wheel")
self.util.motion_task_counter=0
return True
return False
def arm_place_wheel(self):
print("here")
motion_plan = [{"index":0, "position": np.array([-0.86671, -0.02468, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.99517, 4.90661, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.86671, -0.02468, -0.16+0.4353]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.99517, 4.90661, 0.67666]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.86671, -0.02468, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.99517, 4.90661, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([-0.00762, 0.77686, -0.16+0.48217]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-15.858, 4.105, 0.723]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
# {"index":4, "position": np.array([-0.39779, 0.19418, -0.16+0.51592]), "orientation": np.array([0.62501, -0.3307, 0.62501, 0.3307]), "goal_position":np.array([-17.53, 4.68, 0.758]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":5, "position": np.array([-0.35597, -0.15914, -0.16+0.48217]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.572, 5.04127, 0.723]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":6, "position": np.array([-0.48413-0.16, -0.28768, 0.29642]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.446, 5.16, 0.537]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":7, "position": np.array([-0.27412-0.16, -0.61531, 0.25146]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.656, 5.497, 0.492]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([0.5+0.16, -0.112, 0.410]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.364, 5, 0.651]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":5, "position": np.array([0.46203+0.16, -0.76392, 0.15278]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.32833, 5.65751, 0.3945]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":6, "position": np.array([0.65863+0.16, -0.76392, 0.15278]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.52493, 5.65751, 0.3945]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":7, "position": np.array([0.46203+0.16, -0.76392, 0.15278]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.32833, 5.65751, 0.3945]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":8, "position": np.array([0.35597, -0.15914, -0.16+0.48217]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-16.221, 5.05282, 0.725]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":9, "position": np.array([0.16394, 0.68797, 0.64637]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.0297, 4.20519, 1.04836]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}]
self.util.move_ur10_extra(motion_plan, "_wheel")
if self.util.motion_task_counterl==2 and not self.bool_done[7]:
self.bool_done[7] = True
self.util.remove_part("World/Environment", f"wheel_01_{self.id}")
self.util.add_part_custom("World/UR10_wheel/ee_link","FWheel", f"qwheel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counterl==7 and not self.bool_done[8]:
self.bool_done[8] = True
print("Done placing wheel")
self.util.remove_part("World/UR10_wheel/ee_link", f"qwheel_01_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","FWheel", f"xwheel_01_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.1522, 0.33709, 0.56377]), np.array([0.5, -0.5, 0.5, -0.5]))
if self.util.motion_task_counterl==10:
self.util.motion_task_counterl=0
return True
return False
def screw_wheel(self):
motion_plan = [{"index":0, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([-0.67966, -0.08051, -0.16+0.44283]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":3, "position": np.array([0.67955-0.1+0.16, 0.62439, 0.22894]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.67963, 0.4704]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":4, "position": np.array([0.67955+0.16, 0.62439, 0.22894]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236, 5.67963, 0.4704]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":5, "position": np.array([0.67955-0.1+0.16, 0.62439, 0.22894]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.67963, 0.4704]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":6, "position": np.array([-0.67572, 0.09613, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18675, 6.20788, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":7, "position": np.array([-0.67572, 0.09613, -0.16+0.44283]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18675, 6.20788, 0.68279]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":8, "position": np.array([-0.67572, 0.09613, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18675, 6.20788, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":9, "position": np.array([0.67955-0.1+0.16, 0.67241, 0.23225]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.6316, 0.47372]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":10, "position": np.array([0.67955+0.16, 0.67241, 0.23225]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236, 5.6316, 0.47372]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":11, "position": np.array([0.67955-0.1+0.16, 0.67241, 0.23225]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.6316, 0.47372]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":12, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":13, "position": np.array([-0.67966, -0.08051, -0.16+0.44283]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":14, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":15, "position": np.array([0.67955-0.1+0.16, 0.64605, 0.27773]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.65797, 0.51919]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":16, "position": np.array([0.67955+0.16, 0.64605, 0.27773]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236, 5.65797, 0.51919]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":17, "position": np.array([0.67955-0.1+0.16, 0.64605, 0.27773]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.65797, 0.51919]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":18, "position": np.array([-0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}]
self.util.do_screw_driving_extra(motion_plan,"_wheel")
if self.util.motion_task_counterl==19:
print("Done screwing wheel")
self.util.motion_task_counterl=0
return True
return False
def move_ahead_in_wheel_cell(self):
print(self.util.path_plan_counter)
path_plan = [
["translate", [5.04, 1, False]]
]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_wheel_03(self):
motion_plan = [{"index":0, "position": np.array([0.86671, -0.54558, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.79517, 4.90661+0.521, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([0.86671, -0.54558, -0.16+0.4353]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.79517, 4.90661+0.521, 0.67666]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([0.86671, -0.54558, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.79517, 4.90661+0.521, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([0.00762, 0.77686, -0.16+0.48217]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.935, 4.105, 0.723]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":4, "position": np.array([-0.31937-0.16, -0.78789, 0.0258]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.596, 5.671, 0.274]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":5, "position": np.array([-0.47413-0.16, -0.78789, 0.0258]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.42945, 5.671, 0.274]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":6, "position": np.array([-0.31937-0.16, -0.78789, 0.0258]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.596, 5.671, 0.274]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":7, "position": np.array([-0.35597, -0.15914, -0.16+0.48217]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.572, 5.04127, 0.723]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":8, "position": np.array([0.00762, 0.77686, -0.16+0.48217]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.935, 4.105, 0.723]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":9, "position": np.array([0.16345, 0.69284, 0.62942-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.09182, 4.18911, 0.87105]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}]
self.util.move_ur10(motion_plan, "_wheel_01")
if self.util.motion_task_counter==2 and not self.bool_done[9]:
self.bool_done[9] = True
self.util.remove_part("World/Environment", f"wheel_04_{self.id}")
self.util.add_part_custom("World/UR10_wheel_01/ee_link","FWheel", f"qwheel_04_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counter==5 and not self.bool_done[10]:
self.bool_done[10] = True
print("Done placing wheel")
self.util.remove_part("World/UR10_wheel_01/ee_link", f"qwheel_04_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","FWheel", f"xwheel_04_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.80845, -0.22143, 0.43737]), np.array([0.5, -0.5, 0.5, -0.5]))
if self.util.motion_task_counter==10:
self.util.motion_task_counter=0
return True
return False
def screw_wheel_03(self):
motion_plan = [{"index":0, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.67966, -0.08619, -0.16+0.44283]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":3, "position": np.array([-0.49561+0.1-0.16, 0.61097, 0.22823-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.68598, 0.46965-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":4, "position": np.array([-0.49561-0.16, 0.61097, 0.22823-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516, 5.68598, 0.46965-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":5, "position": np.array([-0.49561+0.1-0.16, 0.61097, 0.22823-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.68598, 0.46965-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":6, "position": np.array([0.67966, 0.09013, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.20682, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":7, "position": np.array([0.67966, 0.09013, -0.16+0.44283]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.20682, 0.68464]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":8, "position": np.array([0.67966, 0.09013, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.20682, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":9, "position": np.array([-0.49561+0.1-0.16, 0.66261, 0.23808-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.63434, 0.47951-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":10, "position": np.array([-0.49561-0.16, 0.66261, 0.23808-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516, 5.63434, 0.47951-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":11, "position": np.array([-0.49561+0.1-0.16, 0.66261, 0.23808-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.63434, 0.47951-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":12, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":13, "position": np.array([0.67966, -0.08619, -0.16+0.44283]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":14, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":15, "position": np.array([-0.49561+0.1-0.16, 0.6234, 0.27624-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.67355, 0.51766-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":16, "position": np.array([-0.49561-0.16, 0.6234, 0.27624-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516, 5.67355, 0.51766-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":17, "position": np.array([-0.49561+0.1-0.16, 0.6234, 0.27624-0.12]), "orientation": np.array([0,0,1,0]), "goal_position":np.array([-17.43516-0.1, 5.67355, 0.51766-0.12]), "goal_orientation":np.array([0, -1, 0, 0])},
{"index":18, "position": np.array([0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.61058, 6.38314, 0.68464+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}]
self.util.do_screw_driving(motion_plan,"_wheel_01")
if self.util.motion_task_counter==19:
print("Done screwing wheel")
self.util.motion_task_counter=0
return True
return False
def arm_place_wheel_02(self):
tire_offset = 0.52214
motion_plan = [{"index":0, "position": np.array([-0.86671, -0.53748, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.99517, 4.90661+0.512, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":1, "position": np.array([-0.86671, -0.53748, -0.16+0.4353]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.99517, 4.90661+0.512, 0.67666]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":2, "position": np.array([-0.86671, -0.53748, -0.16+0.4353+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.99517, 4.90661+0.512, 0.67666+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":3, "position": np.array([-0.00762, 0.77686, -0.16+0.48217]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-15.858, 4.105, 0.723]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
# {"index":4, "position": np.array([-0.39779, 0.19418, -0.16+0.51592]), "orientation": np.array([0.62501, -0.3307, 0.62501, 0.3307]), "goal_position":np.array([-17.53, 4.68, 0.758]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":5, "position": np.array([-0.35597, -0.15914, -0.16+0.48217]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.572, 5.04127, 0.723]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":6, "position": np.array([-0.48413-0.16, -0.28768, 0.29642]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.446, 5.16, 0.537]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":7, "position": np.array([-0.27412-0.16, -0.61531, 0.25146]), "orientation": np.array([0, 0, 0.70711, 0.70711]), "goal_position":np.array([-17.656, 5.497, 0.492]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([0.5+0.16, -0.112, 0.410]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.364, 5, 0.651]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":5, "position": np.array([0.46203+0.16, -0.76392, 0.0258]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.32833, 5.65751, 0.274]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":6, "position": np.array([0.65863+0.16, -0.76392, 0.0258]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.52493, 5.65751, 0.274]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])},
{"index":7, "position": np.array([0.46203+0.16, -0.76392, 0.0258]), "orientation": np.array([0.70711, 0.70711, 0, 0]), "goal_position":np.array([-16.32833, 5.65751, 0.274]), "goal_orientation":np.array([0.70711, 0.70711, 0, 0])},
{"index":8, "position": np.array([0.35597, -0.15914, -0.16+0.48217]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-16.221, 5.05282, 0.725]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":9, "position": np.array([-0.00762, 0.77686, -0.16+0.48217]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-15.858, 4.105, 0.723]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":10, "position": np.array([0.16286, 0.68548, 0.63765-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.02865, 4.20818, 0.87901]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
# {"index":11, "position": np.array([-0.87307, -0.01687-tire_offset, 0.436-0.16+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-14.9927, 4.91057+tire_offset, 0.67736+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])}
]
self.util.move_ur10_extra(motion_plan, "_wheel")
if self.util.motion_task_counterl==2 and not self.bool_done[11]:
self.bool_done[11] = True
self.util.remove_part("World/Environment", f"wheel_02_{self.id}")
self.util.add_part_custom("World/UR10_wheel/ee_link","FWheel", f"qwheel_02_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.25604, -0.18047, -0.18125]), np.array([0, 0, 0.70711, 0.70711]))
if self.util.motion_task_counterl==7 and not self.bool_done[12]:
self.bool_done[12] = True
print("Done placing wheel")
self.util.remove_part("World/UR10_wheel/ee_link", f"qwheel_02_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","FWheel", f"xwheel_02_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.80934, 0.35041, 0.43888]), np.array([0.5, -0.5, 0.5, -0.5]))
if self.util.motion_task_counterl==11:
self.util.motion_task_counterl=0
return True
return False
def screw_wheel_02(self):
motion_plan = [{"index":0, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([-0.67966, -0.08051, -0.16+0.44283]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":3, "position": np.array([0.67955-0.1+0.16, 0.62439, 0.22894-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.67963, 0.4704-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":4, "position": np.array([0.67955+0.16, 0.62439, 0.22894-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236, 5.67963, 0.4704-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":5, "position": np.array([0.67955-0.1+0.16, 0.62439, 0.22894-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.67963, 0.4704-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":6, "position": np.array([-0.67572, 0.09613, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18675, 6.20788, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":7, "position": np.array([-0.67572, 0.09613, -0.16+0.44283]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18675, 6.20788, 0.68279]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":8, "position": np.array([-0.67572, 0.09613, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18675, 6.20788, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":9, "position": np.array([0.67955-0.1+0.16, 0.67241, 0.23225-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.6316, 0.47372-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":10, "position": np.array([0.67955+0.16, 0.67241, 0.23225-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236, 5.6316, 0.47372-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":11, "position": np.array([0.67955-0.1+0.16, 0.67241, 0.23225-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.6316, 0.47372-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":12, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":13, "position": np.array([-0.67966, -0.08051, -0.16+0.44283]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":14, "position": np.array([-0.67966, -0.08051, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":15, "position": np.array([0.67955-0.1+0.16, 0.64605, 0.27773-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.65797, 0.51919-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":16, "position": np.array([0.67955+0.16, 0.64605, 0.27773-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236, 5.65797, 0.51919-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":17, "position": np.array([0.67955-0.1+0.16, 0.64605, 0.27773-0.12]), "orientation": np.array([0,-1,0,0]), "goal_position":np.array([-16.54236+0.1, 5.65797, 0.51919-0.12]), "goal_orientation":np.array([0, 0, 1, 0])},
{"index":18, "position": np.array([-0.67966, -0.08619, -0.16+0.44283+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-15.18282, 6.38452, 0.68279+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}]
self.util.do_screw_driving_extra(motion_plan,"_wheel")
if self.util.motion_task_counterl==19:
print("Done screwing wheel")
self.util.motion_task_counterl=0
return True
return False
def arm_place_fwheel_together(self):
if not self.right_side:
self.right_side = self.arm_place_wheel_01()
if not self.left_side:
self.left_side = self.arm_place_wheel()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def screw_fwheel_together(self):
if not self.right_side:
self.right_side = self.screw_wheel_01()
if not self.left_side:
self.left_side = self.screw_wheel()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def arm_place_bwheel_together(self):
if not self.right_side:
self.right_side = self.arm_place_wheel_03()
if not self.left_side:
self.left_side = self.arm_place_wheel_02()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def screw_bwheel_together(self):
if not self.right_side:
self.right_side = self.screw_wheel_03()
if not self.left_side:
self.left_side = self.screw_wheel_02()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def move_to_lower_cover_cell(self):
print(self.util.path_plan_counter)
# path_plan = [
# ["rotate", [np.array([0.73548, 0, 0, -0.67755]), 0.0042, False]],
# ["translate", [-0.64, 1, False]],
# ["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, True]],
# ["translate", [-12.037, 1, False]],
# ["rotate", [np.array([0, 0, 0, -1]), 0.0042, True]],
# ["translate", [-20.15, 0, False]],
# ["rotate", [np.array([0.70711, 0, 0, -0.70711]), 0.0042, False]],
# ["translate", [-17, 1, False]],
# ["rotate", [np.array([0, 0, 0, 1]), 0.0042, True]],
# ["translate", [-26.9114, 0, False]]]
path_plan = [
["rotate", [np.array([-0.73548, 0, 0, 0.67755]), 0.0042, False]],
["wait",[]],
["translate", [-0.64, 1, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, True]],
["wait",[]],
["translate", [-12.1, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, True]],
["wait",[]],
["translate", [-21.13755, 0, False]], # 20.2 earlier
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, False]],
["wait",[]],
["translate", [-17.1, 1, False]],
["translate", [-17.34, 1, False]],
["wait",[]],
["rotate", [np.array([0, 0, 0, 1]), 0.0042, True]],
["wait",[]],
["translate", [-26.9114, 0, False]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_lower_cover(self):
motion_plan = [
# {"index":0, "position": np.array([-0.49105, 0.76464, -0.16+0.4434+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.49436, 0.6851+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
# {"index":1, "position": np.array([-0.49105, 0.76464, -0.16+0.4434]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.49436, 0.6851]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
# {"index":2, "position": np.array([-0.49105, 0.76464, -0.16+0.4434+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.49436, 0.6851+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
*self.lower_cover[0],
{"index":3, "position": np.array([-0.70739, -0.00943, -0.16+0.52441]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-26.76661, -16.26838, 0.76611]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":4, "position": np.array([-0.59828, -0.85859, -0.16+0.36403+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-26.65756, -17.11785, 0.60573+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":5, "position": np.array([-0.59828, -0.85859, -0.16+0.36403]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-26.65756, -17.11785, 0.60573]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":6, "position": np.array([-0.59828, -0.85859, -0.16+0.36403+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-26.65756, -17.11785, 0.60573+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":7, "position": np.array([-0.49105, 0.76464, -0.16+0.4434+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.54994, -15.49436, 0.6851+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
# {"index":8, "position": np.array([0.16286, 0.68548, 0.63765-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-25.8962, -15.5737, 0.879938]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}
{"index":8, "position": np.array([0.54581, 0.04547, 0.73769-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-25.5133, -16.2136, 0.9801]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}
]
self.util.move_ur10(motion_plan, "_lower_cover")
if self.util.motion_task_counter==2 and not self.bool_done[20]:
self.bool_done[20] = True
self.util.remove_part("World/Environment", f"lower_coverr_{self.id}")
self.util.add_part_custom("World/UR10_lower_cover/ee_link","lower_cover", f"qlower_coverr_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.27893, -0.08083, 0.29584]), np.array([0.5, -0.5, 0.5, 0.5]))
if self.util.motion_task_counter==6 and not self.bool_done[21]:
self.bool_done[21] = True
print("Done placing right lower cover")
self.util.remove_part("World/UR10_lower_cover/ee_link", f"qlower_coverr_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","lower_cover", f"xlower_coverr_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.03325, -0.29278, 0.31255]), np.array([0, 0, 0.70711, 0.70711]))
# np.array([435.65021, 418.57531,21.83379]), np.array([0.50942, 0.50942,0.4904, 0.4904])
if self.util.motion_task_counter==9:
self.util.motion_task_counter=0
return True
return False
def screw_lower_cover(self):
motion_plan = [{"index":0, "position": np.array([0.00434, 0.77877, -0.16+0.43196+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.48421, -15.4803, 0.67396+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([0.00434, 0.77877, -0.16+0.43196]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.48421, -15.4803, 0.67396]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([0.00434, 0.77877, -0.16+0.43196+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.48421, -15.4803, 0.67396+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":3, "position": np.array([0.71996, -0.73759, -0.16+0.26658+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76846, -16.99645, 0.50858+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([0.71996, -0.73759, -0.16+0.26658]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76846, -16.99645, 0.50858]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":5, "position": np.array([0.71996, -0.73759, -0.16+0.26658+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76846, -16.99645, 0.50858+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":6, "position": np.array([-0.17139, 0.78152, -0.16+0.43196+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.65994, -15.47755, 0.67396+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":7, "position": np.array([-0.17139, 0.78152, -0.16+0.43196]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.65994, -15.47755, 0.67396]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":8, "position": np.array([-0.17139, 0.78152, -0.16+0.43196+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.65994, -15.47755, 0.67396+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":9, "position": np.array([0.71996, -0.80562, -0.16+0.26658+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76846, -17.06448, 0.50858+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":10, "position": np.array([0.71996, -0.80562, -0.16+0.26658]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76846, -17.06448, 0.50858]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":11, "position": np.array([0.71996, -0.80562, -0.16+0.26658+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76846, -17.06448, 0.50858+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":12, "position": np.array([0.00434, 0.77877, -0.16+0.43196+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.48421, -15.4803, 0.67396+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}]
self.util.do_screw_driving(motion_plan,"_lower_cover")
if self.util.motion_task_counter==13:
print("Done screwing right lower cover")
self.util.motion_task_counter=0
return True
return False
def arm_place_lower_cover_01(self):
motion_plan = [
# {"index":0, "position": np.array([0.49458, 0.74269, -0.16+0.44428+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.06174, 0.68566+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
# {"index":1, "position": np.array([0.49458, 0.74269, -0.16+0.44428]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.06174, 0.68566]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
# {"index":2, "position": np.array([0.49458, 0.74269, -0.16+0.44428+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.06174, 0.68566+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
*self.lower_cover[1],
{"index":3, "position": np.array([0.79817, 0.02534, -0.16+0.58377]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.85719, -18.34429, 0.82514]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":4, "position": np.array([0.59724, -0.78253, -0.16+0.36033+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-26.65614, -17.53666, 0.6017+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":5, "position": np.array([0.59724, -0.78253, -0.16+0.36033]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-26.65614, -17.53666, 0.6017]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":6, "position": np.array([0.59724, -0.78253, -0.16+0.36033+0.2]), "orientation": np.array([0, -0.70711, 0, 0.70711]), "goal_position":np.array([-26.65614, -17.53666, 0.6017+0.2]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":7, "position": np.array([0.49458, 0.74269, -0.16+0.44428+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.55383, -19.06174, 0.68566+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
# {"index":8, "position": np.array([0.16286, 0.68548, 0.63765-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-26.222, -19.0046, 0.879939]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}
{"index":8, "position": np.array([-0.54581, 0.04547, 0.73769-0.16]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-25.513, -18.3647, 0.98016]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])}
]
self.util.move_ur10_extra(motion_plan, "_lower_cover_01")
if self.util.motion_task_counterl==2 and not self.bool_done[22]:
self.bool_done[22] = True
self.util.remove_part("World/Environment", f"lower_coverl_{self.id}")
self.util.add_part_custom("World/UR10_lower_cover_01/ee_link","lower_cover", f"qlower_coverl_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.28058, 0.07474, -0.29292]), np.array([0.5, 0.5, -0.5, 0.5]))
if self.util.motion_task_counterl==6 and not self.bool_done[23]:
self.bool_done[23] = True
print("Done placing right lower cover")
self.util.remove_part("World/UR10_lower_cover_01/ee_link", f"qlower_coverl_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","lower_cover", f"xlower_coverl_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.03589, 0.13349, 0.30227]), np.array([0, 0, -0.70711, -0.70711]))
if self.util.motion_task_counterl==9:
self.util.motion_task_counterl=0
return True
return False
def screw_lower_cover_01(self):
motion_plan = [{"index":0, "position": np.array([-0.00975, 0.77293, -0.16+0.42757+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.46819, -19.08897, 0.66977+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([-0.00975, 0.77293, -0.16+0.42757]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.46819, -19.08897, 0.66977]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([-0.00975, 0.77293, -0.16+0.42757+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.46819, -19.08897, 0.66977+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":3, "position": np.array([-0.71345, -0.63679, -0.16+0.26949+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.681, 0.51169+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([-0.71345, -0.63679, -0.16+0.26949]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.681, 0.51169]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":5, "position": np.array([-0.71345, -0.63679, -0.16+0.26949+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.681, 0.51169+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":6, "position": np.array([-0.18665, 0.77293, -0.16+0.42757+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.29128, -19.08897, 0.66977+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":7, "position": np.array([-0.18665, 0.77293, -0.16+0.42757]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.29128, -19.08897, 0.66977]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":8, "position": np.array([-0.18665, 0.77293, -0.16+0.42757+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.29128, -19.08897, 0.66977+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":9, "position": np.array([-0.00975, 0.77293, -0.16+0.42757+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.46819, -19.08897, 0.66977+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":10, "position": np.array([-0.71345, -0.63679, -0.16+0.26949+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.681, 0.51169+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":11, "position": np.array([-0.71345, -0.68679, -0.16+0.26949+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.681+0.05, 0.51169+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":12, "position": np.array([-0.71345, -0.68679, -0.16+0.26949]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.681+0.05, 0.51169]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":13, "position": np.array([-0.71345, -0.68679, -0.16+0.26949+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.681+0.05, 0.51169+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":9, "position": np.array([-0.71345, -0.70416, -0.16+0.26949+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.61363, 0.51169+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":10, "position": np.array([-0.71345, -0.70416, -0.16+0.26949]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.61363, 0.51169]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":11, "position": np.array([-0.71345, -0.70416, -0.16+0.26949+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-26.76467, -17.61363, 0.51169+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":14, "position": np.array([-0.00975, 0.77293, -0.16+0.42757+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-27.46819, -19.08897, 0.66977+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}]
self.util.do_screw_driving_extra(motion_plan,"_lower_cover_01")
if self.util.motion_task_counterl==15:
print("Done screwing right lower cover")
self.util.motion_task_counterl=0
return True
return False
def arm_place_lower_cover_together(self):
if not self.right_side:
self.right_side = self.arm_place_lower_cover()
if not self.left_side:
self.left_side = self.arm_place_lower_cover_01()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def screw_lower_cover_together(self):
if not self.right_side:
self.right_side = self.screw_lower_cover()
if not self.left_side:
self.left_side = self.screw_lower_cover_01()
if self.left_side and self.right_side:
self.left_side = self.right_side = False
return True
return False
def move_to_main_cover_cell(self):
print(self.util.path_plan_counter)
# path_plan = [
# ["translate", [-27.9, 0, False]],
# ["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, False]],
# ["translate", [-17.18, 1, True]]]
path_plan = [
["translate", [-28.6, 0, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, False]],
["wait",[]],
["translate", [-17.18, 1, True]]]
if self.id == 0:
path_plan = [
["translate", [-28.7, 0, False]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, False]],
["wait",[]],
["translate", [-17.18, 1, True]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_main_cover(self):
motion_plan = [
# {'index': 15, 'position': np.array([-0.74286, 0.42878, 0.35038]), 'orientation': np.array([ 0.6511, -0.2758, 0.6511, 0.2758]), 'goal_position': np.array([-29.14515, -16.32381, 1.33072]), 'goal_orientation': np.array([ 0.65542, 0.26538, 0.65542, -0.26538])},
# {'index': 16, 'position': np.array([-0.89016, 0.32513, 0.35038]), 'orientation': np.array([ 0.60698, -0.36274, 0.60698, 0.36274]), 'goal_position': np.array([-29.24913, -16.1764 , 1.33072]), 'goal_orientation': np.array([ 0.68569, 0.1727 , 0.68569, -0.1727 ])},
# {'index': 17, 'position': np.array([-1.09352, -0.27789, 0.42455]), 'orientation': np.array([ 0.5, -0.5, 0.5, 0.5]), 'goal_position': np.array([-29.85252, -15.97435, 1.40075]), 'goal_orientation': np.array([0.70711, 0. , 0.70711, 0. ])},
{"index":0, "position": np.array([-1.09352, -0.27789, 0.58455-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.01444-11.83808, -15.97435, 1.40075]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":1, "position": np.array([-1.09352, -0.27789, 0.19772-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.01444-11.83808, -15.97435, 1.01392]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":2, "position": np.array([-1.09352, -0.27789, 0.58455-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.01444-11.83808, -15.97435, 1.40075]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
{"index":3, "position": np.array([-0.89016, 0.32513, 0.51038-0.16]), "orientation": np.array([0.60698, -0.36274, 0.60698, 0.36274]), "goal_position":np.array([-17.41105-11.83808, -16.1764, 1.33072]), "goal_orientation":np.array([0.68569, 0.1727, 0.68569, -0.1727])},
{"index":4, "position": np.array([-0.74286, 0.42878, 0.51038-0.16]), "orientation": np.array([0.6511, -0.2758, 0.6511, 0.2758]), "goal_position":np.array([-17.30707-11.83808, -16.32381, 1.33072]), "goal_orientation":np.array([0.65542, 0.26538, 0.65542, -0.26538])},
{"index":5, "position": np.array([-0.5015, 0.55795, 0.51038-0.16]), "orientation": np.array([0.6954, -0.12814, 0.6954, 0.12814]), "goal_position":np.array([-17.17748-11.83808, -16.5655, 1.33072]), "goal_orientation":np.array([0.58233, 0.40111, 0.58233, -0.40111])},
{"index":6, "position": np.array([-0.28875, 0.74261, 0.51038-0.16]), "orientation": np.array([0.70458, -0.0597, 0.70458, 0.0597]), "goal_position":np.array([-16.99268-11.83808, -16.77844, 1.33072]), "goal_orientation":np.array([0.54043, 0.456, 0.54043, -0.456])},
{"index":7, "position": np.array([0.11095-0.11, 0.94, 0.49096-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 1.31062]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":8, "position": np.array([0.11095-0.11, 0.94, 0.2926-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 1.11226]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":9, "position": np.array([0.11095-0.11, 0.94, 0.19682-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 1.01648]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":10, "position": np.array([0.11095-0.11, 0.94, 0.15697-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 0.97663]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":11, "position": np.array([0.11095-0.11, 0.94, 0.11895-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 0.93861]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":12, "position": np.array([0.11095-0.11, 0.94, 0.07882-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995+0.11, 0.89848]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":13, "position": np.array([0.11095, 0.94627, 0.49096-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175-11.83808, -17.17995, 1.31062]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])},
{"index":14, "position": np.array([-0.28875, 0.74261, 0.51038-0.16]), "orientation": np.array([0.70458, -0.0597, 0.70458, 0.0597]), "goal_position":np.array([-16.99268-11.83808, -16.77844, 1.33072]), "goal_orientation":np.array([0.54043, 0.456, 0.54043, -0.456])},
{"index":15, "position": np.array([-0.5015, 0.55795, 0.51038-0.16]), "orientation": np.array([0.6954, -0.12814, 0.6954, 0.12814]), "goal_position":np.array([-17.17748-11.83808, -16.5655, 1.33072]), "goal_orientation":np.array([0.58233, 0.40111, 0.58233, -0.40111])},
# {"index":16, "position": np.array([-0.74286, 0.42878, 0.51038-0.16]), "orientation": np.array([0.6511, -0.2758, 0.6511, 0.2758]), "goal_position":np.array([-17.30707-11.83808, -16.32381, 1.33072]), "goal_orientation":np.array([0.65542, 0.26538, 0.65542, -0.26538])},
# {"index":17, "position": np.array([-0.89016, 0.32513, 0.51038-0.16]), "orientation": np.array([0.60698, -0.36274, 0.60698, 0.36274]), "goal_position":np.array([-17.41105-11.83808, -16.1764, 1.33072]), "goal_orientation":np.array([0.68569, 0.1727, 0.68569, -0.1727])},
# {"index":18, "position": np.array([-1.09352, -0.27789, 0.58455-0.16]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-18.01444-11.83808, -15.97435, 1.40075]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])},
# {'index': 19, 'position': np.array([-0.89016, 0.32513, 0.35038]), 'orientation': np.array([ 0.60698, -0.36274, 0.60698, 0.36274]), 'goal_position': np.array([-29.24913, -16.1764 , 1.33072]), 'goal_orientation': np.array([ 0.68569, 0.1727 , 0.68569, -0.1727 ])},
# {'index': 20, 'position': np.array([-0.74286, 0.42878, 0.35038]), 'orientation': np.array([ 0.6511, -0.2758, 0.6511, 0.2758]), 'goal_position': np.array([-29.14515, -16.32381, 1.33072]), 'goal_orientation': np.array([ 0.65542, 0.26538, 0.65542, -0.26538])},
# {"index": 21, "position": np.array([-0.5015, 0.55795, 0.51038-0.16]), "orientation": np.array([0.6954, -0.12814, 0.6954, 0.12814]), "goal_position":np.array([-17.17748-11.83808, -16.5655, 1.33072]), "goal_orientation":np.array([0.58233, 0.40111, 0.58233, -0.40111])},
{"index": 16, "position": np.array([-0.5015, 0.55795, 0.51038-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.17748-11.83808, -16.5655, 1.33072]), "goal_orientation":np.array([0.58233, 0.40111, 0.58233, -0.40111])}]
# {'index': 22, 'position': np.array([0.16394, 0.68799, 0.44663]), 'orientation': np.array([ 0.70711, 0, 0.70711, 0]), 'goal_position': np.array([-28.88652, -17.23535, 1.42725]), 'goal_orientation': np.array([0.70711, 0. , 0.70711, 0. ])}]
self.util.move_ur10(motion_plan, "_main_cover")
# remove world main cover and add ee main cover
if self.util.motion_task_counter==2 and not self.bool_done[24]:
self.bool_done[24] = True
self.util.remove_part("World/Environment", f"main_cover_{self.id}")
if self.id%2==0:
self.util.add_part_custom("World/UR10_main_cover/ee_link","main_cover", f"qmain_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.71735, 0.26961, -0.69234]), np.array([0.5, 0.5, -0.5, 0.5]))
else:
self.util.add_part_custom("World/UR10_main_cover/ee_link","main_cover_orange", f"qmain_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.71735, 0.26961, -0.69234]), np.array([0.5, 0.5, -0.5, 0.5]))
# remove ee main cover and add mobile platform main cover
if self.util.motion_task_counter==13 and not self.bool_done[25]:
self.bool_done[25] = True
self.util.remove_part("World/UR10_main_cover/ee_link", f"qmain_cover_{self.id}")
if self.id%2==0:
self.util.add_part_custom(f"mock_robot_{self.id}/platform","main_cover", f"xmain_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.81508, 0.27909, 0.19789]), np.array([0.70711, 0.70711, 0, 0]))
else:
self.util.add_part_custom(f"mock_robot_{self.id}/platform","main_cover_orange", f"xmain_cover_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.81508, 0.27909, 0.19789]), np.array([0.70711, 0.70711, 0, 0]))
if self.util.motion_task_counter==17:
print("Done placing main cover")
self.util.motion_task_counter=0
return True
return False
def move_to_handle_cell(self):
print(self.util.path_plan_counter)
# path_plan = [
# ["translate", [-13.2, 1, True]],
# ["rotate", [np.array([-0.56641, 0, 0, 0.82413]), 0.0042, True]],
# ["translate", [-10.46, 1, True]],
# ["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, False]],
# ["translate", [-6.69, 1, True]]]
path_plan = [
["translate", [-13.2, 1, True]],
["wait",[]],
["rotate", [np.array([-0.56641, 0, 0, 0.82413]), 0.0042, True]],
["wait",[]],
# ["translate", [-10.46, 1, True]],
# ["translate", [-10.3, 1, True]],
["translate", [-10.43, 1, True]],
["wait",[]],
["rotate", [np.array([-0.70711, 0, 0, 0.70711]), 0.0042, False]],
["wait",[]],
["translate", [-6.69, 1, True]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_handle(self):
motion_plan = [{"index":0, "position": np.array([0.83713, -0.36166, -0.16+0.31902+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-29.33969, -6.83473, 0.56077+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":1, "position": np.array([0.83713, -0.36166, -0.16+0.31902]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-29.33969, -6.83473, 0.56077]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":2, "position": np.array([0.83713, -0.36166, -0.16+0.31902+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-29.33969, -6.83473, 0.56077+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":3, "position": np.array([-0.00141, 0.74106, -0.16+0.61331]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-28.5011, -7.93748, 0.85506]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([-1.01604+0.07, -0.16743-0.09, -0.13+0.76104]), "orientation": np.array([0.34531, -0.61706, 0.61706, 0.34531]), "goal_position":np.array([-27.48648-0.07, -7.02902, 1.00275]), "goal_orientation":np.array([-0.34531, -0.61706, -0.61706, 0.34531])},
{"index":5, "position": np.array([-1.01604+0.07, -0.26045-0.09, -0.13+0.7032]), "orientation": np.array([0.34531, -0.61706, 0.61706, 0.34531]), "goal_position":np.array([-27.48648-0.07, -6.93599, 0.94492]), "goal_orientation":np.array([-0.34531, -0.61706, -0.61706, 0.34531])},
{"index":6, "position": np.array([-1.01604+0.07, -0.16743-0.09, -0.13+0.76104]), "orientation": np.array([0.34531, -0.61706, 0.61706, 0.34531]), "goal_position":np.array([-27.48648-0.07, -7.02902, 1.00275]), "goal_orientation":np.array([-0.34531, -0.61706, -0.61706, 0.34531])},
{"index":7, "position": np.array([-0.00141, 0.74106, -0.16+0.61331]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-28.5011, -7.93748, 0.85506]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])}]
self.util.move_ur10(motion_plan, "_handle")
if self.util.motion_task_counter==2 and not self.bool_done[26]:
self.bool_done[26] = True
self.util.remove_part("World/Environment", f"handle_{self.id}")
self.util.add_part_custom("World/UR10_handle/ee_link","handle", f"qhandle_{self.id}", np.array([0.001,0.001,0.001]), np.array([-0.5218, 0.42317, 0.36311]), np.array([0.5, -0.5, 0.5, -0.5]))
if self.util.motion_task_counter==6 and not self.bool_done[27]:
self.bool_done[27] = True
print("Done placing handle")
self.util.remove_part("World/UR10_handle/ee_link", f"qhandle_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","handle", f"xhandle_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.82439, 0.44736, 1.16068]), np.array([0.20721, 0.68156, -0.67309, -0.19874]))
if self.util.motion_task_counter==8:
self.util.motion_task_counter=0
return True
return False
def screw_handle(self):
motion_plan = [{"index":0, "position": np.array([-0.78213, -0.03592, -0.16+0.4263+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-25.91341, -6.95701, 0.66945+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":1, "position": np.array([-0.78213, -0.03592, -0.16+0.4263]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-25.91341, -6.95701, 0.66945]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":2, "position": np.array([-0.78213, -0.03592, -0.16+0.4263+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-25.91341, -6.95701, 0.66945+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":3, "position": np.array([0.7448+0.13899, -0.02487, -0.16+0.7457+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-27.4413-0.13899, -6.96836, 0.98886+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":4, "position": np.array([0.7448+0.13899, -0.02487, -0.16+0.7457]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-27.4413-0.13899, -6.96836, 0.98886]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":5, "position": np.array([0.7448+0.13899, -0.02487, -0.16+0.7457+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-27.4413-0.13899, -6.96836, 0.98886+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":6, "position": np.array([-0.77943, -0.21316, -0.16+0.4263+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-25.91611, -6.77978, 0.66945+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":7, "position": np.array([-0.77943, -0.21316, -0.16+0.4263]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-25.91611, -6.77978, 0.66945]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":8, "position": np.array([-0.77943, -0.21316, -0.16+0.4263+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-25.91611, -6.77978, 0.66945+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":9, "position": np.array([0.83599-0.024, -0.02487, -0.16+0.7457+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-27.53249+0.024, -6.96836, 0.98886+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":10, "position": np.array([0.83599-0.024, -0.02487, -0.16+0.7457]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-27.53249+0.024, -6.96836, 0.98886]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":11, "position": np.array([0.83599-0.024, -0.02487, -0.16+0.7457+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-27.53249+0.024, -6.96836, 0.98886+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
{"index":12, "position": np.array([-0.77943, -0.21316, -0.16+0.4263+0.2]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-25.91611, -6.77978, 0.66945+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])}]
self.util.do_screw_driving(motion_plan,"_handle")
if self.util.motion_task_counter==13:
print("Done screwing handle")
self.util.motion_task_counter=0
return True
return False
def move_to_light_cell(self):
print(self.util.path_plan_counter)
# path_plan = [["translate", [-6.41, 1, True]],
# ["rotate", [np.array([-1, 0, 0, 0]), 0.0042, False]],
# ["translate", [-18.56, 0, False]]]
path_plan = [["translate", [-5.8, 1, True]],
["wait",[]],
# ["rotate", [np.array([-1, 0, 0, 0]), 0.008, False]],
["rotate", [np.array([-1, 0, 0, 0]), 0.0042, False]],
["wait",[]],
["translate", [-18.56, 0, False]]]
if self.id==1 or self.id==2:
path_plan = [["translate", [-5.77, 1, True]],
["wait",[]],
# ["rotate", [np.array([-1, 0, 0, 0]), 0.008, False]],
["rotate", [np.array([-1, 0, 0, 0]), 0.0042, False]],
["wait",[]],
["translate", [-18.56, 0, False]]]
if self.id==6:
path_plan = [["translate", [-5.85, 1, True]],
["wait",[]],
# ["rotate", [np.array([-1, 0, 0, 0]), 0.008, False]],
["rotate", [np.array([-1, 0, 0, 0]), 0.0042, False]],
["wait",[]],
["translate", [-18.56, 0, False]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def arm_place_light(self):
if not self.bool_done[30]:
self.bool_done[30] = True
motion_plan = [{"index":0, "position": np.array([0.03769, -0.74077, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.06964, -4.37873, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])}]
self.util.do_screw_driving(motion_plan, "_light")
self.util.motion_task_counter=0
light_offset=0.1098
motion_plan = [
# {"index":0, "position": np.array([0.5517, 0.68287, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.23584, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# {"index":1, "position": np.array([0.5517, 0.68287, -0.16+0.34371]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.23584, 0.58583]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
# {"index":2, "position": np.array([0.5517, 0.68287, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.23584, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])},
*self.light,
{"index":3, "position": np.array([-0.57726, -0.00505, -0.16+0.65911]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.25466, -6.54783, 0.90123]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":4, "position": np.array([0.32558+0.12, -0.65596+0.04105-light_offset, -0.16+0.65947]), "orientation": np.array([0.65861, -0.65861, 0.25736, 0.25736]), "goal_position":np.array([-18.15724, -5.8969-0.04105, 0.90133]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":5, "position": np.array([0.36852+0.12, -0.65596+0.04105-light_offset, -0.16+0.61986]), "orientation": np.array([0.65861, -0.65861, 0.25736, 0.25736]), "goal_position":np.array([-18.2, -5.8969-0.04105, 0.86172]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":6, "position": np.array([0.32558+0.12, -0.65596+0.04105-light_offset, -0.16+0.65947]), "orientation": np.array([0.65861, -0.65861, 0.25736, 0.25736]), "goal_position":np.array([-18.15724, -5.8969-0.04105, 0.90133]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":4, "position": np.array([0.29868+0.12, -0.76576+0, -0.16+0.68019]), "orientation": np.array([0.659, -0.65796, 0.25749, 0.25789]), "goal_position":np.array([-18.13043, -5.78712-0, 0.922310]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":5, "position": np.array([0.3648+0.12, -0.76576+0, -0.16+0.61948]), "orientation": np.array([0.659, -0.65796, 0.25749, 0.25789]), "goal_position":np.array([-18.19655, -5.78712-0, 0.8616]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":6, "position": np.array([0.29868+0.12, -0.76576+0, -0.16+0.68019]), "orientation": np.array([0.659, -0.65796, 0.25749, 0.25789]), "goal_position":np.array([-18.13043, -5.78712-0, 0.922310]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":7, "position": np.array([0.11405, 0.9514, -0.16+0.34371+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-17.94611, -7.50448, 0.58583+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])}
# {"index":7, "position": np.array([-0.57726, -0.00505, -0.16+0.65911]), "orientation": np.array([0.5, -0.5, 0.5, 0.5]), "goal_position":np.array([-17.25466, -6.54783, 0.90123]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":7, "position": np.array([0.5517, 0.68287, -0.16+0.34371+0.2]), "orientation": np.array([0.5, 0.5, 0.5, -0.5]), "goal_position":np.array([-18.38395, -7.23584, 0.58583+0.2]), "goal_orientation":np.array([0.5, -0.5, 0.5, 0.5])}
]
self.util.move_ur10(motion_plan, "_light")
if self.util.motion_task_counter==2 and not self.bool_done[28]:
self.bool_done[28] = True
self.util.remove_part("World/Environment", f"light_0{self.id}")
self.util.add_part_custom("World/UR10_light/ee_link","FFrontLightAssembly", f"qlight_{self.id}", np.array([0.001,0.001,0.001]), np.array([1.30826, -0.30485, -0.12023]), np.array([0.36036, -0.00194, 0.00463, 0.9328]))
if self.util.motion_task_counter==6 and not self.bool_done[29]:
self.bool_done[29] = True
print("Done placing light")
self.util.remove_part("World/UR10_light/ee_link", f"qlight_{self.id}")
self.util.add_part_custom(f"mock_robot_{self.id}/platform","FFrontLightAssembly", f"xlight_{self.id}", np.array([0.001,0.001,0.001]), np.array([0.8669, -0.10851, 1.76492]), np.array([0.47905, -0.49076, 0.50734, 0.52179]))
if self.util.motion_task_counter==8:
self.util.motion_task_counter=0
return True
return False
def screw_light(self):
light_offset=0.12284
# motion_plan = [{"index":0, "position": np.array([0.03769, -0.74077, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.06964, -4.37873, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":1, "position": np.array([0.03769, -0.74077, -0.16+0.43386]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.06964, -4.37873, 0.67627]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":2, "position": np.array([0.03769, -0.74077, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.06964, -4.37873, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":3, "position": np.array([0.10078, 0.73338+0.04105-light_offset, -0.16+0.5969+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.13269, -5.85288-0.04105, 0.83931+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":4, "position": np.array([0.10078, 0.73338+0.04105-light_offset, -0.16+0.5969]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.13269, -5.85288-0.04105, 0.83931]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":5, "position": np.array([0.10078, 0.73338+0.04105-light_offset, -0.16+0.5969+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.13269, -5.85288-0.04105, 0.83931+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":6, "position": np.array([0.21628, -0.7386, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.24824, -4.38091, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":7, "position": np.array([0.21628, -0.7386, -0.16+0.43386]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.24824, -4.38091, 0.67627]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":8, "position": np.array([0.21628, -0.7386, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.24824, -4.38091, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
# {"index":9, "position": np.array([0.10078, 0.82997+0.04105-light_offset, -0.16+0.5969+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.13269, -5.94947-0.04105, 0.83931+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":10, "position": np.array([0.10078, 0.82997+0.04105-light_offset, -0.16+0.5969]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.13269, -5.94947-0.04105, 0.83931]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":11, "position": np.array([0.10078, 0.82997+0.04105-light_offset, -0.16+0.5969+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.13269, -5.94947-0.04105, 0.83931+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
# {"index":12, "position": np.array([0.03932, -0.71305, -0.16+0.42576+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.0712, -4.4, 0.66799+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])}]
motion_plan = [{"index":0, "position": np.array([0.03769, -0.74077, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.06964, -4.37873, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":1, "position": np.array([0.03769, -0.74077, -0.16+0.43386]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.06964, -4.37873, 0.67627]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":2, "position": np.array([0.03769, -0.74077, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.06964, -4.37873, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":3, "position": np.array([0.07394, 0.72035+0, -0.16+0.57846+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.10573, -5.84019-0, 0.82088+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":4, "position": np.array([0.07394, 0.72035+0, -0.16+0.57846]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.10573, -5.84019-0, 0.82088]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":5, "position": np.array([0.07394, 0.72035+0, -0.16+0.57846+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.10573, -5.84019-0, 0.82088+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":6, "position": np.array([0.21628, -0.7386, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.24824, -4.38091, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":7, "position": np.array([0.21628, -0.7386, -0.16+0.43386]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.24824, -4.38091, 0.67627]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":8, "position": np.array([0.21628, -0.7386, -0.16+0.43386+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.24824, -4.38091, 0.67627+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])},
{"index":9, "position": np.array([0.07394, 0.61525+0, -0.16+0.57846+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.10573, -5.73509-0, 0.82088+0.2]), "goal_orientation":np.array([0, 0.70711, 0, -0.70711])},
{"index":10, "position": np.array([0.07394, 0.61525+0, -0.16+0.57846]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.10573, -5.73509-0, 0.82088]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":11, "position": np.array([0.07394, 0.61525+0, -0.16+0.57846+0.2]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-18.10573, -5.73509-0, 0.82088+0.2]), "goal_orientation":np.array([0, -0.70711, 0, 0.70711])},
{"index":12, "position": np.array([0.03932, -0.71305, -0.16+0.42576+0.2]), "orientation": np.array([0, 0.70711, 0, -0.70711]), "goal_position":np.array([-18.0712, -4.4, 0.66799+0.2]), "goal_orientation":np.array([0.5, 0.5, 0.5, -0.5])}]
self.util.do_screw_driving(motion_plan,"_light")
if self.util.motion_task_counter==13:
print("Done screwing light")
self.util.motion_task_counter=0
return True
return False
def go_to_end_goal(self):
print(self.util.path_plan_counter)
path_plan = [["translate", [-9.95, 0, True]],
["wait",[]],
["rotate", [np.array([0.99341, 0, 0, -0.11458]), 0.0042, True]],
["wait",[]],
["translate", [-9.16, 0, True]],
["wait",[]],
["rotate", [np.array([1,0,0,0]), 0.0042, False]],
["wait",[]],
["translate", [8, 0, True]],
]
if self.id==2 or self.id==4:
path_plan = [["translate", [-9.95, 0, True]],
["wait",[]],
["rotate", [np.array([0.99341, 0, 0, -0.11458]), 0.0042, True]],
["wait",[]],
["translate", [-9.16, 0, True]],
["wait",[]],
["rotate", [np.array([1,0,0,0]), 0.0042, False]],
["wait",[]],
["wait",[]],
["wait",[]],
["wait",[]],
["wait",[]],
["wait",[]],
["translate", [8, 0, True]],
]
self.util.move_mp(path_plan)
# current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose()
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
self.moving_platform.apply_action(self.util._my_custom_controller.forward(command=[0.5,0]))
self.util.remove_part(f"mock_robot_{self.id}","platform")
self.util.remove_part(f"mock_robot_{self.id}","wheel_top_right")
self.util.remove_part(f"mock_robot_{self.id}","wheel_top_left")
self.util.remove_part(f"mock_robot_{self.id}","wheel_bottom_right")
self.util.remove_part(f"mock_robot_{self.id}","wheel_bottom_left")
# self.util.remove_part(None,f"mock_robot_{self.id}")
# self.util.remove_part(None,f"mock_robot_{self.id}")
# self.util.remove_part(None,f"mock_robot_{self.id}")
# self.util.remove_part(None,f"mock_robot_{self.id}")
# self.util.remove_part(None,f"mock_robot_{self.id}")
# self.util.remove_part(None,f"mock_robot_{self.id}")
return True
return False
def move_to_contingency_cell(self):
print(self.util.path_plan_counter)
path_plan = [
["translate", [-23.937, 1, True]],
["wait",[]],
["rotate", [np.array([0,0,0,1]), 0.0042, True]],
["wait",[]],
["translate", [-35.63314, 0, True]],
["wait",[]],
["rotate", [np.array([0.70711, 0, 0, 0.70711]), 0.0042, True]],
["wait",[]],
["translate", [17.6, 1, True]],
["wait",[]],
["rotate", [np.array([1,0,0,0]), 0.0042, True]],
["wait",[]],
["translate", [-20.876, 0, True]]]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False
def disassemble(self):
print(self.disassembly_event)
def delay_for(amount):
if self.delay == amount:
self.delay=0
self.disassembly_event+=1
return True
else:
self.delay+=1
return False
# remove and add part
if self.disassembly_event == 0:
if not self.isDone[self.disassembly_event] and delay_for(100):
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xmain_cover_{self.id}")
self.util.add_part_custom("World/Environment","main_cover", "qmain_cover", np.array([0.001, 0.001, 0.001]), np.array([-24.35262, 19.39603, -0.02519]), np.array([0.70711, 0.70711, 0, 0]))
self.isDone[self.disassembly_event-1]=True
# remove and add part
elif self.disassembly_event == 1:
if not self.isDone[self.disassembly_event] and delay_for(100):
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xlower_coverr_{self.id}")
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xlower_coverl_{self.id}")
self.util.add_part_custom("World/Environment","lower_cover", "qlower_coverr", np.array([0.001, 0.001, 0.001]), np.array([-20.65511, 19.03402, 0.25662]), np.array([0,0,0.70711,0.70711]))
self.util.add_part_custom("World/Environment","lower_cover", "qlower_coverl", np.array([0.001, 0.001, 0.001]), np.array([-20.29928, 19.04322, 0.25662]), np.array([0,0,-0.70711,-0.70711]))
self.isDone[self.disassembly_event-1]=True
# remove and add part
elif self.disassembly_event == 2:
if not self.isDone[self.disassembly_event] and delay_for(100):
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xwheel_01_{self.id}")
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xwheel_02_{self.id}")
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xwheel_03_{self.id}")
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xwheel_04_{self.id}")
self.util.add_part_custom("World/Environment","FWheel", "qwheel_01", np.array([0.001, 0.001, 0.001]), np.array([-18.86967, 18.93091, 0.25559]), np.array([0.70711, 0, -0.70711, 0]))
self.util.add_part_custom("World/Environment","FWheel", "qwheel_02", np.array([0.001, 0.001, 0.001]), np.array([-18.34981, 18.93091, 0.25559]), np.array([0.70711, 0, -0.70711, 0]))
self.util.add_part_custom("World/Environment","FWheel", "qwheel_03", np.array([0.001, 0.001, 0.001]), np.array([-17.85765, 18.93091, 0.25559]), np.array([0.70711, 0, -0.70711, 0]))
self.util.add_part_custom("World/Environment","FWheel", "qwheel_04", np.array([0.001, 0.001, 0.001]), np.array([-17.33776, 18.93091, 0.25559]), np.array([0.70711, 0, -0.70711, 0]))
self.isDone[self.disassembly_event-1]=True
# remove and add part
elif self.disassembly_event == 3:
if not self.isDone[self.disassembly_event] and delay_for(100):
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xfuel_{self.id}")
self.util.add_part_custom("World/Environment","fuel", "qfuel", np.array([0.001, 0.001, 0.001]), np.array([-23.63045, 16.54196, 0.26478]), np.array([0.5,0.5,-0.5,-0.5]))
self.isDone[self.disassembly_event-1]=True
# remove and add part
elif self.disassembly_event == 4:
if not self.isDone[self.disassembly_event] and delay_for(100):
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xbattery_{self.id}")
self.util.add_part_custom("World/Environment","battery", "qbattery", np.array([0.001, 0.001, 0.001]), np.array([-21.87392, 16.38365, 0.25864]), np.array([0.70711, 0.70711, 0, 0]))
self.isDone[self.disassembly_event-1]=True
# remove and add part
elif self.disassembly_event == 5:
if not self.isDone[self.disassembly_event] and delay_for(100):
self.util.remove_part(f"mock_robot_{self.id}/platform",f"xFSuspensionBack_{self.id}")
self.util.add_part_custom("World/Environment","FSuspensionBack", "qsuspension_back", np.array([0.001, 0.001, 0.001]), np.array([-20.82231, 16.78007, 0.24643]), np.array([0.5, 0.5, -0.5, 0.5]))
self.isDone[self.disassembly_event-1]=True
elif self.disassembly_event == 6:
if not self.isDone[self.disassembly_event] and delay_for(100):
self.util.remove_part(f"mock_robot_{self.id}/platform",f"engine_{self.id}")
self.util.add_part_custom("World/Environment","engine_no_rigid", "qengine", np.array([0.001, 0.001, 0.001]), np.array([-19.07782, 16.35288, 0.43253]), np.array([0.99457,0,-0.10407,0]))
self.isDone[self.disassembly_event-1]=True
elif self.disassembly_event == 7:
return True
return False
def carry_on(self):
print(self.util.path_plan_counter)
path_plan = [
["translate", [-10.0529, 0, True]]
]
self.util.move_mp(path_plan)
if len(path_plan) == self.util.path_plan_counter:
self.util.path_plan_counter=0
return True
return False | 191,906 | Python | 93.909496 | 322 | 0.554746 |
swadaskar/Isaac_Sim_Folder/extension_examples/hello_world/README.md | # Microfactory
| 17 | Markdown | 4.999998 | 14 | 0.705882 |
swadaskar/Isaac_Sim_Folder/extension_examples/simple_stack/simple_stack_extension.py | # Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
import os
from omni.isaac.examples.base_sample import BaseSampleExtension
from omni.isaac.examples.simple_stack import SimpleStack
import asyncio
import omni.ui as ui
from omni.isaac.ui.ui_utils import btn_builder
class SimpleStackExtension(BaseSampleExtension):
def on_startup(self, ext_id: str):
super().on_startup(ext_id)
super().start_extension(
menu_name="Manipulation",
submenu_name="",
name="Simple Stack",
title="Stack Two Cubes",
doc_link="https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/overview.html",
overview="This Example shows how to stack two cubes using Franka robot in Isaac Sim.\n\nPress the 'Open in IDE' button to view the source code.",
sample=SimpleStack(),
file_path=os.path.abspath(__file__),
number_of_extra_frames=1,
)
self.task_ui_elements = {}
frame = self.get_frame(index=0)
self.build_task_controls_ui(frame)
return
def _on_stacking_button_event(self):
asyncio.ensure_future(self.sample._on_stacking_event_async())
self.task_ui_elements["Start Stacking"].enabled = False
return
def post_reset_button_event(self):
self.task_ui_elements["Start Stacking"].enabled = True
return
def post_load_button_event(self):
self.task_ui_elements["Start Stacking"].enabled = True
return
def post_clear_button_event(self):
self.task_ui_elements["Start Stacking"].enabled = False
return
def build_task_controls_ui(self, frame):
with frame:
with ui.VStack(spacing=5):
# Update the Frame Title
frame.title = "Task Controls"
frame.visible = True
dict = {
"label": "Start Stacking",
"type": "button",
"text": "Start Stacking",
"tooltip": "Start Stacking",
"on_clicked_fn": self._on_stacking_button_event,
}
self.task_ui_elements["Start Stacking"] = btn_builder(**dict)
self.task_ui_elements["Start Stacking"].enabled = False
| 2,678 | Python | 37.826086 | 157 | 0.626587 |
swadaskar/Isaac_Sim_Folder/extension_examples/simple_stack/simple_stack.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.franka.tasks import Stacking
from omni.isaac.franka.controllers import StackingController
class SimpleStack(BaseSample):
def __init__(self) -> None:
super().__init__()
self._controller = None
self._articulation_controller = None
def setup_scene(self):
world = self.get_world()
world.add_task(Stacking(name="stacking_task"))
return
async def setup_post_load(self):
self._franka_task = self._world.get_task(name="stacking_task")
self._task_params = self._franka_task.get_params()
my_franka = self._world.scene.get_object(self._task_params["robot_name"]["value"])
self._controller = StackingController(
name="stacking_controller",
gripper=my_franka.gripper,
robot_articulation=my_franka,
picking_order_cube_names=self._franka_task.get_cube_names(),
robot_observation_name=my_franka.name,
)
self._articulation_controller = my_franka.get_articulation_controller()
return
def _on_stacking_physics_step(self, step_size):
observations = self._world.get_observations()
actions = self._controller.forward(observations=observations)
self._articulation_controller.apply_action(actions)
if self._controller.is_done():
self._world.pause()
return
async def _on_stacking_event_async(self):
world = self.get_world()
world.add_physics_callback("sim_step", self._on_stacking_physics_step)
await world.play_async()
return
async def setup_pre_reset(self):
world = self.get_world()
if world.physics_callback_exists("sim_step"):
world.remove_physics_callback("sim_step")
self._controller.reset()
return
def world_cleanup(self):
self._controller = None
return
| 2,380 | Python | 36.203124 | 90 | 0.667227 |
swadaskar/Isaac_Sim_Folder/extension_examples/simple_stack/__init__.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from omni.isaac.examples.simple_stack.simple_stack import SimpleStack
from omni.isaac.examples.simple_stack.simple_stack_extension import SimpleStackExtension
| 588 | Python | 48.083329 | 88 | 0.823129 |
swadaskar/Isaac_Sim_Folder/extension_examples/kaya_gamepad/kaya_gamepad_extension.py | # Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
import os
from omni.isaac.examples.base_sample import BaseSampleExtension
from omni.isaac.examples.kaya_gamepad import KayaGamepad
class KayaGamepadExtension(BaseSampleExtension):
def on_startup(self, ext_id: str):
super().on_startup(ext_id)
overview = "This Example shows how to drive a NVIDIA Kaya robot using a Gamepad in Isaac Sim."
overview += "\n\nConnect a gamepad to the robot, and the press PLAY to begin simulating."
overview += "\n\nPress the 'Open in IDE' button to view the source code."
super().start_extension(
menu_name="Input Devices",
submenu_name="",
name="Kaya Gamepad",
title="NVIDIA Kaya Gamepad Example",
doc_link="https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_advanced_input_devices.html",
overview=overview,
file_path=os.path.abspath(__file__),
sample=KayaGamepad(),
)
return
| 1,415 | Python | 43.249999 | 120 | 0.698233 |
swadaskar/Isaac_Sim_Folder/extension_examples/kaya_gamepad/__init__.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from omni.isaac.examples.kaya_gamepad.kaya_gamepad import KayaGamepad
from omni.isaac.examples.kaya_gamepad.kaya_gamepad_extension import KayaGamepadExtension
| 588 | Python | 48.083329 | 88 | 0.823129 |
swadaskar/Isaac_Sim_Folder/extension_examples/kaya_gamepad/kaya_gamepad.py | # Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
from omni.isaac.examples.base_sample import BaseSample
from omni.isaac.core.utils.nucleus import get_assets_root_path
import omni.usd
import carb
import omni.graph.core as og
class KayaGamepad(BaseSample):
def __init__(self) -> None:
super().__init__()
def setup_scene(self):
assets_root_path = get_assets_root_path()
if assets_root_path is None:
carb.log_error("Could not find Isaac Sim assets folder")
return
kaya_usd = assets_root_path + "/Isaac/Robots/Kaya/kaya.usd"
kaya_ogn_usd = assets_root_path + "/Isaac/Robots/Kaya/kaya_ogn_gamepad.usd"
stage = omni.usd.get_context().get_stage()
graph_prim = stage.DefinePrim("/World", "Xform")
graph_prim.GetReferences().AddReference(kaya_ogn_usd)
def world_cleanup(self):
pass
| 1,268 | Python | 36.323528 | 83 | 0.705836 |
pkoprov/CNC_robot_cell_DT/README.md | # Extension Project Template
This project was automatically generated.
- `app` - It is a folder link to the location of your *Omniverse Kit* based app.
- `exts` - It is a folder where you can add new extensions. It was automatically added to extension search path. (Extension Manager -> Gear Icon -> Extension Search Path).
Open this folder using Visual Studio Code. It will suggest you to install few extensions that will make python experience better.
Look for "cell.dt" extension in extension manager and enable it. Try applying changes to any python files, it will hot-reload and you can observe results immediately.
Alternatively, you can launch your app from console with this folder added to search path and your extension enabled, e.g.:
```
> app\omni.code.bat --ext-folder exts --enable company.hello.world
```
# App Link Setup
If `app` folder link doesn't exist or broken it can be created again. For better developer experience it is recommended to create a folder link named `app` to the *Omniverse Kit* app installed from *Omniverse Launcher*. Convenience script to use is included.
Run:
```
> link_app.bat
```
If successful you should see `app` folder link in the root of this repo.
If multiple Omniverse apps is installed script will select recommended one. Or you can explicitly pass an app:
```
> link_app.bat --app create
```
You can also just pass a path to create link to:
```
> link_app.bat --path "C:/Users/bob/AppData/Local/ov/pkg/create-2021.3.4"
```
# Sharing Your Extensions
This folder is ready to be pushed to any git repository. Once pushed direct link to a git repository can be added to *Omniverse Kit* extension search paths.
Link might look like this: `git://github.com/[user]/[your_repo].git?branch=main&dir=exts`
Notice `exts` is repo subfolder with extensions. More information can be found in "Git URL as Extension Search Paths" section of developers manual.
To add a link to your *Omniverse Kit* based app go into: Extension Manager -> Gear Icon -> Extension Search Path
| 2,031 | Markdown | 37.339622 | 258 | 0.756278 |
pkoprov/CNC_robot_cell_DT/tools/scripts/link_app.py | import argparse
import json
import os
import sys
import packmanapi
import urllib3
def find_omniverse_apps():
http = urllib3.PoolManager()
try:
r = http.request("GET", "http://127.0.0.1:33480/components")
except Exception as e:
print(f"Failed retrieving apps from an Omniverse Launcher, maybe it is not installed?\nError: {e}")
sys.exit(1)
apps = {}
for x in json.loads(r.data.decode("utf-8")):
latest = x.get("installedVersions", {}).get("latest", "")
if latest:
for s in x.get("settings", []):
if s.get("version", "") == latest:
root = s.get("launch", {}).get("root", "")
apps[x["slug"]] = (x["name"], root)
break
return apps
def create_link(src, dst):
print(f"Creating a link '{src}' -> '{dst}'")
packmanapi.link(src, dst)
APP_PRIORITIES = ["code", "create", "view"]
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create folder link to Kit App installed from Omniverse Launcher")
parser.add_argument(
"--path",
help="Path to Kit App installed from Omniverse Launcher, e.g.: 'C:/Users/bob/AppData/Local/ov/pkg/create-2021.3.4'",
required=False,
)
parser.add_argument(
"--app", help="Name of Kit App installed from Omniverse Launcher, e.g.: 'code', 'create'", required=False
)
args = parser.parse_args()
path = args.path
if not path:
print("Path is not specified, looking for Omniverse Apps...")
apps = find_omniverse_apps()
if len(apps) == 0:
print(
"Can't find any Omniverse Apps. Use Omniverse Launcher to install one. 'Code' is the recommended app for developers."
)
sys.exit(0)
print("\nFound following Omniverse Apps:")
for i, slug in enumerate(apps):
name, root = apps[slug]
print(f"{i}: {name} ({slug}) at: '{root}'")
if args.app:
selected_app = args.app.lower()
if selected_app not in apps:
choices = ", ".join(apps.keys())
print(f"Passed app: '{selected_app}' is not found. Specify one of the following found Apps: {choices}")
sys.exit(0)
else:
selected_app = next((x for x in APP_PRIORITIES if x in apps), None)
if not selected_app:
selected_app = next(iter(apps))
print(f"\nSelected app: {selected_app}")
_, path = apps[selected_app]
if not os.path.exists(path):
print(f"Provided path doesn't exist: {path}")
else:
SCRIPT_ROOT = os.path.dirname(os.path.realpath(__file__))
create_link(f"{SCRIPT_ROOT}/../../app", path)
print("Success!")
| 2,814 | Python | 32.117647 | 133 | 0.562189 |
pkoprov/CNC_robot_cell_DT/tools/packman/config.packman.xml | <config remotes="cloudfront">
<remote2 name="cloudfront">
<transport actions="download" protocol="https" packageLocation="d4i3qtqj3r0z5.cloudfront.net/${name}@${version}" />
</remote2>
</config>
| 211 | XML | 34.333328 | 123 | 0.691943 |
pkoprov/CNC_robot_cell_DT/tools/packman/bootstrap/install_package.py | # Copyright 2019 NVIDIA CORPORATION
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import shutil
import sys
import tempfile
import zipfile
__author__ = "hfannar"
logging.basicConfig(level=logging.WARNING, format="%(message)s")
logger = logging.getLogger("install_package")
class TemporaryDirectory:
def __init__(self):
self.path = None
def __enter__(self):
self.path = tempfile.mkdtemp()
return self.path
def __exit__(self, type, value, traceback):
# Remove temporary data created
shutil.rmtree(self.path)
def install_package(package_src_path, package_dst_path):
with zipfile.ZipFile(package_src_path, allowZip64=True) as zip_file, TemporaryDirectory() as temp_dir:
zip_file.extractall(temp_dir)
# Recursively copy (temp_dir will be automatically cleaned up on exit)
try:
# Recursive copy is needed because both package name and version folder could be missing in
# target directory:
shutil.copytree(temp_dir, package_dst_path)
except OSError as exc:
logger.warning("Directory %s already present, packaged installation aborted" % package_dst_path)
else:
logger.info("Package successfully installed to %s" % package_dst_path)
install_package(sys.argv[1], sys.argv[2])
| 1,844 | Python | 33.166666 | 108 | 0.703362 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/cell/dt/extension.py | import omni.ext
import omni.ui as ui
from paho.mqtt import client as mqtt_client
from pxr import UsdGeom, Gf
from .models import Cube
import carb.events
# Event is unique integer id. Create it from string by hashing, using helper function.
NEW_MESSAGE = carb.events.type_from_string("cell.dt.NEW_MESSAGE_EVENT")
BUS = omni.kit.app.get_app().get_message_bus_event_stream()
class SyncTwinMqttSampleExtension(omni.ext.IExt):
def load_usd_model(self):
print("loading model...")
self.context = omni.usd.get_context()
self_cube = Cube()
def on_startup(self, ext_id):
print("Digital Twin startup")
# init data
self.mqtt_connected = False
self.target_prim = "/World/Cube"
self.current_coord = ui.SimpleFloatModel(0)
# init ui
self.context = omni.usd.get_context()
self._window = ui.Window("Digital Twin", width=300, height=350)
with self._window.frame:
with ui.VStack():
ui.Button("load model",clicked_fn=self.load_usd_model)
ui.Label("Current Z coord")
ui.StringField(self.current_coord)
self.status_label = ui.Label("- not connected -")
ui.Button("connect MQTT", clicked_fn=self.connect_mqtt)
ui.Button("disconnect MQTT", clicked_fn=self.disconnect)
# we want to know when model changes
self._sub_stage_event = self.context.get_stage_event_stream().create_subscription_to_pop(
self._on_stage_event)
# find our xf prim if model already present
self.find_xf_prim()
# and we need a callback on each frame to update our xf prim
self._app_update_sub = BUS.create_subscription_to_pop_by_type(NEW_MESSAGE,
self._on_app_update_event, name="synctwin.mqtt_sample._on_app_update_event")
# # called on every frame, be careful what to put there
def _on_app_update_event(self, evt):
# if we have found the transform lets update the translation
if self.xf:
translation_matrix = Gf.Matrix4d().SetTranslate(Gf.Vec3d(0, 0, evt.payload["Z"]))
self.xf.MakeMatrixXform().Set(translation_matrix)
# called on load
def _on_stage_event(self, event):
if event.type == int(omni.usd.StageEventType.OPENED):
print("opened new model")
self.find_xf_prim()
# find the prim to be transformed
def find_xf_prim(self):
# get prim from input
stage = self.context.get_stage()
prim = stage.GetPrimAtPath(self.target_prim)
self.xf = UsdGeom.Xformable(prim)
if self.xf:
msg = "found xf."
else:
msg = "## xf not found."
self.status_label.text = msg
print(msg)
# connect to mqtt broker
def connect_mqtt(self):
# this is called when a message arrives
def on_message(client, userdata, msg):
msg_content = msg.payload.decode()
print(f"Received `{msg_content}` from `{msg.topic}` topic")
# userdata is self
userdata.current_coord.set_value(float(msg_content))
BUS.push(NEW_MESSAGE, payload={'Z':float(msg_content)})
# called when connection to mqtt broker has been established
def on_connect(client, userdata, flags, rc):
print(f">> connected {client} {rc}")
if rc == 0:
userdata.status_label.text = "Connected to MQTT Broker!"
topic = "ncsu/digital_twin/Cube"
print(f"subscribing topic {topic}")
client.subscribe(topic)
else:
userdata.status_label.text = f"Failed to connect, return code {rc}"
# let us know when we've subscribed
def on_subscribe(client, userdata, mid, granted_qos):
print(f"subscribed {mid} {granted_qos}")
# now connect broker
if self.mqtt_connected:
print("Already connected to MQTT Broker!")
self.status_label.text = "Already connected to MQTT Broker!"
return
# Set Connecting Client ID
self.client = mqtt_client.Client(mqtt_client.CallbackAPIVersion.VERSION1, 'Omni Cube Client')
self.client.user_data_set(self)
self.client.on_connect = on_connect
self.client.on_message = on_message
self.client.on_subscribe = on_subscribe
self.client.connect("192.168.10.4")
self.client.loop_start()
self.mqtt_connected = True
return
def disconnect(self):
print("disconnecting")
self.client.disconnect()
self.client.loop_stop()
self.mqtt_connected = False
self.status_label.text = "Disonnected from MQTT Broker!"
def on_shutdown(self):
print("Digital Twin shutdown")
self.client = None
self._app_update_sub = None | 5,081 | Python | 36.367647 | 111 | 0.588073 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/cell/dt/__init__.py | from .extension import *
| 25 | Python | 11.999994 | 24 | 0.76 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/cell/dt/models.py | import omni.kit.commands as commands
# from pxr import Usd
# import omni.isaac.core.utils.prims as prim_utils
class Cube():
def __init__(self):
commands.execute('CreateMeshPrimWithDefaultXform',prim_type='Cube')
class Light():
def __init__(self):
commands.execute('CreatePrim',
prim_type='DistantLight',
attributes={'angle': 1.0, 'intensity': 3000})
# stage: Usd.Stage = Usd.Stage.CreateInMemory()
| 453 | Python | 24.222221 | 75 | 0.651214 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/cell/dt/tests/__init__.py | from .test_hello_world import * | 31 | Python | 30.999969 | 31 | 0.774194 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/cell/dt/tests/test_hello_world.py | # NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test
# Extnsion for writing UI tests (simulate UI interaction)
import omni.kit.ui_test as ui_test
# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
import cell.dt
# Having a test class dervived from omni.kit.test.AsyncTestCase declared on the root of module will make it auto-discoverable by omni.kit.test
class Test(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
pass
# After running each test
async def tearDown(self):
pass
# Actual test, notice it is "async" function, so "await" can be used if needed
async def test_hello_public_function(self):
result = cell.dt.some_public_function(4)
self.assertEqual(result, 256)
async def test_window_button(self):
# Find a label in our window
label = ui_test.find("My Window//Frame/**/Label[*]")
# Find buttons in our window
add_button = ui_test.find("My Window//Frame/**/Button[*].text=='Add'")
reset_button = ui_test.find("My Window//Frame/**/Button[*].text=='Reset'")
# Click reset button
await reset_button.click()
self.assertEqual(label.widget.text, "empty")
await add_button.click()
self.assertEqual(label.widget.text, "count: 1")
await add_button.click()
self.assertEqual(label.widget.text, "count: 2")
| 1,650 | Python | 34.127659 | 142 | 0.678788 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/config/extension.toml | [package]
# Semantic Versioning is used: https://semver.org/
version = "1.0.0"
# Lists people or organizations that are considered the "authors" of the package.
authors = ["Pavel Koprov"]
# The title and description fields are primarily for displaying extension info in UI
title = "cell dt"
description="An extension to run the Digital Twin of CNC and Robot cell"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = "https://github.com/pkoprov/CNC_robot_cell_DT"
# One of categories for UI.
category = "other"
# Keywords for the extension
keywords = ["digital twin"]
# Location of change log file in target (final) folder of extension, relative to the root.
# More info on writing changelog: https://keepachangelog.com/en/1.0.0/
changelog="docs/CHANGELOG.md"
# Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
# Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
preview_image = "data/preview.jpg"
# Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
icon = "data/icon.png"
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import cell.dt".
[[python.module]]
name = "cell.dt"
[python.pipapi]
requirements = ["paho-mqtt"]
use_online_index = true
[[test]]
# Extra dependencies only to be used during test run
dependencies = [
"omni.kit.ui_test" # UI testing extension
]
| 1,642 | TOML | 29.425925 | 118 | 0.74056 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/docs/CHANGELOG.md | # Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [1.0.0] - 2021-04-26
- Initial version of extension UI template with a window
| 178 | Markdown | 18.888887 | 80 | 0.702247 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/docs/README.md | # Python Extension Example [cell.dt]
This is an example of pure python Kit extension. It is intended to be copied and serve as a template to create new extensions.
| 166 | Markdown | 32.399994 | 126 | 0.777108 |
pkoprov/CNC_robot_cell_DT/exts/cell.dt/docs/index.rst | cell.dt
#############################
Example of Python only extension
.. toctree::
:maxdepth: 1
README
CHANGELOG
.. automodule::"cell.dt"
:platform: Windows-x86_64, Linux-x86_64
:members:
:undoc-members:
:show-inheritance:
:imported-members:
:exclude-members: contextmanager
| 315 | reStructuredText | 14.047618 | 43 | 0.596825 |
zoctipus/cse542Project/pyproject.toml | [tool.isort]
py_version = 310
line_length = 120
group_by_package = true
# Files to skip
skip_glob = ["docs/*", "logs/*", "_isaac_sim/*", ".vscode/*"]
# Order of imports
sections = [
"FUTURE",
"STDLIB",
"THIRDPARTY",
"ASSETS_FIRSTPARTY",
"FIRSTPARTY",
"EXTRA_FIRSTPARTY",
"LOCALFOLDER",
]
# Extra standard libraries considered as part of python (permissive licenses
extra_standard_library = [
"numpy",
"h5py",
"open3d",
"torch",
"tensordict",
"bpy",
"matplotlib",
"gymnasium",
"gym",
"scipy",
"hid",
"yaml",
"prettytable",
"toml",
"trimesh",
"tqdm",
]
# Imports from Isaac Sim and Omniverse
known_third_party = [
"omni.isaac.core",
"omni.replicator.isaac",
"omni.replicator.core",
"pxr",
"omni.kit.*",
"warp",
"carb",
]
# Imports from this repository
known_first_party = "omni.isaac.orbit"
known_assets_firstparty = "omni.isaac.orbit_assets"
known_extra_firstparty = [
"omni.isaac.orbit_tasks"
]
# Imports from the local folder
known_local_folder = "config"
[tool.pyright]
include = ["source/extensions", "source/standalone"]
exclude = [
"**/__pycache__",
"**/_isaac_sim",
"**/docs",
"**/logs",
".git",
".vscode",
]
typeCheckingMode = "basic"
pythonVersion = "3.10"
pythonPlatform = "Linux"
enableTypeIgnoreComments = true
# This is required as the CI pre-commit does not download the module (i.e. numpy, torch, prettytable)
# Therefore, we have to ignore missing imports
reportMissingImports = "none"
# This is required to ignore for type checks of modules with stubs missing.
reportMissingModuleSource = "none" # -> most common: prettytable in mdp managers
reportGeneralTypeIssues = "none" # -> raises 218 errors (usage of literal MISSING in dataclasses)
reportOptionalMemberAccess = "warning" # -> raises 8 errors
reportPrivateUsage = "warning"
[tool.codespell]
skip = '*.usd,*.svg,*.png,_isaac_sim*,*.bib,*.css,*/_build'
quiet-level = 0
# the world list should always have words in lower case
ignore-words-list = "haa,slq,collapsable"
# todo: this is hack to deal with incorrect spelling of "Environment" in the Isaac Sim grid world asset
exclude-file = "source/extensions/omni.isaac.orbit/omni/isaac/orbit/sim/spawners/from_files/from_files.py"
| 2,314 | TOML | 23.627659 | 106 | 0.665946 |
zoctipus/cse542Project/CONTRIBUTING.md | # Contribution Guidelines
Orbit is a community maintained project. We wholeheartedly welcome contributions to the project to make
the framework more mature and useful for everyone. These may happen in forms of bug reports, feature requests,
design proposals and more.
For general information on how to contribute see
<https://isaac-orbit.github.io/orbit/source/refs/contributing.html>.
| 388 | Markdown | 42.222218 | 110 | 0.81701 |
zoctipus/cse542Project/CONTRIBUTORS.md | # Orbit Developers and Contributors
This is the official list of Orbit Project developers and contributors.
To see the full list of contributors, please check the revision history in the source control.
Guidelines for modifications:
* Please keep the lists sorted alphabetically.
* Names should be added to this file as: *individual names* or *organizations*.
* E-mail addresses are tracked elsewhere to avoid spam.
## Developers
* Boston Dynamics AI Institute, Inc.
* ETH Zurich
* NVIDIA Corporation & Affiliates
* University of Toronto
---
* David Hoeller
* Farbod Farshidian
* Hunter Hansen
* James Smith
* **Mayank Mittal** (maintainer)
* Nikita Rudin
* Pascal Roth
## Contributors
* Anton Bjørndahl Mortensen
* Alice Zhou
* Andrej Orsula
* Antonio Serrano-Muñoz
* Arjun Bhardwaj
* Calvin Yu
* Chenyu Yang
* Jia Lin Yuan
* Jingzhou Liu
* Muhong Guo
* Kourosh Darvish
* Özhan Özen
* Qinxi Yu
* René Zurbrügg
* Ritvik Singh
* Rosario Scalise
* Shafeef Omar
* Vladimir Fokow
## Acknowledgements
* Ajay Mandlekar
* Animesh Garg
* Buck Babich
* Gavriel State
* Hammad Mazhar
* Marco Hutter
* Yunrong Guo
| 1,115 | Markdown | 17.6 | 94 | 0.756054 |
zoctipus/cse542Project/README.md | 
---
# Orbit
[](https://docs.omniverse.nvidia.com/isaacsim/latest/overview.html)
[](https://docs.python.org/3/whatsnew/3.10.html)
[](https://releases.ubuntu.com/20.04/)
[](https://pre-commit.com/)
[](https://isaac-orbit.github.io/orbit)
[](https://opensource.org/licenses/BSD-3-Clause)
<!-- TODO: Replace docs status with workflow badge? Link: https://github.com/isaac-orbit/orbit/actions/workflows/docs.yaml/badge.svg -->
**Orbit** is a unified and modular framework for robot learning that aims to simplify common workflows
in robotics research (such as RL, learning from demonstrations, and motion planning). It is built upon
[NVIDIA Isaac Sim](https://docs.omniverse.nvidia.com/isaacsim/latest/overview.html) to leverage the latest
simulation capabilities for photo-realistic scenes and fast and accurate simulation.
Please refer to our [documentation page](https://isaac-orbit.github.io/orbit) to learn more about the
installation steps, features, tutorials, and how to set up your project with Orbit.
## Announcements
* [17.04.2024] [**v0.3.0**](https://github.com/NVIDIA-Omniverse/orbit/releases/tag/v0.3.0):
Several improvements and bug fixes to the framework. Includes cabinet opening and dexterous manipulation environments,
terrain-aware patch sampling, and animation recording.
* [22.12.2023] [**v0.2.0**](https://github.com/NVIDIA-Omniverse/orbit/releases/tag/v0.2.0):
Significant breaking updates to enhance the modularity and user-friendliness of the framework. Also includes
procedural terrain generation, warp-based custom ray-casters, and legged-locomotion environments.
## Contributing to Orbit
We wholeheartedly welcome contributions from the community to make this framework mature and useful for everyone.
These may happen as bug reports, feature requests, or code contributions. For details, please check our
[contribution guidelines](https://isaac-orbit.github.io/orbit/source/refs/contributing.html).
## Troubleshooting
Please see the [troubleshooting](https://isaac-orbit.github.io/orbit/source/refs/troubleshooting.html) section for
common fixes or [submit an issue](https://github.com/NVIDIA-Omniverse/orbit/issues).
For issues related to Isaac Sim, we recommend checking its [documentation](https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/overview.html)
or opening a question on its [forums](https://forums.developer.nvidia.com/c/agx-autonomous-machines/isaac/67).
## Support
* Please use GitHub [Discussions](https://github.com/NVIDIA-Omniverse/Orbit/discussions) for discussing ideas, asking questions, and requests for new features.
* Github [Issues](https://github.com/NVIDIA-Omniverse/orbit/issues) should only be used to track executable pieces of work with a definite scope and a clear deliverable. These can be fixing bugs, documentation issues, new features, or general updates.
## Acknowledgement
NVIDIA Isaac Sim is available freely under [individual license](https://www.nvidia.com/en-us/omniverse/download/). For more information about its license terms, please check [here](https://docs.omniverse.nvidia.com/app_isaacsim/common/NVIDIA_Omniverse_License_Agreement.html#software-support-supplement).
Orbit framework is released under [BSD-3 License](LICENSE). The license files of its dependencies and assets are present in the [`docs/licenses`](docs/licenses) directory.
## Citing
If you use this framework in your work, please cite [this paper](https://arxiv.org/abs/2301.04195):
```text
@article{mittal2023orbit,
author={Mittal, Mayank and Yu, Calvin and Yu, Qinxi and Liu, Jingzhou and Rudin, Nikita and Hoeller, David and Yuan, Jia Lin and Singh, Ritvik and Guo, Yunrong and Mazhar, Hammad and Mandlekar, Ajay and Babich, Buck and State, Gavriel and Hutter, Marco and Garg, Animesh},
journal={IEEE Robotics and Automation Letters},
title={Orbit: A Unified Simulation Framework for Interactive Robot Learning Environments},
year={2023},
volume={8},
number={6},
pages={3740-3747},
doi={10.1109/LRA.2023.3270034}
}
```
| 4,547 | Markdown | 59.639999 | 304 | 0.773257 |
zoctipus/cse542Project/tools/install_deps.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""
A script with various methods of installing dependencies
defined in an extension.toml
"""
import argparse
import os
import shutil
import sys
import toml
from subprocess import SubprocessError, run
# add argparse arguments
parser = argparse.ArgumentParser(description="Utility to install dependencies based on an extension.toml")
parser.add_argument("type", type=str, choices=["all", "apt", "rosdep"], help="The type of packages to install")
parser.add_argument("path", type=str, help="The path to the extension which will have its deps installed")
def install_apt_packages(path):
"""
A function which attempts to install apt packages for Orbit extensions.
It looks in {extension_root}/config/extension.toml for [orbit_settings][apt_deps]
and then attempts to install them. Exits on failure to stop the build process
from continuing despite missing dependencies.
Args:
path: A path to the extension root
"""
try:
if shutil.which("apt"):
with open(f"{path}/config/extension.toml") as fd:
ext_toml = toml.load(fd)
if "orbit_settings" in ext_toml and "apt_deps" in ext_toml["orbit_settings"]:
deps = ext_toml["orbit_settings"]["apt_deps"]
print(f"[INFO] Installing the following apt packages: {deps}")
run_and_print(["apt-get", "update"])
run_and_print(["apt-get", "install", "-y"] + deps)
else:
print("[INFO] No apt packages to install")
else:
raise RuntimeError("Exiting because 'apt' is not a known command")
except SubprocessError as e:
print(f"[ERROR]: {str(e.stderr, encoding='utf-8')}")
sys.exit(1)
except Exception as e:
print(f"[ERROR]: {e}")
sys.exit(1)
def install_rosdep_packages(path):
"""
A function which attempts to install rosdep packages for Orbit extensions.
It looks in {extension_root}/config/extension.toml for [orbit_settings][ros_ws]
and then attempts to install all rosdeps under that workspace.
Exits on failure to stop the build process from continuing despite missing dependencies.
Args:
path: A path to the extension root
"""
try:
if shutil.which("rosdep"):
with open(f"{path}/config/extension.toml") as fd:
ext_toml = toml.load(fd)
if "orbit_settings" in ext_toml and "ros_ws" in ext_toml["orbit_settings"]:
ws_path = ext_toml["orbit_settings"]["ros_ws"]
if not os.path.exists("/etc/ros/rosdep/sources.list.d/20-default.list"):
run_and_print(["rosdep", "init"])
run_and_print(["rosdep", "update", "--rosdistro=humble"])
run_and_print([
"rosdep",
"install",
"--from-paths",
f"{path}/{ws_path}/src",
"--ignore-src",
"-y",
"--rosdistro=humble",
])
else:
print("[INFO] No rosdep packages to install")
else:
raise RuntimeError("Exiting because 'rosdep' is not a known command")
except SubprocessError as e:
print(f"[ERROR]: {str(e.stderr, encoding='utf-8')}")
sys.exit(1)
except Exception as e:
print(f"[ERROR]: {e}")
sys.exit(1)
def run_and_print(args):
"""
Runs a subprocess.run(args=args, capture_output=True, check=True),
and prints the output
"""
completed_process = run(args=args, capture_output=True, check=True)
print(f"{str(completed_process.stdout, encoding='utf-8')}")
def main():
args = parser.parse_args()
if args.type == "all":
install_apt_packages(args.path)
install_rosdep_packages(args.path)
elif args.type == "apt":
install_apt_packages(args.path)
elif args.type == "rosdep":
install_rosdep_packages(args.path)
else:
print(f"[ERROR] '{args.type}' type dependencies not installable")
sys.exit(1)
if __name__ == "__main__":
main()
| 4,357 | Python | 35.316666 | 111 | 0.586413 |
zoctipus/cse542Project/tools/tests_to_skip.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# The following tests are skipped by run_tests.py
TESTS_TO_SKIP = [
# orbit
"test_argparser_launch.py", # app.close issue
"test_env_var_launch.py", # app.close issue
"test_kwarg_launch.py", # app.close issue
"test_differential_ik.py", # Failing
# orbit_tasks
"test_data_collector.py", # Failing
"test_record_video.py", # Failing
]
| 492 | Python | 27.999998 | 56 | 0.666667 |
zoctipus/cse542Project/tools/run_all_tests.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""A runner script for all the tests within source directory.
.. code-block:: bash
./orbit.sh -p tools/run_all_tests.py
# for dry run
./orbit.sh -p tools/run_all_tests.py --discover_only
# for quiet run
./orbit.sh -p tools/run_all_tests.py --quiet
# for increasing timeout (default is 600 seconds)
./orbit.sh -p tools/run_all_tests.py --timeout 1000
"""
import argparse
import logging
import os
import subprocess
import sys
import time
from datetime import datetime
from pathlib import Path
from prettytable import PrettyTable
# Tests to skip
from tests_to_skip import TESTS_TO_SKIP
ORBIT_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
"""Path to the root directory of Orbit repository."""
def parse_args() -> argparse.Namespace:
"""Parse command line arguments."""
parser = argparse.ArgumentParser(description="Run all tests under current directory.")
# add arguments
parser.add_argument(
"--skip_tests",
default="",
help="Space separated list of tests to skip in addition to those in tests_to_skip.py.",
type=str,
nargs="*",
)
# configure default test directory (source directory)
default_test_dir = os.path.join(ORBIT_PATH, "source")
parser.add_argument(
"--test_dir", type=str, default=default_test_dir, help="Path to the directory containing the tests."
)
# configure default logging path based on time stamp
log_file_name = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + ".log"
default_log_path = os.path.join(ORBIT_PATH, "logs", "test_results", log_file_name)
parser.add_argument(
"--log_path", type=str, default=default_log_path, help="Path to the log file to store the results in."
)
parser.add_argument("--discover_only", action="store_true", help="Only discover and print tests, don't run them.")
parser.add_argument("--quiet", action="store_true", help="Don't print to console, only log to file.")
parser.add_argument("--timeout", type=int, default=600, help="Timeout for each test in seconds.")
# parse arguments
args = parser.parse_args()
return args
def test_all(
test_dir: str,
tests_to_skip: list[str],
log_path: str,
timeout: float = 600.0,
discover_only: bool = False,
quiet: bool = False,
) -> bool:
"""Run all tests under the given directory.
Args:
test_dir: Path to the directory containing the tests.
tests_to_skip: List of tests to skip.
log_path: Path to the log file to store the results in.
timeout: Timeout for each test in seconds. Defaults to 600 seconds (10 minutes).
discover_only: If True, only discover and print the tests without running them. Defaults to False.
quiet: If False, print the output of the tests to the terminal console (in addition to the log file).
Defaults to False.
Returns:
True if all un-skipped tests pass or `discover_only` is True. Otherwise, False.
Raises:
ValueError: If any test to skip is not found under the given `test_dir`.
"""
# Create the log directory if it doesn't exist
os.makedirs(os.path.dirname(log_path), exist_ok=True)
# Add file handler to log to file
logging_handlers = [logging.FileHandler(log_path)]
# We also want to print to console
if not quiet:
logging_handlers.append(logging.StreamHandler())
# Set up logger
logging.basicConfig(level=logging.INFO, format="%(message)s", handlers=logging_handlers)
# Discover all tests under current directory
all_test_paths = [str(path) for path in Path(test_dir).resolve().rglob("*test_*.py")]
skipped_test_paths = []
test_paths = []
# Check that all tests to skip are actually in the tests
for test_to_skip in tests_to_skip:
for test_path in all_test_paths:
if test_to_skip in test_path:
break
else:
raise ValueError(f"Test to skip '{test_to_skip}' not found in tests.")
# Remove tests to skip from the list of tests to run
if len(tests_to_skip) != 0:
for test_path in all_test_paths:
if any([test_to_skip in test_path for test_to_skip in tests_to_skip]):
skipped_test_paths.append(test_path)
else:
test_paths.append(test_path)
else:
test_paths = all_test_paths
# Sort test paths so they're always in the same order
all_test_paths.sort()
test_paths.sort()
skipped_test_paths.sort()
# Print tests to be run
logging.info("\n" + "=" * 60 + "\n")
logging.info(f"The following {len(all_test_paths)} tests were found:")
for i, test_path in enumerate(all_test_paths):
logging.info(f"{i + 1:02d}: {test_path}")
logging.info("\n" + "=" * 60 + "\n")
logging.info(f"The following {len(skipped_test_paths)} tests are marked to be skipped:")
for i, test_path in enumerate(skipped_test_paths):
logging.info(f"{i + 1:02d}: {test_path}")
logging.info("\n" + "=" * 60 + "\n")
# Exit if only discovering tests
if discover_only:
return True
results = {}
# Run each script and store results
for test_path in test_paths:
results[test_path] = {}
before = time.time()
logging.info("\n" + "-" * 60 + "\n")
logging.info(f"[INFO] Running '{test_path}'\n")
try:
completed_process = subprocess.run(
[sys.executable, test_path], check=True, capture_output=True, timeout=timeout
)
except subprocess.TimeoutExpired as e:
logging.error(f"Timeout occurred: {e}")
result = "TIMEDOUT"
stdout = e.stdout
stderr = e.stderr
except subprocess.CalledProcessError as e:
# When check=True is passed to subprocess.run() above, CalledProcessError is raised if the process returns a
# non-zero exit code. The caveat is returncode is not correctly updated in this case, so we simply
# catch the exception and set this test as FAILED
result = "FAILED"
stdout = e.stdout
stderr = e.stderr
except Exception as e:
logging.error(f"Unexpected exception {e}. Please report this issue on the repository.")
result = "FAILED"
stdout = e.stdout
stderr = e.stderr
else:
# Should only get here if the process ran successfully, e.g. no exceptions were raised
# but we still check the returncode just in case
result = "PASSED" if completed_process.returncode == 0 else "FAILED"
stdout = completed_process.stdout
stderr = completed_process.stderr
after = time.time()
time_elapsed = after - before
# Decode stdout and stderr and write to file and print to console if desired
stdout_str = stdout.decode("utf-8") if stdout is not None else ""
stderr_str = stderr.decode("utf-8") if stderr is not None else ""
# Write to log file
logging.info(stdout_str)
logging.info(stderr_str)
logging.info(f"[INFO] Time elapsed: {time_elapsed:.2f} s")
logging.info(f"[INFO] Result '{test_path}': {result}")
# Collect results
results[test_path]["time_elapsed"] = time_elapsed
results[test_path]["result"] = result
# Calculate the number and percentage of passing tests
num_tests = len(all_test_paths)
num_passing = len([test_path for test_path in test_paths if results[test_path]["result"] == "PASSED"])
num_failing = len([test_path for test_path in test_paths if results[test_path]["result"] == "FAILED"])
num_timing_out = len([test_path for test_path in test_paths if results[test_path]["result"] == "TIMEDOUT"])
num_skipped = len(skipped_test_paths)
if num_tests == 0:
passing_percentage = 100
else:
passing_percentage = (num_passing + num_skipped) / num_tests * 100
# Print summaries of test results
summary_str = "\n\n"
summary_str += "===================\n"
summary_str += "Test Result Summary\n"
summary_str += "===================\n"
summary_str += f"Total: {num_tests}\n"
summary_str += f"Passing: {num_passing}\n"
summary_str += f"Failing: {num_failing}\n"
summary_str += f"Skipped: {num_skipped}\n"
summary_str += f"Timing Out: {num_timing_out}\n"
summary_str += f"Passing Percentage: {passing_percentage:.2f}%\n"
# Print time elapsed in hours, minutes, seconds
total_time = sum([results[test_path]["time_elapsed"] for test_path in test_paths])
summary_str += f"Total Time Elapsed: {total_time // 3600}h"
summary_str += f"{total_time // 60 % 60}m"
summary_str += f"{total_time % 60:.2f}s"
summary_str += "\n\n=======================\n"
summary_str += "Per Test Result Summary\n"
summary_str += "=======================\n"
# Construct table of results per test
per_test_result_table = PrettyTable(field_names=["Test Path", "Result", "Time (s)"])
per_test_result_table.align["Test Path"] = "l"
per_test_result_table.align["Time (s)"] = "r"
for test_path in test_paths:
per_test_result_table.add_row(
[test_path, results[test_path]["result"], f"{results[test_path]['time_elapsed']:0.2f}"]
)
for test_path in skipped_test_paths:
per_test_result_table.add_row([test_path, "SKIPPED", "N/A"])
summary_str += per_test_result_table.get_string()
# Print summary to console and log file
logging.info(summary_str)
# Only count failing and timing out tests towards failure
return num_failing + num_timing_out == 0
if __name__ == "__main__":
# parse command line arguments
args = parse_args()
# add tests to skip to the list of tests to skip
tests_to_skip = TESTS_TO_SKIP
tests_to_skip += args.skip_tests
# run all tests
test_success = test_all(
test_dir=args.test_dir,
tests_to_skip=tests_to_skip,
log_path=args.log_path,
timeout=args.timeout,
discover_only=args.discover_only,
quiet=args.quiet,
)
# update exit status based on all tests passing or not
if not test_success:
exit(1)
| 10,432 | Python | 36.394265 | 120 | 0.625863 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/setup.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Installation script for the 'omni.isaac.orbit_tasks' python package."""
import itertools
import os
import toml
from setuptools import setup
# Obtain the extension data from the extension.toml file
EXTENSION_PATH = os.path.dirname(os.path.realpath(__file__))
# Read the extension.toml file
EXTENSION_TOML_DATA = toml.load(os.path.join(EXTENSION_PATH, "config", "extension.toml"))
# Minimum dependencies required prior to installation
INSTALL_REQUIRES = [
# generic
"numpy",
"torch==2.0.1",
"torchvision>=0.14.1", # ensure compatibility with torch 1.13.1
"protobuf>=3.20.2",
# data collection
"h5py",
# basic logger
"tensorboard",
# video recording
"moviepy",
]
# Extra dependencies for RL agents
EXTRAS_REQUIRE = {
"sb3": ["stable-baselines3>=2.0"],
"skrl": ["skrl>=1.1.0"],
"rl_games": ["rl-games==1.6.1", "gym"], # rl-games still needs gym :(
"rsl_rl": ["rsl_rl@git+https://github.com/leggedrobotics/rsl_rl.git"],
"robomimic": ["robomimic@git+https://github.com/ARISE-Initiative/robomimic.git"],
}
# cumulation of all extra-requires
EXTRAS_REQUIRE["all"] = list(itertools.chain.from_iterable(EXTRAS_REQUIRE.values()))
# Installation operation
setup(
name="omni-isaac-orbit_tasks",
author="ORBIT Project Developers",
maintainer="Mayank Mittal",
maintainer_email="[email protected]",
url=EXTENSION_TOML_DATA["package"]["repository"],
version=EXTENSION_TOML_DATA["package"]["version"],
description=EXTENSION_TOML_DATA["package"]["description"],
keywords=EXTENSION_TOML_DATA["package"]["keywords"],
include_package_data=True,
python_requires=">=3.10",
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
packages=["omni.isaac.orbit_tasks"],
classifiers=[
"Natural Language :: English",
"Programming Language :: Python :: 3.10",
"Isaac Sim :: 2023.1.0-hotfix.1",
"Isaac Sim :: 2023.1.1",
],
zip_safe=False,
)
| 2,113 | Python | 29.637681 | 89 | 0.67345 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/test/test_environments.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher, run_tests
# launch the simulator
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import torch
import unittest
import omni.usd
from omni.isaac.orbit.envs import RLTaskEnv, RLTaskEnvCfg
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils.parse_cfg import parse_env_cfg
class TestEnvironments(unittest.TestCase):
"""Test cases for all registered environments."""
@classmethod
def setUpClass(cls):
# acquire all Isaac environments names
cls.registered_tasks = list()
for task_spec in gym.registry.values():
if "Isaac" in task_spec.id:
cls.registered_tasks.append(task_spec.id)
# sort environments by name
cls.registered_tasks.sort()
# print all existing task names
print(">>> All registered environments:", cls.registered_tasks)
"""
Test fixtures.
"""
def test_multiple_instances_gpu(self):
"""Run all environments with multiple instances and check environments return valid signals."""
# common parameters
num_envs = 32
use_gpu = True
# iterate over all registered environments
for task_name in self.registered_tasks:
with self.subTest(task_name=task_name):
print(f">>> Running test for environment: {task_name}")
# check environment
self._check_random_actions(task_name, use_gpu, num_envs, num_steps=100)
# close the environment
print(f">>> Closing environment: {task_name}")
print("-" * 80)
def test_single_instance_gpu(self):
"""Run all environments with single instance and check environments return valid signals."""
# common parameters
num_envs = 1
use_gpu = True
# iterate over all registered environments
for task_name in self.registered_tasks:
with self.subTest(task_name=task_name):
print(f">>> Running test for environment: {task_name}")
# check environment
self._check_random_actions(task_name, use_gpu, num_envs, num_steps=100)
# close the environment
print(f">>> Closing environment: {task_name}")
print("-" * 80)
"""
Helper functions.
"""
def _check_random_actions(self, task_name: str, use_gpu: bool, num_envs: int, num_steps: int = 1000):
"""Run random actions and check environments return valid signals."""
# create a new stage
omni.usd.get_context().new_stage()
# parse configuration
env_cfg: RLTaskEnvCfg = parse_env_cfg(task_name, use_gpu=use_gpu, num_envs=num_envs)
# create environment
env: RLTaskEnv = gym.make(task_name, cfg=env_cfg)
# reset environment
obs, _ = env.reset()
# check signal
self.assertTrue(self._check_valid_tensor(obs))
# simulate environment for num_steps steps
with torch.inference_mode():
for _ in range(num_steps):
# sample actions from -1 to 1
actions = 2 * torch.rand(env.action_space.shape, device=env.unwrapped.device) - 1
# apply actions
transition = env.step(actions)
# check signals
for data in transition:
self.assertTrue(self._check_valid_tensor(data), msg=f"Invalid data: {data}")
# close the environment
env.close()
@staticmethod
def _check_valid_tensor(data: torch.Tensor | dict) -> bool:
"""Checks if given data does not have corrupted values.
Args:
data: Data buffer.
Returns:
True if the data is valid.
"""
if isinstance(data, torch.Tensor):
return not torch.any(torch.isnan(data))
elif isinstance(data, dict):
valid_tensor = True
for value in data.values():
if isinstance(value, dict):
valid_tensor &= TestEnvironments._check_valid_tensor(value)
elif isinstance(value, torch.Tensor):
valid_tensor &= not torch.any(torch.isnan(value))
return valid_tensor
else:
raise ValueError(f"Input data of invalid type: {type(data)}.")
if __name__ == "__main__":
run_tests()
| 4,679 | Python | 33.666666 | 105 | 0.600769 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/test/test_data_collector.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher, run_tests
# launch the simulator
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import os
import torch
import unittest
from omni.isaac.orbit_tasks.utils.data_collector import RobomimicDataCollector
class TestRobomimicDataCollector(unittest.TestCase):
"""Test dataset flushing behavior of robomimic data collector."""
def test_basic_flushing(self):
"""Adds random data into the collector and checks saving of the data."""
# name of the environment (needed by robomimic)
task_name = "My-Task-v0"
# specify directory for logging experiments
test_dir = os.path.dirname(os.path.abspath(__file__))
log_dir = os.path.join(test_dir, "output", "demos")
# name of the file to save data
filename = "hdf_dataset.hdf5"
# number of episodes to collect
num_demos = 10
# number of environments to simulate
num_envs = 4
# create data-collector
collector_interface = RobomimicDataCollector(task_name, log_dir, filename, num_demos)
# reset the collector
collector_interface.reset()
while not collector_interface.is_stopped():
# generate random data to store
# -- obs
obs = {"joint_pos": torch.randn(num_envs, 7), "joint_vel": torch.randn(num_envs, 7)}
# -- actions
actions = torch.randn(num_envs, 7)
# -- next obs
next_obs = {"joint_pos": torch.randn(num_envs, 7), "joint_vel": torch.randn(num_envs, 7)}
# -- rewards
rewards = torch.randn(num_envs)
# -- dones
dones = torch.rand(num_envs) > 0.5
# store signals
# -- obs
for key, value in obs.items():
collector_interface.add(f"obs/{key}", value)
# -- actions
collector_interface.add("actions", actions)
# -- next_obs
for key, value in next_obs.items():
collector_interface.add(f"next_obs/{key}", value.cpu().numpy())
# -- rewards
collector_interface.add("rewards", rewards)
# -- dones
collector_interface.add("dones", dones)
# flush data from collector for successful environments
# note: in this case we flush all the time
reset_env_ids = dones.nonzero(as_tuple=False).squeeze(-1)
collector_interface.flush(reset_env_ids)
# close collector
collector_interface.close()
# TODO: Add inspection of the saved dataset as part of the test.
if __name__ == "__main__":
run_tests()
| 2,906 | Python | 32.802325 | 101 | 0.602546 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/test/test_record_video.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher, run_tests
# launch the simulator
app_launcher = AppLauncher(headless=True, offscreen_render=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import os
import torch
import unittest
import omni.usd
from omni.isaac.orbit.envs import RLTaskEnvCfg
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils import parse_env_cfg
class TestRecordVideoWrapper(unittest.TestCase):
"""Test recording videos using the RecordVideo wrapper."""
@classmethod
def setUpClass(cls):
# acquire all Isaac environments names
cls.registered_tasks = list()
for task_spec in gym.registry.values():
if "Isaac" in task_spec.id:
cls.registered_tasks.append(task_spec.id)
# sort environments by name
cls.registered_tasks.sort()
# print all existing task names
print(">>> All registered environments:", cls.registered_tasks)
# directory to save videos
cls.videos_dir = os.path.join(os.path.dirname(__file__), "output", "videos")
def setUp(self) -> None:
# common parameters
self.num_envs = 16
self.use_gpu = True
# video parameters
self.step_trigger = lambda step: step % 225 == 0
self.video_length = 200
def test_record_video(self):
"""Run random actions agent with recording of videos."""
for task_name in self.registered_tasks:
with self.subTest(task_name=task_name):
print(f">>> Running test for environment: {task_name}")
# create a new stage
omni.usd.get_context().new_stage()
# parse configuration
env_cfg: RLTaskEnvCfg = parse_env_cfg(task_name, use_gpu=self.use_gpu, num_envs=self.num_envs)
# create environment
env = gym.make(task_name, cfg=env_cfg, render_mode="rgb_array")
# directory to save videos
videos_dir = os.path.join(self.videos_dir, task_name)
# wrap environment to record videos
env = gym.wrappers.RecordVideo(
env,
videos_dir,
step_trigger=self.step_trigger,
video_length=self.video_length,
disable_logger=True,
)
# reset environment
env.reset()
# simulate environment
with torch.inference_mode():
for _ in range(500):
# compute zero actions
actions = 2 * torch.rand(env.action_space.shape, device=env.unwrapped.device) - 1
# apply actions
_ = env.step(actions)
# close the simulator
env.close()
if __name__ == "__main__":
run_tests()
| 3,127 | Python | 31.926315 | 110 | 0.579789 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/test/wrappers/test_rsl_rl_wrapper.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher, run_tests
# launch the simulator
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import torch
import unittest
import omni.usd
from omni.isaac.orbit.envs import RLTaskEnvCfg
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils.parse_cfg import parse_env_cfg
from omni.isaac.orbit_tasks.utils.wrappers.rsl_rl import RslRlVecEnvWrapper
class TestRslRlVecEnvWrapper(unittest.TestCase):
"""Test that RSL-RL VecEnv wrapper works as expected."""
@classmethod
def setUpClass(cls):
# acquire all Isaac environments names
cls.registered_tasks = list()
for task_spec in gym.registry.values():
if "Isaac" in task_spec.id:
cls.registered_tasks.append(task_spec.id)
# sort environments by name
cls.registered_tasks.sort()
# only pick the first four environments to test
cls.registered_tasks = cls.registered_tasks[:4]
# print all existing task names
print(">>> All registered environments:", cls.registered_tasks)
def setUp(self) -> None:
# common parameters
self.num_envs = 64
self.use_gpu = True
def test_random_actions(self):
"""Run random actions and check environments return valid signals."""
for task_name in self.registered_tasks:
with self.subTest(task_name=task_name):
print(f">>> Running test for environment: {task_name}")
# create a new stage
omni.usd.get_context().new_stage()
# parse configuration
env_cfg: RLTaskEnvCfg = parse_env_cfg(task_name, use_gpu=self.use_gpu, num_envs=self.num_envs)
# create environment
env = gym.make(task_name, cfg=env_cfg)
# wrap environment
env = RslRlVecEnvWrapper(env)
# reset environment
obs, extras = env.reset()
# check signal
self.assertTrue(self._check_valid_tensor(obs))
self.assertTrue(self._check_valid_tensor(extras))
# simulate environment for 1000 steps
with torch.inference_mode():
for _ in range(1000):
# sample actions from -1 to 1
actions = 2 * torch.rand(env.action_space.shape, device=env.unwrapped.device) - 1
# apply actions
transition = env.step(actions)
# check signals
for data in transition:
self.assertTrue(self._check_valid_tensor(data), msg=f"Invalid data: {data}")
# close the environment
print(f">>> Closing environment: {task_name}")
env.close()
def test_no_time_outs(self):
"""Check that environments with finite horizon do not send time-out signals."""
for task_name in self.registered_tasks:
with self.subTest(task_name=task_name):
print(f">>> Running test for environment: {task_name}")
# create a new stage
omni.usd.get_context().new_stage()
# parse configuration
env_cfg: RLTaskEnvCfg = parse_env_cfg(task_name, use_gpu=self.use_gpu, num_envs=self.num_envs)
# change to finite horizon
env_cfg.is_finite_horizon = True
# create environment
env = gym.make(task_name, cfg=env_cfg)
# wrap environment
env = RslRlVecEnvWrapper(env)
# reset environment
_, extras = env.reset()
# check signal
self.assertNotIn("time_outs", extras, msg="Time-out signal found in finite horizon environment.")
# simulate environment for 10 steps
with torch.inference_mode():
for _ in range(10):
# sample actions from -1 to 1
actions = 2 * torch.rand(env.action_space.shape, device=env.unwrapped.device) - 1
# apply actions
extras = env.step(actions)[-1]
# check signals
self.assertNotIn(
"time_outs", extras, msg="Time-out signal found in finite horizon environment."
)
# close the environment
print(f">>> Closing environment: {task_name}")
env.close()
"""
Helper functions.
"""
@staticmethod
def _check_valid_tensor(data: torch.Tensor | dict) -> bool:
"""Checks if given data does not have corrupted values.
Args:
data: Data buffer.
Returns:
True if the data is valid.
"""
if isinstance(data, torch.Tensor):
return not torch.any(torch.isnan(data))
elif isinstance(data, dict):
valid_tensor = True
for value in data.values():
if isinstance(value, dict):
valid_tensor &= TestRslRlVecEnvWrapper._check_valid_tensor(value)
elif isinstance(value, torch.Tensor):
valid_tensor &= not torch.any(torch.isnan(value))
return valid_tensor
else:
raise ValueError(f"Input data of invalid type: {type(data)}.")
if __name__ == "__main__":
run_tests()
| 5,796 | Python | 36.160256 | 113 | 0.559179 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/test/wrappers/test_rl_games_wrapper.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher, run_tests
# launch the simulator
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import torch
import unittest
import omni.usd
from omni.isaac.orbit.envs import RLTaskEnvCfg
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils.parse_cfg import parse_env_cfg
from omni.isaac.orbit_tasks.utils.wrappers.rl_games import RlGamesVecEnvWrapper
class TestRlGamesVecEnvWrapper(unittest.TestCase):
"""Test that RL-Games VecEnv wrapper works as expected."""
@classmethod
def setUpClass(cls):
# acquire all Isaac environments names
cls.registered_tasks = list()
for task_spec in gym.registry.values():
if "Isaac" in task_spec.id:
cls.registered_tasks.append(task_spec.id)
# sort environments by name
cls.registered_tasks.sort()
# only pick the first four environments to test
cls.registered_tasks = cls.registered_tasks[:4]
# print all existing task names
print(">>> All registered environments:", cls.registered_tasks)
def setUp(self) -> None:
# common parameters
self.num_envs = 64
self.use_gpu = True
def test_random_actions(self):
"""Run random actions and check environments return valid signals."""
for task_name in self.registered_tasks:
with self.subTest(task_name=task_name):
print(f">>> Running test for environment: {task_name}")
# create a new stage
omni.usd.get_context().new_stage()
# parse configuration
env_cfg: RLTaskEnvCfg = parse_env_cfg(task_name, use_gpu=self.use_gpu, num_envs=self.num_envs)
# create environment
env = gym.make(task_name, cfg=env_cfg)
# wrap environment
env = RlGamesVecEnvWrapper(env, "cuda:0", 100, 100)
# reset environment
obs = env.reset()
# check signal
self.assertTrue(self._check_valid_tensor(obs))
# simulate environment for 100 steps
with torch.inference_mode():
for _ in range(100):
# sample actions from -1 to 1
actions = 2 * torch.rand(env.num_envs, *env.action_space.shape, device=env.device) - 1
# apply actions
transition = env.step(actions)
# check signals
for data in transition:
self.assertTrue(self._check_valid_tensor(data), msg=f"Invalid data: {data}")
# close the environment
print(f">>> Closing environment: {task_name}")
env.close()
"""
Helper functions.
"""
@staticmethod
def _check_valid_tensor(data: torch.Tensor | dict) -> bool:
"""Checks if given data does not have corrupted values.
Args:
data: Data buffer.
Returns:
True if the data is valid.
"""
if isinstance(data, torch.Tensor):
return not torch.any(torch.isnan(data))
elif isinstance(data, dict):
valid_tensor = True
for value in data.values():
if isinstance(value, dict):
valid_tensor &= TestRlGamesVecEnvWrapper._check_valid_tensor(value)
elif isinstance(value, torch.Tensor):
valid_tensor &= not torch.any(torch.isnan(value))
return valid_tensor
else:
raise ValueError(f"Input data of invalid type: {type(data)}.")
if __name__ == "__main__":
run_tests()
| 3,997 | Python | 33.17094 | 110 | 0.583688 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/test/wrappers/test_sb3_wrapper.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher, run_tests
# launch the simulator
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import numpy as np
import torch
import unittest
import omni.usd
from omni.isaac.orbit.envs import RLTaskEnvCfg
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils.parse_cfg import parse_env_cfg
from omni.isaac.orbit_tasks.utils.wrappers.sb3 import Sb3VecEnvWrapper
class TestStableBaselines3VecEnvWrapper(unittest.TestCase):
"""Test that RSL-RL VecEnv wrapper works as expected."""
@classmethod
def setUpClass(cls):
# acquire all Isaac environments names
cls.registered_tasks = list()
for task_spec in gym.registry.values():
if "Isaac" in task_spec.id:
cls.registered_tasks.append(task_spec.id)
# sort environments by name
cls.registered_tasks.sort()
# only pick the first four environments to test
cls.registered_tasks = cls.registered_tasks[:4]
# print all existing task names
print(">>> All registered environments:", cls.registered_tasks)
def setUp(self) -> None:
# common parameters
self.num_envs = 64
self.use_gpu = True
def test_random_actions(self):
"""Run random actions and check environments return valid signals."""
for task_name in self.registered_tasks:
with self.subTest(task_name=task_name):
print(f">>> Running test for environment: {task_name}")
# create a new stage
omni.usd.get_context().new_stage()
# parse configuration
env_cfg: RLTaskEnvCfg = parse_env_cfg(task_name, use_gpu=self.use_gpu, num_envs=self.num_envs)
# create environment
env = gym.make(task_name, cfg=env_cfg)
# wrap environment
env = Sb3VecEnvWrapper(env)
# reset environment
obs = env.reset()
# check signal
self.assertTrue(self._check_valid_array(obs))
# simulate environment for 1000 steps
with torch.inference_mode():
for _ in range(1000):
# sample actions from -1 to 1
actions = 2 * np.random.rand(env.num_envs, *env.action_space.shape) - 1
# apply actions
transition = env.step(actions)
# check signals
for data in transition:
self.assertTrue(self._check_valid_array(data), msg=f"Invalid data: {data}")
# close the environment
print(f">>> Closing environment: {task_name}")
env.close()
"""
Helper functions.
"""
@staticmethod
def _check_valid_array(data: np.ndarray | dict | list) -> bool:
"""Checks if given data does not have corrupted values.
Args:
data: Data buffer.
Returns:
True if the data is valid.
"""
if isinstance(data, np.ndarray):
return not np.any(np.isnan(data))
elif isinstance(data, dict):
valid_array = True
for value in data.values():
if isinstance(value, dict):
valid_array &= TestStableBaselines3VecEnvWrapper._check_valid_array(value)
elif isinstance(value, np.ndarray):
valid_array &= not np.any(np.isnan(value))
return valid_array
elif isinstance(data, list):
valid_array = True
for value in data:
valid_array &= TestStableBaselines3VecEnvWrapper._check_valid_array(value)
return valid_array
else:
raise ValueError(f"Input data of invalid type: {type(data)}.")
if __name__ == "__main__":
run_tests()
| 4,188 | Python | 33.05691 | 110 | 0.582139 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/config/extension.toml | [package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.6.1"
# Description
title = "ORBIT Environments"
description="Extension containing suite of environments for robot learning."
readme = "docs/README.md"
repository = "https://github.com/NVIDIA-Omniverse/Orbit"
category = "robotics"
keywords = ["robotics", "rl", "il", "learning"]
[dependencies]
"omni.isaac.orbit" = {}
"omni.isaac.orbit_assets" = {}
"omni.isaac.core" = {}
"omni.isaac.gym" = {}
"omni.replicator.isaac" = {}
[[python.module]]
name = "omni.isaac.orbit_tasks"
| 557 | TOML | 23.260869 | 76 | 0.696589 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Package containing task implementations for various robotic environments."""
import os
import toml
# Conveniences to other module directories via relative paths
ORBIT_TASKS_EXT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../"))
"""Path to the extension source directory."""
ORBIT_TASKS_METADATA = toml.load(os.path.join(ORBIT_TASKS_EXT_DIR, "config", "extension.toml"))
"""Extension metadata dictionary parsed from the extension.toml file."""
# Configure the module-level variables
__version__ = ORBIT_TASKS_METADATA["package"]["version"]
##
# Register Gym environments.
##
from .utils import import_packages
# The blacklist is used to prevent importing configs from sub-packages
_BLACKLIST_PKGS = ["utils"]
# Import all configs in this package
import_packages(__name__, _BLACKLIST_PKGS)
| 946 | Python | 29.548386 | 95 | 0.742072 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Classic environments for control.
These environments are based on the MuJoCo environments provided by OpenAI.
Reference:
https://github.com/openai/gym/tree/master/gym/envs/mujoco
"""
| 315 | Python | 23.307691 | 75 | 0.75873 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/ant_env_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.actuators import ImplicitActuatorCfg
from omni.isaac.orbit.assets import ArticulationCfg, AssetBaseCfg
from omni.isaac.orbit.envs import RLTaskEnvCfg
from omni.isaac.orbit.managers import EventTermCfg as EventTerm
from omni.isaac.orbit.managers import ObservationGroupCfg as ObsGroup
from omni.isaac.orbit.managers import ObservationTermCfg as ObsTerm
from omni.isaac.orbit.managers import RewardTermCfg as RewTerm
from omni.isaac.orbit.managers import SceneEntityCfg
from omni.isaac.orbit.managers import TerminationTermCfg as DoneTerm
from omni.isaac.orbit.scene import InteractiveSceneCfg
from omni.isaac.orbit.terrains import TerrainImporterCfg
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.utils.assets import ISAAC_NUCLEUS_DIR
import omni.isaac.orbit_tasks.classic.humanoid.mdp as mdp
##
# Scene definition
##
@configclass
class MySceneCfg(InteractiveSceneCfg):
"""Configuration for the terrain scene with an ant robot."""
# terrain
terrain = TerrainImporterCfg(
prim_path="/World/ground",
terrain_type="plane",
collision_group=-1,
physics_material=sim_utils.RigidBodyMaterialCfg(
friction_combine_mode="average",
restitution_combine_mode="average",
static_friction=1.0,
dynamic_friction=1.0,
restitution=0.0,
),
debug_vis=False,
)
# robot
robot = ArticulationCfg(
prim_path="{ENV_REGEX_NS}/Robot",
spawn=sim_utils.UsdFileCfg(
usd_path=f"{ISAAC_NUCLEUS_DIR}/Robots/Ant/ant_instanceable.usd",
rigid_props=sim_utils.RigidBodyPropertiesCfg(
disable_gravity=False,
max_depenetration_velocity=10.0,
enable_gyroscopic_forces=True,
),
articulation_props=sim_utils.ArticulationRootPropertiesCfg(
enabled_self_collisions=False,
solver_position_iteration_count=4,
solver_velocity_iteration_count=0,
sleep_threshold=0.005,
stabilization_threshold=0.001,
),
copy_from_source=False,
),
init_state=ArticulationCfg.InitialStateCfg(
pos=(0.0, 0.0, 0.5),
joint_pos={
".*_leg": 0.0,
"front_left_foot": 0.785398, # 45 degrees
"front_right_foot": -0.785398,
"left_back_foot": -0.785398,
"right_back_foot": 0.785398,
},
),
actuators={
"body": ImplicitActuatorCfg(
joint_names_expr=[".*"],
stiffness=0.0,
damping=0.0,
),
},
)
# lights
light = AssetBaseCfg(
prim_path="/World/light",
spawn=sim_utils.DistantLightCfg(color=(0.75, 0.75, 0.75), intensity=3000.0),
)
##
# MDP settings
##
@configclass
class CommandsCfg:
"""Command terms for the MDP."""
# no commands for this MDP
null = mdp.NullCommandCfg()
@configclass
class ActionsCfg:
"""Action specifications for the MDP."""
joint_effort = mdp.JointEffortActionCfg(asset_name="robot", joint_names=[".*"], scale=7.5)
@configclass
class ObservationsCfg:
"""Observation specifications for the MDP."""
@configclass
class PolicyCfg(ObsGroup):
"""Observations for the policy."""
base_height = ObsTerm(func=mdp.base_pos_z)
base_lin_vel = ObsTerm(func=mdp.base_lin_vel)
base_ang_vel = ObsTerm(func=mdp.base_ang_vel)
base_yaw_roll = ObsTerm(func=mdp.base_yaw_roll)
base_angle_to_target = ObsTerm(func=mdp.base_angle_to_target, params={"target_pos": (1000.0, 0.0, 0.0)})
base_up_proj = ObsTerm(func=mdp.base_up_proj)
base_heading_proj = ObsTerm(func=mdp.base_heading_proj, params={"target_pos": (1000.0, 0.0, 0.0)})
joint_pos_norm = ObsTerm(func=mdp.joint_pos_limit_normalized)
joint_vel_rel = ObsTerm(func=mdp.joint_vel_rel, scale=0.2)
feet_body_forces = ObsTerm(
func=mdp.body_incoming_wrench,
scale=0.1,
params={
"asset_cfg": SceneEntityCfg(
"robot", body_names=["front_left_foot", "front_right_foot", "left_back_foot", "right_back_foot"]
)
},
)
actions = ObsTerm(func=mdp.last_action)
def __post_init__(self):
self.enable_corruption = False
self.concatenate_terms = True
# observation groups
policy: PolicyCfg = PolicyCfg()
@configclass
class EventCfg:
"""Configuration for events."""
reset_base = EventTerm(
func=mdp.reset_root_state_uniform,
mode="reset",
params={"pose_range": {}, "velocity_range": {}},
)
reset_robot_joints = EventTerm(
func=mdp.reset_joints_by_offset,
mode="reset",
params={
"position_range": (-0.2, 0.2),
"velocity_range": (-0.1, 0.1),
},
)
@configclass
class RewardsCfg:
"""Reward terms for the MDP."""
# (1) Reward for moving forward
progress = RewTerm(func=mdp.progress_reward, weight=1.0, params={"target_pos": (1000.0, 0.0, 0.0)})
# (2) Stay alive bonus
alive = RewTerm(func=mdp.is_alive, weight=0.5)
# (3) Reward for non-upright posture
upright = RewTerm(func=mdp.upright_posture_bonus, weight=0.1, params={"threshold": 0.93})
# (4) Reward for moving in the right direction
move_to_target = RewTerm(
func=mdp.move_to_target_bonus, weight=0.5, params={"threshold": 0.8, "target_pos": (1000.0, 0.0, 0.0)}
)
# (5) Penalty for large action commands
action_l2 = RewTerm(func=mdp.action_l2, weight=-0.005)
# (6) Penalty for energy consumption
energy = RewTerm(func=mdp.power_consumption, weight=-0.05, params={"gear_ratio": {".*": 15.0}})
# (7) Penalty for reaching close to joint limits
joint_limits = RewTerm(
func=mdp.joint_limits_penalty_ratio, weight=-0.1, params={"threshold": 0.99, "gear_ratio": {".*": 15.0}}
)
@configclass
class TerminationsCfg:
"""Termination terms for the MDP."""
# (1) Terminate if the episode length is exceeded
time_out = DoneTerm(func=mdp.time_out, time_out=True)
# (2) Terminate if the robot falls
torso_height = DoneTerm(func=mdp.root_height_below_minimum, params={"minimum_height": 0.31})
@configclass
class CurriculumCfg:
"""Curriculum terms for the MDP."""
pass
@configclass
class AntEnvCfg(RLTaskEnvCfg):
"""Configuration for the MuJoCo-style Ant walking environment."""
# Scene settings
scene: MySceneCfg = MySceneCfg(num_envs=4096, env_spacing=5.0)
# Basic settings
observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg()
commands: CommandsCfg = CommandsCfg()
# MDP settings
rewards: RewardsCfg = RewardsCfg()
terminations: TerminationsCfg = TerminationsCfg()
events: EventCfg = EventCfg()
curriculum: CurriculumCfg = CurriculumCfg()
def __post_init__(self):
"""Post initialization."""
# general settings
self.decimation = 2
self.episode_length_s = 16.0
# simulation settings
self.sim.dt = 1 / 120.0
self.sim.physx.bounce_threshold_velocity = 0.2
# default friction material
self.sim.physics_material.static_friction = 1.0
self.sim.physics_material.dynamic_friction = 1.0
self.sim.physics_material.restitution = 0.0
| 7,721 | Python | 31.445378 | 116 | 0.627898 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""
Ant locomotion environment (similar to OpenAI Gym Ant-v2).
"""
import gymnasium as gym
from . import agents, ant_env_cfg
##
# Register Gym environments.
##
gym.register(
id="Isaac-Ant-v0",
entry_point="omni.isaac.orbit.envs:RLTaskEnv",
disable_env_checker=True,
kwargs={
"env_cfg_entry_point": ant_env_cfg.AntEnvCfg,
"rsl_rl_cfg_entry_point": agents.rsl_rl_ppo_cfg.AntPPORunnerCfg,
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
"skrl_cfg_entry_point": f"{agents.__name__}:skrl_ppo_cfg.yaml",
"sb3_cfg_entry_point": f"{agents.__name__}:sb3_ppo_cfg.yaml",
},
)
| 776 | Python | 24.899999 | 79 | 0.653351 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/agents/rsl_rl_ppo_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit_tasks.utils.wrappers.rsl_rl import (
RslRlOnPolicyRunnerCfg,
RslRlPpoActorCriticCfg,
RslRlPpoAlgorithmCfg,
)
@configclass
class AntPPORunnerCfg(RslRlOnPolicyRunnerCfg):
num_steps_per_env = 32
max_iterations = 1000
save_interval = 50
experiment_name = "ant"
empirical_normalization = False
policy = RslRlPpoActorCriticCfg(
init_noise_std=1.0,
actor_hidden_dims=[400, 200, 100],
critic_hidden_dims=[400, 200, 100],
activation="elu",
)
algorithm = RslRlPpoAlgorithmCfg(
value_loss_coef=1.0,
use_clipped_value_loss=True,
clip_param=0.2,
entropy_coef=0.0,
num_learning_epochs=5,
num_mini_batches=4,
learning_rate=5.0e-4,
schedule="adaptive",
gamma=0.99,
lam=0.95,
desired_kl=0.01,
max_grad_norm=1.0,
)
| 1,068 | Python | 24.45238 | 58 | 0.641386 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/agents/skrl_ppo_cfg.yaml | seed: 42
# Models are instantiated using skrl's model instantiator utility
# https://skrl.readthedocs.io/en/develop/modules/skrl.utils.model_instantiators.html
models:
separate: False
policy: # see skrl.utils.model_instantiators.gaussian_model for parameter details
clip_actions: True
clip_log_std: True
initial_log_std: 0
min_log_std: -20.0
max_log_std: 2.0
input_shape: "Shape.STATES"
hiddens: [256, 128, 64]
hidden_activation: ["elu", "elu", "elu"]
output_shape: "Shape.ACTIONS"
output_activation: "tanh"
output_scale: 1.0
value: # see skrl.utils.model_instantiators.deterministic_model for parameter details
clip_actions: False
input_shape: "Shape.STATES"
hiddens: [256, 128, 64]
hidden_activation: ["elu", "elu", "elu"]
output_shape: "Shape.ONE"
output_activation: ""
output_scale: 1.0
# PPO agent configuration (field names are from PPO_DEFAULT_CONFIG)
# https://skrl.readthedocs.io/en/latest/modules/skrl.agents.ppo.html
agent:
rollouts: 16
learning_epochs: 8
mini_batches: 4
discount_factor: 0.99
lambda: 0.95
learning_rate: 3.e-4
learning_rate_scheduler: "KLAdaptiveLR"
learning_rate_scheduler_kwargs:
kl_threshold: 0.008
state_preprocessor: "RunningStandardScaler"
state_preprocessor_kwargs: null
value_preprocessor: "RunningStandardScaler"
value_preprocessor_kwargs: null
random_timesteps: 0
learning_starts: 0
grad_norm_clip: 1.0
ratio_clip: 0.2
value_clip: 0.2
clip_predicted_values: True
entropy_loss_scale: 0.0
value_loss_scale: 1.0
kl_threshold: 0
rewards_shaper_scale: 0.01
# logging and checkpoint
experiment:
directory: "ant"
experiment_name: ""
write_interval: 40
checkpoint_interval: 400
# Sequential trainer
# https://skrl.readthedocs.io/en/latest/modules/skrl.trainers.sequential.html
trainer:
timesteps: 8000
| 1,888 | YAML | 27.194029 | 88 | 0.710805 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/agents/sb3_ppo_cfg.yaml | # Reference: https://github.com/DLR-RM/rl-baselines3-zoo/blob/master/hyperparams/ppo.yml#L161
seed: 42
n_timesteps: !!float 1e7
policy: 'MlpPolicy'
batch_size: 128
n_steps: 512
gamma: 0.99
gae_lambda: 0.9
n_epochs: 20
ent_coef: 0.0
sde_sample_freq: 4
max_grad_norm: 0.5
vf_coef: 0.5
learning_rate: !!float 3e-5
use_sde: True
clip_range: 0.4
policy_kwargs: "dict(
log_std_init=-1,
ortho_init=False,
activation_fn=nn.ReLU,
net_arch=dict(pi=[256, 256], vf=[256, 256])
)"
| 557 | YAML | 22.249999 | 93 | 0.597846 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/agents/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from . import rsl_rl_ppo_cfg
| 152 | Python | 20.85714 | 56 | 0.736842 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/agents/rl_games_ppo_cfg.yaml | params:
seed: 42
# environment wrapper clipping
env:
clip_actions: 1.0
algo:
name: a2c_continuous
model:
name: continuous_a2c_logstd
network:
name: actor_critic
separate: False
space:
continuous:
mu_activation: None
sigma_activation: None
mu_init:
name: default
sigma_init:
name: const_initializer
val: 0
fixed_sigma: True
mlp:
units: [256, 128, 64]
activation: elu
d2rl: False
initializer:
name: default
regularizer:
name: None
load_checkpoint: False # flag which sets whether to load the checkpoint
load_path: '' # path to the checkpoint to load
config:
name: ant
env_name: rlgpu
device: 'cuda:0'
device_name: 'cuda:0'
multi_gpu: False
ppo: True
mixed_precision: True
normalize_input: True
normalize_value: True
value_bootstrap: True
num_actors: -1
reward_shaper:
scale_value: 0.6
normalize_advantage: True
gamma: 0.99
tau: 0.95
learning_rate: 3e-4
lr_schedule: adaptive
schedule_type: legacy
kl_threshold: 0.008
score_to_win: 20000
max_epochs: 500
save_best_after: 100
save_frequency: 50
grad_norm: 1.0
entropy_coef: 0.0
truncate_grads: True
e_clip: 0.2
horizon_length: 16
minibatch_size: 32768
mini_epochs: 4
critic_coef: 2
clip_value: True
seq_length: 4
bounds_loss_coef: 0.0001
| 1,502 | YAML | 18.51948 | 73 | 0.601198 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""
Cartpole balancing environment.
"""
import gymnasium as gym
from . import agents
from .cartpole_env_cfg import CartpoleEnvCfg
##
# Register Gym environments.
##
gym.register(
id="Isaac-Cartpole-v0",
entry_point="omni.isaac.orbit.envs:RLTaskEnv",
disable_env_checker=True,
kwargs={
"env_cfg_entry_point": CartpoleEnvCfg,
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
"rsl_rl_cfg_entry_point": agents.rsl_rl_ppo_cfg.CartpolePPORunnerCfg,
"skrl_cfg_entry_point": f"{agents.__name__}:skrl_ppo_cfg.yaml",
"sb3_cfg_entry_point": f"{agents.__name__}:sb3_ppo_cfg.yaml",
},
)
| 784 | Python | 24.32258 | 79 | 0.667092 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import math
import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import ArticulationCfg, AssetBaseCfg
from omni.isaac.orbit.envs import RLTaskEnvCfg
from omni.isaac.orbit.managers import EventTermCfg as EventTerm
from omni.isaac.orbit.managers import ObservationGroupCfg as ObsGroup
from omni.isaac.orbit.managers import ObservationTermCfg as ObsTerm
from omni.isaac.orbit.managers import RewardTermCfg as RewTerm
from omni.isaac.orbit.managers import SceneEntityCfg
from omni.isaac.orbit.managers import TerminationTermCfg as DoneTerm
from omni.isaac.orbit.scene import InteractiveSceneCfg
from omni.isaac.orbit.utils import configclass
import omni.isaac.orbit_tasks.classic.cartpole.mdp as mdp
##
# Pre-defined configs
##
from omni.isaac.orbit_assets.cartpole import CARTPOLE_CFG # isort:skip
##
# Scene definition
##
@configclass
class CartpoleSceneCfg(InteractiveSceneCfg):
"""Configuration for a cart-pole scene."""
# ground plane
ground = AssetBaseCfg(
prim_path="/World/ground",
spawn=sim_utils.GroundPlaneCfg(size=(100.0, 100.0)),
)
# cartpole
robot: ArticulationCfg = CARTPOLE_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")
# lights
dome_light = AssetBaseCfg(
prim_path="/World/DomeLight",
spawn=sim_utils.DomeLightCfg(color=(0.9, 0.9, 0.9), intensity=500.0),
)
distant_light = AssetBaseCfg(
prim_path="/World/DistantLight",
spawn=sim_utils.DistantLightCfg(color=(0.9, 0.9, 0.9), intensity=2500.0),
init_state=AssetBaseCfg.InitialStateCfg(rot=(0.738, 0.477, 0.477, 0.0)),
)
##
# MDP settings
##
@configclass
class CommandsCfg:
"""Command terms for the MDP."""
# no commands for this MDP
null = mdp.NullCommandCfg()
@configclass
class ActionsCfg:
"""Action specifications for the MDP."""
joint_effort = mdp.JointEffortActionCfg(asset_name="robot", joint_names=["slider_to_cart"], scale=100.0)
@configclass
class ObservationsCfg:
"""Observation specifications for the MDP."""
@configclass
class PolicyCfg(ObsGroup):
"""Observations for policy group."""
# observation terms (order preserved)
joint_pos_rel = ObsTerm(func=mdp.joint_pos_rel)
joint_vel_rel = ObsTerm(func=mdp.joint_vel_rel)
def __post_init__(self) -> None:
self.enable_corruption = False
self.concatenate_terms = True
# observation groups
policy: PolicyCfg = PolicyCfg()
@configclass
class EventCfg:
"""Configuration for events."""
# reset
reset_cart_position = EventTerm(
func=mdp.reset_joints_by_offset,
mode="reset",
params={
"asset_cfg": SceneEntityCfg("robot", joint_names=["slider_to_cart"]),
"position_range": (-1.0, 1.0),
"velocity_range": (-0.5, 0.5),
},
)
reset_pole_position = EventTerm(
func=mdp.reset_joints_by_offset,
mode="reset",
params={
"asset_cfg": SceneEntityCfg("robot", joint_names=["cart_to_pole"]),
"position_range": (-0.25 * math.pi, 0.25 * math.pi),
"velocity_range": (-0.25 * math.pi, 0.25 * math.pi),
},
)
@configclass
class RewardsCfg:
"""Reward terms for the MDP."""
# (1) Constant running reward
alive = RewTerm(func=mdp.is_alive, weight=1.0)
# (2) Failure penalty
terminating = RewTerm(func=mdp.is_terminated, weight=-2.0)
# (3) Primary task: keep pole upright
pole_pos = RewTerm(
func=mdp.joint_pos_target_l2,
weight=-1.0,
params={"asset_cfg": SceneEntityCfg("robot", joint_names=["cart_to_pole"]), "target": 0.0},
)
# (4) Shaping tasks: lower cart velocity
cart_vel = RewTerm(
func=mdp.joint_vel_l1,
weight=-0.01,
params={"asset_cfg": SceneEntityCfg("robot", joint_names=["slider_to_cart"])},
)
# (5) Shaping tasks: lower pole angular velocity
pole_vel = RewTerm(
func=mdp.joint_vel_l1,
weight=-0.005,
params={"asset_cfg": SceneEntityCfg("robot", joint_names=["cart_to_pole"])},
)
@configclass
class TerminationsCfg:
"""Termination terms for the MDP."""
# (1) Time out
time_out = DoneTerm(func=mdp.time_out, time_out=True)
# (2) Cart out of bounds
cart_out_of_bounds = DoneTerm(
func=mdp.joint_pos_out_of_manual_limit,
params={"asset_cfg": SceneEntityCfg("robot", joint_names=["slider_to_cart"]), "bounds": (-3.0, 3.0)},
)
@configclass
class CurriculumCfg:
"""Configuration for the curriculum."""
pass
##
# Environment configuration
##
@configclass
class CartpoleEnvCfg(RLTaskEnvCfg):
"""Configuration for the locomotion velocity-tracking environment."""
# Scene settings
scene: CartpoleSceneCfg = CartpoleSceneCfg(num_envs=4096, env_spacing=4.0)
# Basic settings
observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg()
events: EventCfg = EventCfg()
# MDP settings
curriculum: CurriculumCfg = CurriculumCfg()
rewards: RewardsCfg = RewardsCfg()
terminations: TerminationsCfg = TerminationsCfg()
# No command generator
commands: CommandsCfg = CommandsCfg()
# Post initialization
def __post_init__(self) -> None:
"""Post initialization."""
# general settings
self.decimation = 2
self.episode_length_s = 5
# viewer settings
self.viewer.eye = (8.0, 0.0, 5.0)
# simulation settings
self.sim.dt = 1 / 120
| 5,678 | Python | 26.838235 | 109 | 0.653575 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/agents/rsl_rl_ppo_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit_tasks.utils.wrappers.rsl_rl import (
RslRlOnPolicyRunnerCfg,
RslRlPpoActorCriticCfg,
RslRlPpoAlgorithmCfg,
)
@configclass
class CartpolePPORunnerCfg(RslRlOnPolicyRunnerCfg):
num_steps_per_env = 16
max_iterations = 150
save_interval = 50
experiment_name = "cartpole"
empirical_normalization = False
policy = RslRlPpoActorCriticCfg(
init_noise_std=1.0,
actor_hidden_dims=[32, 32],
critic_hidden_dims=[32, 32],
activation="elu",
)
algorithm = RslRlPpoAlgorithmCfg(
value_loss_coef=1.0,
use_clipped_value_loss=True,
clip_param=0.2,
entropy_coef=0.005,
num_learning_epochs=5,
num_mini_batches=4,
learning_rate=1.0e-3,
schedule="adaptive",
gamma=0.99,
lam=0.95,
desired_kl=0.01,
max_grad_norm=1.0,
)
| 1,065 | Python | 24.380952 | 58 | 0.644131 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/agents/skrl_ppo_cfg.yaml | seed: 42
# Models are instantiated using skrl's model instantiator utility
# https://skrl.readthedocs.io/en/develop/modules/skrl.utils.model_instantiators.html
models:
separate: False
policy: # see skrl.utils.model_instantiators.gaussian_model for parameter details
clip_actions: True
clip_log_std: True
initial_log_std: 0
min_log_std: -20.0
max_log_std: 2.0
input_shape: "Shape.STATES"
hiddens: [32, 32]
hidden_activation: ["elu", "elu"]
output_shape: "Shape.ACTIONS"
output_activation: "tanh"
output_scale: 1.0
value: # see skrl.utils.model_instantiators.deterministic_model for parameter details
clip_actions: False
input_shape: "Shape.STATES"
hiddens: [32, 32]
hidden_activation: ["elu", "elu"]
output_shape: "Shape.ONE"
output_activation: ""
output_scale: 1.0
# PPO agent configuration (field names are from PPO_DEFAULT_CONFIG)
# https://skrl.readthedocs.io/en/latest/modules/skrl.agents.ppo.html
agent:
rollouts: 16
learning_epochs: 5
mini_batches: 4
discount_factor: 0.99
lambda: 0.95
learning_rate: 1.e-3
learning_rate_scheduler: "KLAdaptiveLR"
learning_rate_scheduler_kwargs:
kl_threshold: 0.01
state_preprocessor: "RunningStandardScaler"
state_preprocessor_kwargs: null
value_preprocessor: "RunningStandardScaler"
value_preprocessor_kwargs: null
random_timesteps: 0
learning_starts: 0
grad_norm_clip: 1.0
ratio_clip: 0.2
value_clip: 0.2
clip_predicted_values: True
entropy_loss_scale: 0.0
value_loss_scale: 2.0
kl_threshold: 0
rewards_shaper_scale: 1.0
# logging and checkpoint
experiment:
directory: "cartpole"
experiment_name: ""
write_interval: 12
checkpoint_interval: 120
# Sequential trainer
# https://skrl.readthedocs.io/en/latest/modules/skrl.trainers.sequential.html
trainer:
timesteps: 2400
| 1,865 | YAML | 26.850746 | 88 | 0.713673 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/agents/sb3_ppo_cfg.yaml | # Reference: https://github.com/DLR-RM/rl-baselines3-zoo/blob/master/hyperparams/ppo.yml#L32
seed: 42
n_timesteps: !!float 1e6
policy: 'MlpPolicy'
n_steps: 16
batch_size: 4096
gae_lambda: 0.95
gamma: 0.99
n_epochs: 20
ent_coef: 0.01
learning_rate: !!float 3e-4
clip_range: !!float 0.2
policy_kwargs: "dict(
activation_fn=nn.ELU,
net_arch=[32, 32],
squash_output=False,
)"
vf_coef: 1.0
max_grad_norm: 1.0
| 475 | YAML | 21.666666 | 92 | 0.610526 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/agents/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from . import rsl_rl_ppo_cfg # noqa: F401, F403
| 172 | Python | 23.714282 | 56 | 0.72093 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/agents/rl_games_ppo_cfg.yaml | params:
seed: 42
# environment wrapper clipping
env:
# added to the wrapper
clip_observations: 5.0
# can make custom wrapper?
clip_actions: 1.0
algo:
name: a2c_continuous
model:
name: continuous_a2c_logstd
# doesn't have this fine grained control but made it close
network:
name: actor_critic
separate: False
space:
continuous:
mu_activation: None
sigma_activation: None
mu_init:
name: default
sigma_init:
name: const_initializer
val: 0
fixed_sigma: True
mlp:
units: [32, 32]
activation: elu
d2rl: False
initializer:
name: default
regularizer:
name: None
load_checkpoint: False # flag which sets whether to load the checkpoint
load_path: '' # path to the checkpoint to load
config:
name: cartpole
env_name: rlgpu
device: 'cuda:0'
device_name: 'cuda:0'
multi_gpu: False
ppo: True
mixed_precision: False
normalize_input: False
normalize_value: False
num_actors: -1 # configured from the script (based on num_envs)
reward_shaper:
scale_value: 1.0
normalize_advantage: False
gamma: 0.99
tau : 0.95
learning_rate: 3e-4
lr_schedule: adaptive
kl_threshold: 0.008
score_to_win: 20000
max_epochs: 150
save_best_after: 50
save_frequency: 25
grad_norm: 1.0
entropy_coef: 0.0
truncate_grads: True
e_clip: 0.2
horizon_length: 16
minibatch_size: 8192
mini_epochs: 8
critic_coef: 4
clip_value: True
seq_length: 4
bounds_loss_coef: 0.0001
| 1,648 | YAML | 19.873417 | 73 | 0.61165 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/mdp/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""This sub-module contains the functions that are specific to the cartpole environments."""
from omni.isaac.orbit.envs.mdp import * # noqa: F401, F403
from .rewards import * # noqa: F401, F403
| 321 | Python | 28.272725 | 92 | 0.735202 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/mdp/rewards.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import torch
from typing import TYPE_CHECKING
from omni.isaac.orbit.assets import Articulation
from omni.isaac.orbit.managers import SceneEntityCfg
from omni.isaac.orbit.utils.math import wrap_to_pi
if TYPE_CHECKING:
from omni.isaac.orbit.envs import RLTaskEnv
def joint_pos_target_l2(env: RLTaskEnv, target: float, asset_cfg: SceneEntityCfg) -> torch.Tensor:
"""Penalize joint position deviation from a target value."""
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# wrap the joint positions to (-pi, pi)
joint_pos = wrap_to_pi(asset.data.joint_pos[:, asset_cfg.joint_ids])
# compute the reward
return torch.sum(torch.square(joint_pos - target), dim=1)
| 907 | Python | 32.629628 | 98 | 0.742007 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""
Humanoid locomotion environment (similar to OpenAI Gym Humanoid-v2).
"""
import gymnasium as gym
from . import agents, humanoid_env_cfg
##
# Register Gym environments.
##
gym.register(
id="Isaac-Humanoid-v0",
entry_point="omni.isaac.orbit.envs:RLTaskEnv",
disable_env_checker=True,
kwargs={
"env_cfg_entry_point": humanoid_env_cfg.HumanoidEnvCfg,
"rsl_rl_cfg_entry_point": agents.rsl_rl_ppo_cfg.HumanoidPPORunnerCfg,
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
"skrl_cfg_entry_point": f"{agents.__name__}:skrl_ppo_cfg.yaml",
"sb3_cfg_entry_point": f"{agents.__name__}:sb3_ppo_cfg.yaml",
},
)
| 811 | Python | 26.066666 | 79 | 0.668311 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/humanoid_env_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.actuators import ImplicitActuatorCfg
from omni.isaac.orbit.assets import ArticulationCfg, AssetBaseCfg
from omni.isaac.orbit.envs import RLTaskEnvCfg
from omni.isaac.orbit.managers import EventTermCfg as EventTerm
from omni.isaac.orbit.managers import ObservationGroupCfg as ObsGroup
from omni.isaac.orbit.managers import ObservationTermCfg as ObsTerm
from omni.isaac.orbit.managers import RewardTermCfg as RewTerm
from omni.isaac.orbit.managers import SceneEntityCfg
from omni.isaac.orbit.managers import TerminationTermCfg as DoneTerm
from omni.isaac.orbit.scene import InteractiveSceneCfg
from omni.isaac.orbit.terrains import TerrainImporterCfg
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.utils.assets import ISAAC_NUCLEUS_DIR
import omni.isaac.orbit_tasks.classic.humanoid.mdp as mdp
##
# Scene definition
##
@configclass
class MySceneCfg(InteractiveSceneCfg):
"""Configuration for the terrain scene with a humanoid robot."""
# terrain
terrain = TerrainImporterCfg(
prim_path="/World/ground",
terrain_type="plane",
collision_group=-1,
physics_material=sim_utils.RigidBodyMaterialCfg(static_friction=1.0, dynamic_friction=1.0, restitution=0.0),
debug_vis=False,
)
# robot
robot = ArticulationCfg(
prim_path="{ENV_REGEX_NS}/Robot",
spawn=sim_utils.UsdFileCfg(
usd_path=f"{ISAAC_NUCLEUS_DIR}/Robots/Humanoid/humanoid_instanceable.usd",
rigid_props=sim_utils.RigidBodyPropertiesCfg(
disable_gravity=None,
max_depenetration_velocity=10.0,
enable_gyroscopic_forces=True,
),
articulation_props=sim_utils.ArticulationRootPropertiesCfg(
enabled_self_collisions=True,
solver_position_iteration_count=4,
solver_velocity_iteration_count=0,
sleep_threshold=0.005,
stabilization_threshold=0.001,
),
copy_from_source=False,
),
init_state=ArticulationCfg.InitialStateCfg(
pos=(0.0, 0.0, 1.34),
joint_pos={".*": 0.0},
),
actuators={
"body": ImplicitActuatorCfg(
joint_names_expr=[".*"],
stiffness={
".*_waist.*": 20.0,
".*_upper_arm.*": 10.0,
"pelvis": 10.0,
".*_lower_arm": 2.0,
".*_thigh:0": 10.0,
".*_thigh:1": 20.0,
".*_thigh:2": 10.0,
".*_shin": 5.0,
".*_foot.*": 2.0,
},
damping={
".*_waist.*": 5.0,
".*_upper_arm.*": 5.0,
"pelvis": 5.0,
".*_lower_arm": 1.0,
".*_thigh:0": 5.0,
".*_thigh:1": 5.0,
".*_thigh:2": 5.0,
".*_shin": 0.1,
".*_foot.*": 1.0,
},
),
},
)
# lights
light = AssetBaseCfg(
prim_path="/World/light",
spawn=sim_utils.DistantLightCfg(color=(0.75, 0.75, 0.75), intensity=3000.0),
)
##
# MDP settings
##
@configclass
class CommandsCfg:
"""Command terms for the MDP."""
# no commands for this MDP
null = mdp.NullCommandCfg()
@configclass
class ActionsCfg:
"""Action specifications for the MDP."""
joint_effort = mdp.JointEffortActionCfg(
asset_name="robot",
joint_names=[".*"],
scale={
".*_waist.*": 67.5,
".*_upper_arm.*": 67.5,
"pelvis": 67.5,
".*_lower_arm": 45.0,
".*_thigh:0": 45.0,
".*_thigh:1": 135.0,
".*_thigh:2": 45.0,
".*_shin": 90.0,
".*_foot.*": 22.5,
},
)
@configclass
class ObservationsCfg:
"""Observation specifications for the MDP."""
@configclass
class PolicyCfg(ObsGroup):
"""Observations for the policy."""
base_height = ObsTerm(func=mdp.base_pos_z)
base_lin_vel = ObsTerm(func=mdp.base_lin_vel)
base_ang_vel = ObsTerm(func=mdp.base_ang_vel, scale=0.25)
base_yaw_roll = ObsTerm(func=mdp.base_yaw_roll)
base_angle_to_target = ObsTerm(func=mdp.base_angle_to_target, params={"target_pos": (1000.0, 0.0, 0.0)})
base_up_proj = ObsTerm(func=mdp.base_up_proj)
base_heading_proj = ObsTerm(func=mdp.base_heading_proj, params={"target_pos": (1000.0, 0.0, 0.0)})
joint_pos_norm = ObsTerm(func=mdp.joint_pos_limit_normalized)
joint_vel_rel = ObsTerm(func=mdp.joint_vel_rel, scale=0.1)
feet_body_forces = ObsTerm(
func=mdp.body_incoming_wrench,
scale=0.01,
params={"asset_cfg": SceneEntityCfg("robot", body_names=["left_foot", "right_foot"])},
)
actions = ObsTerm(func=mdp.last_action)
def __post_init__(self):
self.enable_corruption = False
self.concatenate_terms = True
# observation groups
policy: PolicyCfg = PolicyCfg()
@configclass
class EventCfg:
"""Configuration for events."""
reset_base = EventTerm(
func=mdp.reset_root_state_uniform,
mode="reset",
params={"pose_range": {}, "velocity_range": {}},
)
reset_robot_joints = EventTerm(
func=mdp.reset_joints_by_offset,
mode="reset",
params={
"position_range": (-0.2, 0.2),
"velocity_range": (-0.1, 0.1),
},
)
@configclass
class RewardsCfg:
"""Reward terms for the MDP."""
# (1) Reward for moving forward
progress = RewTerm(func=mdp.progress_reward, weight=1.0, params={"target_pos": (1000.0, 0.0, 0.0)})
# (2) Stay alive bonus
alive = RewTerm(func=mdp.is_alive, weight=2.0)
# (3) Reward for non-upright posture
upright = RewTerm(func=mdp.upright_posture_bonus, weight=0.1, params={"threshold": 0.93})
# (4) Reward for moving in the right direction
move_to_target = RewTerm(
func=mdp.move_to_target_bonus, weight=0.5, params={"threshold": 0.8, "target_pos": (1000.0, 0.0, 0.0)}
)
# (5) Penalty for large action commands
action_l2 = RewTerm(func=mdp.action_l2, weight=-0.01)
# (6) Penalty for energy consumption
energy = RewTerm(
func=mdp.power_consumption,
weight=-0.005,
params={
"gear_ratio": {
".*_waist.*": 67.5,
".*_upper_arm.*": 67.5,
"pelvis": 67.5,
".*_lower_arm": 45.0,
".*_thigh:0": 45.0,
".*_thigh:1": 135.0,
".*_thigh:2": 45.0,
".*_shin": 90.0,
".*_foot.*": 22.5,
}
},
)
# (7) Penalty for reaching close to joint limits
joint_limits = RewTerm(
func=mdp.joint_limits_penalty_ratio,
weight=-0.25,
params={
"threshold": 0.98,
"gear_ratio": {
".*_waist.*": 67.5,
".*_upper_arm.*": 67.5,
"pelvis": 67.5,
".*_lower_arm": 45.0,
".*_thigh:0": 45.0,
".*_thigh:1": 135.0,
".*_thigh:2": 45.0,
".*_shin": 90.0,
".*_foot.*": 22.5,
},
},
)
@configclass
class TerminationsCfg:
"""Termination terms for the MDP."""
# (1) Terminate if the episode length is exceeded
time_out = DoneTerm(func=mdp.time_out, time_out=True)
# (2) Terminate if the robot falls
torso_height = DoneTerm(func=mdp.root_height_below_minimum, params={"minimum_height": 0.8})
@configclass
class CurriculumCfg:
"""Curriculum terms for the MDP."""
pass
@configclass
class HumanoidEnvCfg(RLTaskEnvCfg):
"""Configuration for the MuJoCo-style Humanoid walking environment."""
# Scene settings
scene: MySceneCfg = MySceneCfg(num_envs=4096, env_spacing=5.0)
# Basic settings
observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg()
commands: CommandsCfg = CommandsCfg()
# MDP settings
rewards: RewardsCfg = RewardsCfg()
terminations: TerminationsCfg = TerminationsCfg()
events: EventCfg = EventCfg()
curriculum: CurriculumCfg = CurriculumCfg()
def __post_init__(self):
"""Post initialization."""
# general settings
self.decimation = 2
self.episode_length_s = 16.0
# simulation settings
self.sim.dt = 1 / 120.0
self.sim.physx.bounce_threshold_velocity = 0.2
# default friction material
self.sim.physics_material.static_friction = 1.0
self.sim.physics_material.dynamic_friction = 1.0
self.sim.physics_material.restitution = 0.0
| 9,088 | Python | 30.668989 | 116 | 0.558649 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/agents/rsl_rl_ppo_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit_tasks.utils.wrappers.rsl_rl import (
RslRlOnPolicyRunnerCfg,
RslRlPpoActorCriticCfg,
RslRlPpoAlgorithmCfg,
)
@configclass
class HumanoidPPORunnerCfg(RslRlOnPolicyRunnerCfg):
num_steps_per_env = 32
max_iterations = 1000
save_interval = 50
experiment_name = "humanoid"
empirical_normalization = False
policy = RslRlPpoActorCriticCfg(
init_noise_std=1.0,
actor_hidden_dims=[400, 200, 100],
critic_hidden_dims=[400, 200, 100],
activation="elu",
)
algorithm = RslRlPpoAlgorithmCfg(
value_loss_coef=1.0,
use_clipped_value_loss=True,
clip_param=0.2,
entropy_coef=0.0,
num_learning_epochs=5,
num_mini_batches=4,
learning_rate=5.0e-4,
schedule="adaptive",
gamma=0.99,
lam=0.95,
desired_kl=0.01,
max_grad_norm=1.0,
)
| 1,078 | Python | 24.690476 | 58 | 0.644712 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/agents/skrl_ppo_cfg.yaml | seed: 42
# Models are instantiated using skrl's model instantiator utility
# https://skrl.readthedocs.io/en/develop/modules/skrl.utils.model_instantiators.html
models:
separate: False
policy: # see skrl.utils.model_instantiators.gaussian_model for parameter details
clip_actions: True
clip_log_std: True
initial_log_std: 0
min_log_std: -20.0
max_log_std: 2.0
input_shape: "Shape.STATES"
hiddens: [400, 200, 100]
hidden_activation: ["elu", "elu", "elu"]
output_shape: "Shape.ACTIONS"
output_activation: "tanh"
output_scale: 1.0
value: # see skrl.utils.model_instantiators.deterministic_model for parameter details
clip_actions: False
input_shape: "Shape.STATES"
hiddens: [400, 200, 100]
hidden_activation: ["elu", "elu", "elu"]
output_shape: "Shape.ONE"
output_activation: ""
output_scale: 1.0
# PPO agent configuration (field names are from PPO_DEFAULT_CONFIG)
# https://skrl.readthedocs.io/en/latest/modules/skrl.agents.ppo.html
agent:
rollouts: 32
learning_epochs: 8
mini_batches: 8
discount_factor: 0.99
lambda: 0.95
learning_rate: 3.e-4
learning_rate_scheduler: "KLAdaptiveLR"
learning_rate_scheduler_kwargs:
kl_threshold: 0.008
state_preprocessor: "RunningStandardScaler"
state_preprocessor_kwargs: null
value_preprocessor: "RunningStandardScaler"
value_preprocessor_kwargs: null
random_timesteps: 0
learning_starts: 0
grad_norm_clip: 1.0
ratio_clip: 0.2
value_clip: 0.2
clip_predicted_values: True
entropy_loss_scale: 0.0
value_loss_scale: 1.0
kl_threshold: 0
rewards_shaper_scale: 0.01
# logging and checkpoint
experiment:
directory: "humanoid"
experiment_name: ""
write_interval: 80
checkpoint_interval: 800
# Sequential trainer
# https://skrl.readthedocs.io/en/latest/modules/skrl.trainers.sequential.html
trainer:
timesteps: 16000
| 1,896 | YAML | 27.313432 | 88 | 0.712025 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/agents/sb3_ppo_cfg.yaml | # Reference: https://github.com/DLR-RM/rl-baselines3-zoo/blob/master/hyperparams/ppo.yml#L245
seed: 42
policy: 'MlpPolicy'
n_timesteps: !!float 5e7
batch_size: 256
n_steps: 512
gamma: 0.99
learning_rate: !!float 2.5e-4
ent_coef: 0.0
clip_range: 0.2
n_epochs: 10
gae_lambda: 0.95
max_grad_norm: 1.0
vf_coef: 0.5
policy_kwargs: "dict(
log_std_init=-2,
ortho_init=False,
activation_fn=nn.ReLU,
net_arch=dict(pi=[256, 256], vf=[256, 256])
)"
| 527 | YAML | 22.999999 | 93 | 0.590133 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/agents/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from . import rsl_rl_ppo_cfg # noqa: F401, F403
| 172 | Python | 23.714282 | 56 | 0.72093 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/agents/rl_games_ppo_cfg.yaml | params:
seed: 42
# environment wrapper clipping
env:
clip_actions: 1.0
algo:
name: a2c_continuous
model:
name: continuous_a2c_logstd
network:
name: actor_critic
separate: False
space:
continuous:
mu_activation: None
sigma_activation: None
mu_init:
name: default
sigma_init:
name: const_initializer
val: 0
fixed_sigma: True
mlp:
units: [400, 200, 100]
activation: elu
d2rl: False
initializer:
name: default
regularizer:
name: None
load_checkpoint: False # flag which sets whether to load the checkpoint
load_path: '' # path to the checkpoint to load
config:
name: humanoid
env_name: rlgpu
device: 'cuda:0'
device_name: 'cuda:0'
multi_gpu: False
ppo: True
mixed_precision: True
normalize_input: True
normalize_value: True
value_bootstrap: True
num_actors: -1
reward_shaper:
scale_value: 0.6
normalize_advantage: True
gamma: 0.99
tau: 0.95
learning_rate: 5e-4
lr_schedule: adaptive
kl_threshold: 0.01
score_to_win: 20000
max_epochs: 1000
save_best_after: 100
save_frequency: 100
grad_norm: 1.0
entropy_coef: 0.0
truncate_grads: True
e_clip: 0.2
horizon_length: 32
minibatch_size: 32768
mini_epochs: 5
critic_coef: 4
clip_value: True
seq_length: 4
bounds_loss_coef: 0.0001
| 1,483 | YAML | 18.526316 | 73 | 0.601483 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/mdp/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""This sub-module contains the functions that are specific to the humanoid environment."""
from omni.isaac.orbit.envs.mdp import * # noqa: F401, F403
from .observations import *
from .rewards import *
| 328 | Python | 26.416664 | 91 | 0.746951 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/mdp/rewards.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import torch
from typing import TYPE_CHECKING
import omni.isaac.orbit.utils.math as math_utils
import omni.isaac.orbit.utils.string as string_utils
from omni.isaac.orbit.assets import Articulation
from omni.isaac.orbit.managers import ManagerTermBase, RewardTermCfg, SceneEntityCfg
from . import observations as obs
if TYPE_CHECKING:
from omni.isaac.orbit.envs import RLTaskEnv
def upright_posture_bonus(
env: RLTaskEnv, threshold: float, asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")
) -> torch.Tensor:
"""Reward for maintaining an upright posture."""
up_proj = obs.base_up_proj(env, asset_cfg).squeeze(-1)
return (up_proj > threshold).float()
def move_to_target_bonus(
env: RLTaskEnv,
threshold: float,
target_pos: tuple[float, float, float],
asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"),
) -> torch.Tensor:
"""Reward for moving to the target heading."""
heading_proj = obs.base_heading_proj(env, target_pos, asset_cfg).squeeze(-1)
return torch.where(heading_proj > threshold, 1.0, heading_proj / threshold)
class progress_reward(ManagerTermBase):
"""Reward for making progress towards the target."""
def __init__(self, env: RLTaskEnv, cfg: RewardTermCfg):
# initialize the base class
super().__init__(cfg, env)
# create history buffer
self.potentials = torch.zeros(env.num_envs, device=env.device)
self.prev_potentials = torch.zeros_like(self.potentials)
def reset(self, env_ids: torch.Tensor):
# extract the used quantities (to enable type-hinting)
asset: Articulation = self._env.scene["robot"]
# compute projection of current heading to desired heading vector
target_pos = torch.tensor(self.cfg.params["target_pos"], device=self.device)
to_target_pos = target_pos - asset.data.root_pos_w[env_ids, :3]
# reward terms
self.potentials[env_ids] = -torch.norm(to_target_pos, p=2, dim=-1) / self._env.step_dt
self.prev_potentials[env_ids] = self.potentials[env_ids]
def __call__(
self,
env: RLTaskEnv,
target_pos: tuple[float, float, float],
asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"),
) -> torch.Tensor:
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# compute vector to target
target_pos = torch.tensor(target_pos, device=env.device)
to_target_pos = target_pos - asset.data.root_pos_w[:, :3]
to_target_pos[:, 2] = 0.0
# update history buffer and compute new potential
self.prev_potentials[:] = self.potentials[:]
self.potentials[:] = -torch.norm(to_target_pos, p=2, dim=-1) / env.step_dt
return self.potentials - self.prev_potentials
class joint_limits_penalty_ratio(ManagerTermBase):
"""Penalty for violating joint limits weighted by the gear ratio."""
def __init__(self, env: RLTaskEnv, cfg: RewardTermCfg):
# add default argument
if "asset_cfg" not in cfg.params:
cfg.params["asset_cfg"] = SceneEntityCfg("robot")
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[cfg.params["asset_cfg"].name]
# resolve the gear ratio for each joint
self.gear_ratio = torch.ones(env.num_envs, asset.num_joints, device=env.device)
index_list, _, value_list = string_utils.resolve_matching_names_values(
cfg.params["gear_ratio"], asset.joint_names
)
self.gear_ratio[:, index_list] = torch.tensor(value_list, device=env.device)
self.gear_ratio_scaled = self.gear_ratio / torch.max(self.gear_ratio)
def __call__(
self, env: RLTaskEnv, threshold: float, gear_ratio: dict[str, float], asset_cfg: SceneEntityCfg
) -> torch.Tensor:
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# compute the penalty over normalized joints
joint_pos_scaled = math_utils.scale_transform(
asset.data.joint_pos, asset.data.soft_joint_pos_limits[..., 0], asset.data.soft_joint_pos_limits[..., 1]
)
# scale the violation amount by the gear ratio
violation_amount = (torch.abs(joint_pos_scaled) - threshold) / (1 - threshold)
violation_amount = violation_amount * self.gear_ratio_scaled
return torch.sum((torch.abs(joint_pos_scaled) > threshold) * violation_amount, dim=-1)
class power_consumption(ManagerTermBase):
"""Penalty for the power consumed by the actions to the environment.
This is computed as commanded torque times the joint velocity.
"""
def __init__(self, env: RLTaskEnv, cfg: RewardTermCfg):
# add default argument
if "asset_cfg" not in cfg.params:
cfg.params["asset_cfg"] = SceneEntityCfg("robot")
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[cfg.params["asset_cfg"].name]
# resolve the gear ratio for each joint
self.gear_ratio = torch.ones(env.num_envs, asset.num_joints, device=env.device)
index_list, _, value_list = string_utils.resolve_matching_names_values(
cfg.params["gear_ratio"], asset.joint_names
)
self.gear_ratio[:, index_list] = torch.tensor(value_list, device=env.device)
self.gear_ratio_scaled = self.gear_ratio / torch.max(self.gear_ratio)
def __call__(self, env: RLTaskEnv, gear_ratio: dict[str, float], asset_cfg: SceneEntityCfg) -> torch.Tensor:
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# return power = torque * velocity (here actions: joint torques)
return torch.sum(torch.abs(env.action_manager.action * asset.data.joint_vel * self.gear_ratio_scaled), dim=-1)
| 6,069 | Python | 42.985507 | 118 | 0.66782 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/mdp/observations.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import torch
from typing import TYPE_CHECKING
import omni.isaac.orbit.utils.math as math_utils
from omni.isaac.orbit.assets import Articulation
from omni.isaac.orbit.managers import SceneEntityCfg
if TYPE_CHECKING:
from omni.isaac.orbit.envs import BaseEnv
def base_yaw_roll(env: BaseEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")) -> torch.Tensor:
"""Yaw and roll of the base in the simulation world frame."""
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# extract euler angles (in world frame)
roll, _, yaw = math_utils.euler_xyz_from_quat(asset.data.root_quat_w)
# normalize angle to [-pi, pi]
roll = torch.atan2(torch.sin(roll), torch.cos(roll))
yaw = torch.atan2(torch.sin(yaw), torch.cos(yaw))
return torch.cat((yaw.unsqueeze(-1), roll.unsqueeze(-1)), dim=-1)
def base_up_proj(env: BaseEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")) -> torch.Tensor:
"""Projection of the base up vector onto the world up vector."""
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# compute base up vector
base_up_vec = math_utils.quat_rotate(asset.data.root_quat_w, -asset.GRAVITY_VEC_W)
return base_up_vec[:, 2].unsqueeze(-1)
def base_heading_proj(
env: BaseEnv, target_pos: tuple[float, float, float], asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")
) -> torch.Tensor:
"""Projection of the base forward vector onto the world forward vector."""
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# compute desired heading direction
to_target_pos = torch.tensor(target_pos, device=env.device) - asset.data.root_pos_w[:, :3]
to_target_pos[:, 2] = 0.0
to_target_dir = math_utils.normalize(to_target_pos)
# compute base forward vector
heading_vec = math_utils.quat_rotate(asset.data.root_quat_w, asset.FORWARD_VEC_B)
# compute dot product between heading and target direction
heading_proj = torch.bmm(heading_vec.view(env.num_envs, 1, 3), to_target_dir.view(env.num_envs, 3, 1))
return heading_proj.view(env.num_envs, 1)
def base_angle_to_target(
env: BaseEnv, target_pos: tuple[float, float, float], asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")
) -> torch.Tensor:
"""Angle between the base forward vector and the vector to the target."""
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# compute desired heading direction
to_target_pos = torch.tensor(target_pos, device=env.device) - asset.data.root_pos_w[:, :3]
walk_target_angle = torch.atan2(to_target_pos[:, 1], to_target_pos[:, 0])
# compute base forward vector
_, _, yaw = math_utils.euler_xyz_from_quat(asset.data.root_quat_w)
# normalize angle to target to [-pi, pi]
angle_to_target = walk_target_angle - yaw
angle_to_target = torch.atan2(torch.sin(angle_to_target), torch.cos(angle_to_target))
return angle_to_target.unsqueeze(-1)
| 3,270 | Python | 42.039473 | 109 | 0.705505 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Manipulation environments for fixed-arm robots."""
from .reach import * # noqa
| 207 | Python | 22.111109 | 56 | 0.729469 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/inhand_env_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from dataclasses import MISSING
import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import ArticulationCfg, AssetBaseCfg, RigidObjectCfg
from omni.isaac.orbit.envs import RLTaskEnvCfg
from omni.isaac.orbit.managers import EventTermCfg as EventTerm
from omni.isaac.orbit.managers import ObservationGroupCfg as ObsGroup
from omni.isaac.orbit.managers import ObservationTermCfg as ObsTerm
from omni.isaac.orbit.managers import RewardTermCfg as RewTerm
from omni.isaac.orbit.managers import SceneEntityCfg
from omni.isaac.orbit.managers import TerminationTermCfg as DoneTerm
from omni.isaac.orbit.scene import InteractiveSceneCfg
from omni.isaac.orbit.sim.simulation_cfg import PhysxCfg, SimulationCfg
from omni.isaac.orbit.sim.spawners.materials.physics_materials_cfg import RigidBodyMaterialCfg
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.utils.assets import ISAAC_NUCLEUS_DIR
from omni.isaac.orbit.utils.noise import AdditiveGaussianNoiseCfg as Gnoise
import omni.isaac.orbit_tasks.manipulation.inhand.mdp as mdp
##
# Scene definition
##
@configclass
class InHandObjectSceneCfg(InteractiveSceneCfg):
"""Configuration for a scene with an object and a dexterous hand."""
# robots
robot: ArticulationCfg = MISSING
# objects
object: RigidObjectCfg = RigidObjectCfg(
prim_path="{ENV_REGEX_NS}/object",
spawn=sim_utils.UsdFileCfg(
usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/Blocks/DexCube/dex_cube_instanceable.usd",
rigid_props=sim_utils.RigidBodyPropertiesCfg(
kinematic_enabled=False,
disable_gravity=False,
enable_gyroscopic_forces=True,
solver_position_iteration_count=8,
solver_velocity_iteration_count=0,
sleep_threshold=0.005,
stabilization_threshold=0.0025,
max_depenetration_velocity=1000.0,
),
mass_props=sim_utils.MassPropertiesCfg(density=400.0),
),
init_state=RigidObjectCfg.InitialStateCfg(pos=(0.0, -0.19, 0.56), rot=(1.0, 0.0, 0.0, 0.0)),
)
# lights
light = AssetBaseCfg(
prim_path="/World/light",
spawn=sim_utils.DistantLightCfg(color=(0.95, 0.95, 0.95), intensity=1000.0),
)
dome_light = AssetBaseCfg(
prim_path="/World/domeLight",
spawn=sim_utils.DomeLightCfg(color=(0.02, 0.02, 0.02), intensity=1000.0),
)
##
# MDP settings
##
@configclass
class CommandsCfg:
"""Command specifications for the MDP."""
object_pose = mdp.InHandReOrientationCommandCfg(
asset_name="object",
init_pos_offset=(0.0, 0.0, -0.04),
update_goal_on_success=True,
orientation_success_threshold=0.1,
make_quat_unique=False,
marker_pos_offset=(-0.2, -0.06, 0.08),
debug_vis=True,
)
@configclass
class ActionsCfg:
"""Action specifications for the MDP."""
joint_pos = mdp.EMAJointPositionToLimitsActionCfg(
asset_name="robot",
joint_names=[".*"],
alpha=0.95,
rescale_to_limits=True,
)
@configclass
class ObservationsCfg:
"""Observation specifications for the MDP."""
@configclass
class KinematicObsGroupCfg(ObsGroup):
"""Observations with full-kinematic state information.
This does not include acceleration or force information.
"""
# observation terms (order preserved)
# -- robot terms
joint_pos = ObsTerm(func=mdp.joint_pos_limit_normalized, noise=Gnoise(std=0.005))
joint_vel = ObsTerm(func=mdp.joint_vel_rel, scale=0.2, noise=Gnoise(std=0.01))
# -- object terms
object_pos = ObsTerm(
func=mdp.root_pos_w, noise=Gnoise(std=0.002), params={"asset_cfg": SceneEntityCfg("object")}
)
object_quat = ObsTerm(
func=mdp.root_quat_w, params={"asset_cfg": SceneEntityCfg("object"), "make_quat_unique": False}
)
object_lin_vel = ObsTerm(
func=mdp.root_lin_vel_w, noise=Gnoise(std=0.002), params={"asset_cfg": SceneEntityCfg("object")}
)
object_ang_vel = ObsTerm(
func=mdp.root_ang_vel_w,
scale=0.2,
noise=Gnoise(std=0.002),
params={"asset_cfg": SceneEntityCfg("object")},
)
# -- command terms
goal_pose = ObsTerm(func=mdp.generated_commands, params={"command_name": "object_pose"})
goal_quat_diff = ObsTerm(
func=mdp.goal_quat_diff,
params={"asset_cfg": SceneEntityCfg("object"), "command_name": "object_pose", "make_quat_unique": False},
)
# -- action terms
last_action = ObsTerm(func=mdp.last_action)
def __post_init__(self):
self.enable_corruption = True
self.concatenate_terms = True
@configclass
class NoVelocityKinematicObsGroupCfg(KinematicObsGroupCfg):
"""Observations with partial kinematic state information.
In contrast to the full-kinematic state group, this group does not include velocity information
about the robot joints and the object root frame. This is useful for tasks where velocity information
is not available or has a lot of noise.
"""
def __post_init__(self):
# call parent post init
super().__post_init__()
# set unused terms to None
self.joint_vel = None
self.object_lin_vel = None
self.object_ang_vel = None
# observation groups
policy: KinematicObsGroupCfg = KinematicObsGroupCfg()
@configclass
class EventCfg:
"""Configuration for randomization."""
# startup
# -- robot
robot_physics_material = EventTerm(
func=mdp.randomize_rigid_body_material,
mode="startup",
params={
"asset_cfg": SceneEntityCfg("robot", body_names=".*"),
"static_friction_range": (0.7, 1.3),
"dynamic_friction_range": (0.7, 1.3),
"restitution_range": (0.0, 0.0),
"num_buckets": 250,
},
)
robot_scale_mass = EventTerm(
func=mdp.randomize_rigid_body_mass,
mode="startup",
params={
"asset_cfg": SceneEntityCfg("robot", body_names=".*"),
"mass_range": (0.95, 1.05),
"operation": "scale",
},
)
robot_joint_stiffness_and_damping = EventTerm(
func=mdp.randomize_actuator_gains,
mode="startup",
params={
"asset_cfg": SceneEntityCfg("robot", joint_names=".*"),
"stiffness_range": (0.3, 3.0), # default: 3.0
"damping_range": (0.75, 1.5), # default: 0.1
"operation": "scale",
"distribution": "log_uniform",
},
)
# -- object
object_physics_material = EventTerm(
func=mdp.randomize_rigid_body_material,
mode="startup",
params={
"asset_cfg": SceneEntityCfg("object", body_names=".*"),
"static_friction_range": (0.7, 1.3),
"dynamic_friction_range": (0.7, 1.3),
"restitution_range": (0.0, 0.0),
"num_buckets": 250,
},
)
object_scale_mass = EventTerm(
func=mdp.randomize_rigid_body_mass,
mode="startup",
params={
"asset_cfg": SceneEntityCfg("object"),
"mass_range": (0.4, 1.6),
"operation": "scale",
},
)
# reset
reset_object = EventTerm(
func=mdp.reset_root_state_uniform,
mode="reset",
params={
"pose_range": {"x": [-0.01, 0.01], "y": [-0.01, 0.01], "z": [-0.01, 0.01]},
"velocity_range": {},
"asset_cfg": SceneEntityCfg("object", body_names=".*"),
},
)
reset_robot_joints = EventTerm(
func=mdp.reset_joints_within_limits_range,
mode="reset",
params={
"position_range": {".*": [0.2, 0.2]},
"velocity_range": {".*": [0.0, 0.0]},
"use_default_offset": True,
"operation": "scale",
},
)
@configclass
class RewardsCfg:
"""Reward terms for the MDP."""
# -- task
# track_pos_l2 = RewTerm(
# func=mdp.track_pos_l2,
# weight=-10.0,
# params={"object_cfg": SceneEntityCfg("object"), "command_name": "object_pose"},
# )
track_orientation_inv_l2 = RewTerm(
func=mdp.track_orientation_inv_l2,
weight=1.0,
params={"object_cfg": SceneEntityCfg("object"), "rot_eps": 0.1, "command_name": "object_pose"},
)
success_bonus = RewTerm(
func=mdp.success_bonus,
weight=250.0,
params={"object_cfg": SceneEntityCfg("object"), "command_name": "object_pose"},
)
# -- penalties
joint_vel_l2 = RewTerm(func=mdp.joint_vel_l2, weight=-2.5e-5)
action_l2 = RewTerm(func=mdp.action_l2, weight=-0.0001)
action_rate_l2 = RewTerm(func=mdp.action_rate_l2, weight=-0.01)
# -- optional penalties (these are disabled by default)
# object_away_penalty = RewTerm(
# func=mdp.is_terminated_term,
# weight=-0.0,
# params={"term_keys": "object_out_of_reach"},
# )
@configclass
class TerminationsCfg:
"""Termination terms for the MDP."""
time_out = DoneTerm(func=mdp.time_out, time_out=True)
max_consecutive_success = DoneTerm(
func=mdp.max_consecutive_success, params={"num_success": 50, "command_name": "object_pose"}
)
object_out_of_reach = DoneTerm(func=mdp.object_away_from_robot, params={"threshold": 0.3})
# object_out_of_reach = DoneTerm(
# func=mdp.object_away_from_goal, params={"threshold": 0.24, "command_name": "object_pose"}
# )
##
# Environment configuration
##
@configclass
class InHandObjectEnvCfg(RLTaskEnvCfg):
"""Configuration for the in hand reorientation environment."""
# Scene settings
scene: InHandObjectSceneCfg = InHandObjectSceneCfg(num_envs=8192, env_spacing=0.6)
# Simulation settings
sim: SimulationCfg = SimulationCfg(
physics_material=RigidBodyMaterialCfg(
static_friction=1.0,
dynamic_friction=1.0,
),
physx=PhysxCfg(
bounce_threshold_velocity=0.2,
gpu_max_rigid_contact_count=2**20,
gpu_max_rigid_patch_count=2**23,
),
)
# Basic settings
observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg()
commands: CommandsCfg = CommandsCfg()
# MDP settings
rewards: RewardsCfg = RewardsCfg()
terminations: TerminationsCfg = TerminationsCfg()
events: EventCfg = EventCfg()
def __post_init__(self):
"""Post initialization."""
# general settings
self.decimation = 4
self.episode_length_s = 20.0
# simulation settings
self.sim.dt = 1.0 / 120.0
# change viewer settings
self.viewer.eye = (2.0, 2.0, 2.0)
| 11,130 | Python | 31.17052 | 117 | 0.608805 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""In-hand object reorientation environment.
These environments are based on the `dexterous cube manipulation`_ environments
provided in IsaacGymEnvs repository from NVIDIA. However, they contain certain
modifications and additional features.
.. _dexterous cube manipulation: https://github.com/NVIDIA-Omniverse/IsaacGymEnvs/blob/main/isaacgymenvs/tasks/allegro_hand.py
"""
| 500 | Python | 32.399998 | 126 | 0.798 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""This sub-module contains the functions that are specific to the in-hand manipulation environments."""
from omni.isaac.orbit.envs.mdp import * # noqa: F401, F403
from .commands import * # noqa: F401, F403
from .events import * # noqa: F401, F403
from .observations import * # noqa: F401, F403
from .rewards import * # noqa: F401, F403
from .terminations import * # noqa: F401, F403
| 515 | Python | 33.399998 | 104 | 0.72233 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/rewards.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Functions specific to the in-hand dexterous manipulation environments."""
import torch
from typing import TYPE_CHECKING
import omni.isaac.orbit.utils.math as math_utils
from omni.isaac.orbit.assets import RigidObject
from omni.isaac.orbit.envs import RLTaskEnv
from omni.isaac.orbit.managers import SceneEntityCfg
if TYPE_CHECKING:
from .commands import InHandReOrientationCommand
def success_bonus(
env: RLTaskEnv, command_name: str, object_cfg: SceneEntityCfg = SceneEntityCfg("object")
) -> torch.Tensor:
"""Bonus reward for successfully reaching the goal.
The object is considered to have reached the goal when the object orientation is within the threshold.
The reward is 1.0 if the object has reached the goal, otherwise 0.0.
Args:
env: The environment object.
command_name: The command term to be used for extracting the goal.
object_cfg: The configuration for the scene entity. Default is "object".
"""
# extract useful elements
asset: RigidObject = env.scene[object_cfg.name]
command_term: InHandReOrientationCommand = env.command_manager.get_term(command_name)
# obtain the goal orientation
goal_quat_w = command_term.command[:, 3:7]
# obtain the threshold for the orientation error
threshold = command_term.cfg.orientation_success_threshold
# calculate the orientation error
dtheta = math_utils.quat_error_magnitude(asset.data.root_quat_w, goal_quat_w)
return dtheta <= threshold
def track_pos_l2(
env: RLTaskEnv, command_name: str, object_cfg: SceneEntityCfg = SceneEntityCfg("object")
) -> torch.Tensor:
"""Reward for tracking the object position using the L2 norm.
The reward is the distance between the object position and the goal position.
Args:
env: The environment object.
command_term: The command term to be used for extracting the goal.
object_cfg: The configuration for the scene entity. Default is "object".
"""
# extract useful elements
asset: RigidObject = env.scene[object_cfg.name]
command_term: InHandReOrientationCommand = env.command_manager.get_term(command_name)
# obtain the goal position
goal_pos_e = command_term.command[:, 0:3]
# obtain the object position in the environment frame
object_pos_e = asset.data.root_pos_w - env.scene.env_origins
return torch.norm(goal_pos_e - object_pos_e, p=2, dim=-1)
def track_orientation_inv_l2(
env: RLTaskEnv,
command_name: str,
object_cfg: SceneEntityCfg = SceneEntityCfg("object"),
rot_eps: float = 1e-3,
) -> torch.Tensor:
"""Reward for tracking the object orientation using the inverse of the orientation error.
The reward is the inverse of the orientation error between the object orientation and the goal orientation.
Args:
env: The environment object.
command_name: The command term to be used for extracting the goal.
object_cfg: The configuration for the scene entity. Default is "object".
rot_eps: The threshold for the orientation error. Default is 1e-3.
"""
# extract useful elements
asset: RigidObject = env.scene[object_cfg.name]
command_term: InHandReOrientationCommand = env.command_manager.get_term(command_name)
# obtain the goal orientation
goal_quat_w = command_term.command[:, 3:7]
# calculate the orientation error
dtheta = math_utils.quat_error_magnitude(asset.data.root_quat_w, goal_quat_w)
return 1.0 / (dtheta + rot_eps)
| 3,632 | Python | 36.453608 | 111 | 0.719989 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/events.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Functions specific to the in-hand dexterous manipulation environments."""
from __future__ import annotations
import torch
from typing import TYPE_CHECKING, Literal
from omni.isaac.orbit.assets import Articulation
from omni.isaac.orbit.managers import EventTermCfg, ManagerTermBase, SceneEntityCfg
from omni.isaac.orbit.utils.math import sample_uniform
if TYPE_CHECKING:
from omni.isaac.orbit.envs import BaseEnv
class reset_joints_within_limits_range(ManagerTermBase):
"""Reset an articulation's joints to a random position in the given limit ranges.
This function samples random values for the joint position and velocities from the given limit ranges.
The values are then set into the physics simulation.
The parameters to the function are:
* :attr:`position_range` - a dictionary of position ranges for each joint. The keys of the dictionary are the
joint names (or regular expressions) of the asset.
* :attr:`velocity_range` - a dictionary of velocity ranges for each joint. The keys of the dictionary are the
joint names (or regular expressions) of the asset.
* :attr:`use_default_offset` - a boolean flag to indicate if the ranges are offset by the default joint state.
Defaults to False.
* :attr:`asset_cfg` - the configuration of the asset to reset. Defaults to the entity named "robot" in the scene.
* :attr:`operation` - whether the ranges are scaled values of the joint limits, or absolute limits.
Defaults to "abs".
The dictionary values are a tuple of the form ``(a, b)``. Based on the operation, these values are
interpreted differently:
* If the operation is "abs", the values are the absolute minimum and maximum values for the joint, i.e.
the joint range becomes ``[a, b]``.
* If the operation is "scale", the values are the scaling factors for the joint limits, i.e. the joint range
becomes ``[a * min_joint_limit, b * max_joint_limit]``.
If the ``a`` or the ``b`` value is ``None``, the joint limits are used instead.
Note:
If the dictionary does not contain a key, the joint position or joint velocity is set to the default value for
that joint.
"""
def __init__(self, cfg: EventTermCfg, env: BaseEnv):
# initialize the base class
super().__init__(cfg, env)
# check if the cfg has the required parameters
if "position_range" not in cfg.params or "velocity_range" not in cfg.params:
raise ValueError(
"The term 'reset_joints_within_range' requires parameters: 'position_range' and 'velocity_range'."
f" Received: {list(cfg.params.keys())}."
)
# parse the parameters
asset_cfg: SceneEntityCfg = cfg.params.get("asset_cfg", SceneEntityCfg("robot"))
use_default_offset = cfg.params.get("use_default_offset", False)
operation = cfg.params.get("operation", "abs")
# check if the operation is valid
if operation not in ["abs", "scale"]:
raise ValueError(
f"For event 'reset_joints_within_limits_range', unknown operation: '{operation}'."
" Please use 'abs' or 'scale'."
)
# extract the used quantities (to enable type-hinting)
self._asset: Articulation = env.scene[asset_cfg.name]
default_joint_pos = self._asset.data.default_joint_pos[0]
default_joint_vel = self._asset.data.default_joint_vel[0]
# create buffers to store the joint position range
self._pos_ranges = self._asset.data.soft_joint_pos_limits[0].clone()
# parse joint position ranges
pos_joint_ids = []
for joint_name, joint_range in cfg.params["position_range"].items():
# find the joint ids
joint_ids = self._asset.find_joints(joint_name)[0]
pos_joint_ids.extend(joint_ids)
# set the joint position ranges based on the given values
if operation == "abs":
if joint_range[0] is not None:
self._pos_ranges[joint_ids, 0] = joint_range[0]
if joint_range[1] is not None:
self._pos_ranges[joint_ids, 1] = joint_range[1]
elif operation == "scale":
if joint_range[0] is not None:
self._pos_ranges[joint_ids, 0] *= joint_range[0]
if joint_range[1] is not None:
self._pos_ranges[joint_ids, 1] *= joint_range[1]
else:
raise ValueError(
f"Unknown operation: '{operation}' for joint position ranges. Please use 'abs' or 'scale'."
)
# add the default offset
if use_default_offset:
self._pos_ranges[joint_ids] += default_joint_pos[joint_ids].unsqueeze(1)
# store the joint pos ids (used later to sample the joint positions)
self._pos_joint_ids = torch.tensor(pos_joint_ids, device=self._pos_ranges.device)
self._pos_ranges = self._pos_ranges[self._pos_joint_ids]
# create buffers to store the joint velocity range
self._vel_ranges = torch.stack(
[-self._asset.data.soft_joint_vel_limits[0], self._asset.data.soft_joint_vel_limits[0]], dim=1
)
# parse joint velocity ranges
vel_joint_ids = []
for joint_name, joint_range in cfg.params["velocity_range"].items():
# find the joint ids
joint_ids = self._asset.find_joints(joint_name)[0]
vel_joint_ids.extend(joint_ids)
# set the joint position ranges based on the given values
if operation == "abs":
if joint_range[0] is not None:
self._vel_ranges[joint_ids, 0] = joint_range[0]
if joint_range[1] is not None:
self._vel_ranges[joint_ids, 1] = joint_range[1]
elif operation == "scale":
if joint_range[0] is not None:
self._vel_ranges[joint_ids, 0] = joint_range[0] * self._vel_ranges[joint_ids, 0]
if joint_range[1] is not None:
self._vel_ranges[joint_ids, 1] = joint_range[1] * self._vel_ranges[joint_ids, 1]
else:
raise ValueError(
f"Unknown operation: '{operation}' for joint velocity ranges. Please use 'abs' or 'scale'."
)
# add the default offset
if use_default_offset:
self._vel_ranges[joint_ids] += default_joint_vel[joint_ids].unsqueeze(1)
# store the joint vel ids (used later to sample the joint positions)
self._vel_joint_ids = torch.tensor(vel_joint_ids, device=self._vel_ranges.device)
self._vel_ranges = self._vel_ranges[self._vel_joint_ids]
def __call__(
self,
env: BaseEnv,
env_ids: torch.Tensor,
position_range: dict[str, tuple[float | None, float | None]],
velocity_range: dict[str, tuple[float | None, float | None]],
use_default_offset: bool = False,
asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"),
operation: Literal["abs", "scale"] = "abs",
):
# get default joint state
joint_pos = self._asset.data.default_joint_pos[env_ids].clone()
joint_vel = self._asset.data.default_joint_vel[env_ids].clone()
# sample random joint positions for each joint
if len(self._pos_joint_ids) > 0:
joint_pos_shape = (len(env_ids), len(self._pos_joint_ids))
joint_pos[:, self._pos_joint_ids] = sample_uniform(
self._pos_ranges[:, 0], self._pos_ranges[:, 1], joint_pos_shape, device=joint_pos.device
)
# clip the joint positions to the joint limits
joint_pos_limits = self._asset.data.soft_joint_pos_limits[0, self._pos_joint_ids]
joint_pos = joint_pos.clamp(joint_pos_limits[:, 0], joint_pos_limits[:, 1])
# sample random joint velocities for each joint
if len(self._vel_joint_ids) > 0:
joint_vel_shape = (len(env_ids), len(self._vel_joint_ids))
joint_vel[:, self._vel_joint_ids] = sample_uniform(
self._vel_ranges[:, 0], self._vel_ranges[:, 1], joint_vel_shape, device=joint_vel.device
)
# clip the joint velocities to the joint limits
joint_vel_limits = self._asset.data.soft_joint_vel_limits[0, self._vel_joint_ids]
joint_vel = joint_vel.clamp(-joint_vel_limits, joint_vel_limits)
# set into the physics simulation
self._asset.write_joint_state_to_sim(joint_pos, joint_vel, env_ids=env_ids)
| 8,820 | Python | 46.681081 | 118 | 0.613719 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/terminations.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Functions specific to the in-hand dexterous manipulation environments."""
import torch
from typing import TYPE_CHECKING
from omni.isaac.orbit.envs import RLTaskEnv
from omni.isaac.orbit.managers import SceneEntityCfg
if TYPE_CHECKING:
from .commands import InHandReOrientationCommand
def max_consecutive_success(env: RLTaskEnv, num_success: int, command_name: str) -> torch.Tensor:
"""Check if the task has been completed consecutively for a certain number of times.
Args:
env: The environment object.
num_success: Threshold for the number of consecutive successes required.
command_name: The command term to be used for extracting the goal.
"""
command_term: InHandReOrientationCommand = env.command_manager.get_term(command_name)
return command_term.metrics["consecutive_success"] >= num_success
def object_away_from_goal(
env: RLTaskEnv,
threshold: float,
command_name: str,
object_cfg: SceneEntityCfg = SceneEntityCfg("object"),
) -> torch.Tensor:
"""Check if object has gone far from the goal.
The object is considered to be out-of-reach if the distance between the goal and the object is greater
than the threshold.
Args:
env: The environment object.
threshold: The threshold for the distance between the robot and the object.
command_name: The command term to be used for extracting the goal.
object_cfg: The configuration for the scene entity. Default is "object".
"""
# extract useful elements
command_term: InHandReOrientationCommand = env.command_manager.get_term(command_name)
asset = env.scene[object_cfg.name]
# object pos
asset_pos_e = asset.data.root_pos_w - env.scene.env_origins
goal_pos_e = command_term.command[:, :3]
return torch.norm(asset_pos_e - goal_pos_e, p=2, dim=1) > threshold
def object_away_from_robot(
env: RLTaskEnv,
threshold: float,
asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"),
object_cfg: SceneEntityCfg = SceneEntityCfg("object"),
) -> torch.Tensor:
"""Check if object has gone far from the robot.
The object is considered to be out-of-reach if the distance between the robot and the object is greater
than the threshold.
Args:
env: The environment object.
threshold: The threshold for the distance between the robot and the object.
asset_cfg: The configuration for the robot entity. Default is "robot".
object_cfg: The configuration for the object entity. Default is "object".
"""
# extract useful elements
robot = env.scene[asset_cfg.name]
object = env.scene[object_cfg.name]
# compute distance
dist = torch.norm(robot.data.root_pos_w - object.data.root_pos_w, dim=1)
return dist > threshold
| 2,920 | Python | 33.773809 | 107 | 0.708904 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/observations.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Functions specific to the in-hand dexterous manipulation environments."""
import torch
from typing import TYPE_CHECKING
import omni.isaac.orbit.utils.math as math_utils
from omni.isaac.orbit.assets import RigidObject
from omni.isaac.orbit.envs import RLTaskEnv
from omni.isaac.orbit.managers import SceneEntityCfg
if TYPE_CHECKING:
from .commands import InHandReOrientationCommand
def goal_quat_diff(
env: RLTaskEnv, asset_cfg: SceneEntityCfg, command_name: str, make_quat_unique: bool
) -> torch.Tensor:
"""Goal orientation relative to the asset's root frame.
The quaternion is represented as (w, x, y, z). The real part is always positive.
"""
# extract useful elements
asset: RigidObject = env.scene[asset_cfg.name]
command_term: InHandReOrientationCommand = env.command_manager.get_term(command_name)
# obtain the orientations
goal_quat_w = command_term.command[:, 3:7]
asset_quat_w = asset.data.root_quat_w
# compute quaternion difference
quat = math_utils.quat_mul(asset_quat_w, math_utils.quat_conjugate(goal_quat_w))
# make sure the quaternion real-part is always positive
return math_utils.quat_unique(quat) if make_quat_unique else quat
| 1,341 | Python | 33.410256 | 89 | 0.745712 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/commands/commands_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from dataclasses import MISSING
import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.managers import CommandTermCfg
from omni.isaac.orbit.markers import VisualizationMarkersCfg
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.utils.assets import ISAAC_NUCLEUS_DIR
from .orientation_command import InHandReOrientationCommand
@configclass
class InHandReOrientationCommandCfg(CommandTermCfg):
"""Configuration for the uniform 3D orientation command term.
Please refer to the :class:`InHandReOrientationCommand` class for more details.
"""
class_type: type = InHandReOrientationCommand
resampling_time_range: tuple[float, float] = (1e6, 1e6) # no resampling based on time
asset_name: str = MISSING
"""Name of the asset in the environment for which the commands are generated."""
init_pos_offset: tuple[float, float, float] = (0.0, 0.0, 0.0)
"""Position offset of the asset from its default position.
This is used to account for the offset typically present in the object's default position
so that the object is spawned at a height above the robot's palm. When the position command
is generated, the object's default position is used as the reference and the offset specified
is added to it to get the desired position of the object.
"""
make_quat_unique: bool = MISSING
"""Whether to make the quaternion unique or not.
If True, the quaternion is made unique by ensuring the real part is positive.
"""
orientation_success_threshold: float = MISSING
"""Threshold for the orientation error to consider the goal orientation to be reached."""
update_goal_on_success: bool = MISSING
"""Whether to update the goal orientation when the goal orientation is reached."""
marker_pos_offset: tuple[float, float, float] = (0.0, 0.0, 0.0)
"""Position offset of the marker from the object's desired position.
This is useful to position the marker at a height above the object's desired position.
Otherwise, the marker may occlude the object in the visualization.
"""
visualizer_cfg: VisualizationMarkersCfg = VisualizationMarkersCfg(
prim_path="/Visuals/Command/goal_marker",
markers={
"goal": sim_utils.UsdFileCfg(
usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/Blocks/DexCube/dex_cube_instanceable.usd",
scale=(1.0, 1.0, 1.0),
),
},
)
"""Configuration for the visualization markers. Default is a cube marker."""
| 2,655 | Python | 38.058823 | 97 | 0.718267 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/commands/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Sub-module containing command terms for 3D orientation goals."""
from .commands_cfg import InHandReOrientationCommandCfg # noqa: F401
from .orientation_command import InHandReOrientationCommand # noqa: F401
| 336 | Python | 32.699997 | 73 | 0.782738 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/mdp/commands/orientation_command.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Sub-module containing command generators for 3D orientation goals for objects."""
from __future__ import annotations
import torch
from collections.abc import Sequence
from typing import TYPE_CHECKING
import omni.isaac.orbit.utils.math as math_utils
from omni.isaac.orbit.assets import RigidObject
from omni.isaac.orbit.managers import CommandTerm
from omni.isaac.orbit.markers.visualization_markers import VisualizationMarkers
if TYPE_CHECKING:
from omni.isaac.orbit.envs import RLTaskEnv
from .commands_cfg import InHandReOrientationCommandCfg
class InHandReOrientationCommand(CommandTerm):
"""Command term that generates 3D pose commands for in-hand manipulation task.
This command term generates 3D orientation commands for the object. The orientation commands
are sampled uniformly from the 3D orientation space. The position commands are the default
root state of the object.
The constant position commands is to encourage that the object does not move during the task.
For instance, the object should not fall off the robot's palm.
Unlike typical command terms, where the goals are resampled based on time, this command term
does not resample the goals based on time. Instead, the goals are resampled when the object
reaches the goal orientation. The goal orientation is considered to be reached when the
orientation error is below a certain threshold.
"""
cfg: InHandReOrientationCommandCfg
"""Configuration for the command term."""
def __init__(self, cfg: InHandReOrientationCommandCfg, env: RLTaskEnv):
"""Initialize the command term class.
Args:
cfg: The configuration parameters for the command term.
env: The environment object.
"""
# initialize the base class
super().__init__(cfg, env)
# object
self.object: RigidObject = env.scene[cfg.asset_name]
# create buffers to store the command
# -- command: (x, y, z)
init_pos_offset = torch.tensor(cfg.init_pos_offset, dtype=torch.float, device=self.device)
self.pos_command_e = self.object.data.default_root_state[:, :3] + init_pos_offset
self.pos_command_w = self.pos_command_e + self._env.scene.env_origins
# -- orientation: (w, x, y, z)
self.quat_command_w = torch.zeros(self.num_envs, 4, device=self.device)
self.quat_command_w[:, 0] = 1.0 # set the scalar component to 1.0
# -- unit vectors
self._X_UNIT_VEC = torch.tensor([1.0, 0, 0], device=self.device).repeat((self.num_envs, 1))
self._Y_UNIT_VEC = torch.tensor([0, 1.0, 0], device=self.device).repeat((self.num_envs, 1))
self._Z_UNIT_VEC = torch.tensor([0, 0, 1.0], device=self.device).repeat((self.num_envs, 1))
# -- metrics
self.metrics["orientation_error"] = torch.zeros(self.num_envs, device=self.device)
self.metrics["position_error"] = torch.zeros(self.num_envs, device=self.device)
self.metrics["consecutive_success"] = torch.zeros(self.num_envs, device=self.device)
def __str__(self) -> str:
msg = "InHandManipulationCommandGenerator:\n"
msg += f"\tCommand dimension: {tuple(self.command.shape[1:])}\n"
return msg
"""
Properties
"""
@property
def command(self) -> torch.Tensor:
"""The desired goal pose in the environment frame. Shape is (num_envs, 7)."""
return torch.cat((self.pos_command_e, self.quat_command_w), dim=-1)
"""
Implementation specific functions.
"""
def _update_metrics(self):
# logs data
# -- compute the orientation error
self.metrics["orientation_error"] = math_utils.quat_error_magnitude(
self.object.data.root_quat_w, self.quat_command_w
)
# -- compute the position error
self.metrics["position_error"] = torch.norm(self.object.data.root_pos_w - self.pos_command_w, dim=1)
# -- compute the number of consecutive successes
successes = self.metrics["orientation_error"] < self.cfg.orientation_success_threshold
self.metrics["consecutive_success"] += successes.float()
def _resample_command(self, env_ids: Sequence[int]):
# sample new orientation targets
rand_floats = 2.0 * torch.rand((len(env_ids), 2), device=self.device) - 1.0
# rotate randomly about x-axis and then y-axis
quat = math_utils.quat_mul(
math_utils.quat_from_angle_axis(rand_floats[:, 0] * torch.pi, self._X_UNIT_VEC[env_ids]),
math_utils.quat_from_angle_axis(rand_floats[:, 1] * torch.pi, self._Y_UNIT_VEC[env_ids]),
)
# make sure the quaternion real-part is always positive
self.quat_command_w[env_ids] = math_utils.quat_unique(quat) if self.cfg.make_quat_unique else quat
def _update_command(self):
# update the command if goal is reached
if self.cfg.update_goal_on_success:
# compute the goal resets
goal_resets = self.metrics["orientation_error"] < self.cfg.orientation_success_threshold
goal_reset_ids = goal_resets.nonzero(as_tuple=False).squeeze(-1)
# resample the goals
self._resample(goal_reset_ids)
def _set_debug_vis_impl(self, debug_vis: TYPE_CHECKING):
# set visibility of markers
# note: parent only deals with callbacks. not their visibility
if debug_vis:
# create markers if necessary for the first time
if not hasattr(self, "goal_marker_visualizer"):
self.goal_marker_visualizer = VisualizationMarkers(self.cfg.visualizer_cfg)
# set visibility
self.goal_marker_visualizer.set_visibility(True)
else:
if hasattr(self, "goal_marker_visualizer"):
self.goal_marker_visualizer.set_visibility(False)
def _debug_vis_callback(self, event):
# add an offset to the marker position to visualize the goal
marker_pos = self.pos_command_w + torch.tensor(self.cfg.marker_pos_offset, device=self.device)
marker_quat = self.quat_command_w
# visualize the goal marker
self.goal_marker_visualizer.visualize(translations=marker_pos, orientations=marker_quat)
| 6,393 | Python | 43.096551 | 108 | 0.668074 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/config/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Configurations for in-hand manipulation environments."""
# We leave this file empty since we don't want to expose any configs in this package directly.
# We still need this file to import the "config" module in the parent package.
| 358 | Python | 34.899997 | 94 | 0.759777 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/config/allegro_hand/allegro_env_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from omni.isaac.orbit.utils import configclass
import omni.isaac.orbit_tasks.manipulation.inhand.inhand_env_cfg as inhand_env_cfg
##
# Pre-defined configs
##
from omni.isaac.orbit_assets import ALLEGRO_HAND_CFG # isort: skip
@configclass
class AllegroCubeEnvCfg(inhand_env_cfg.InHandObjectEnvCfg):
def __post_init__(self):
# post init of parent
super().__post_init__()
# switch robot to allegro hand
self.scene.robot = ALLEGRO_HAND_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")
@configclass
class AllegroCubeEnvCfg_PLAY(AllegroCubeEnvCfg):
def __post_init__(self):
# post init of parent
super().__post_init__()
# make a smaller scene for play
self.scene.num_envs = 50
# disable randomization for play
self.observations.policy.enable_corruption = False
# remove termination due to timeouts
self.terminations.time_out = None
##
# Environment configuration with no velocity observations.
##
@configclass
class AllegroCubeNoVelObsEnvCfg(AllegroCubeEnvCfg):
def __post_init__(self):
# post init of parent
super().__post_init__()
# switch observation group to no velocity group
self.observations.policy = inhand_env_cfg.ObservationsCfg.NoVelocityKinematicObsGroupCfg()
@configclass
class AllegroCubeNoVelObsEnvCfg_PLAY(AllegroCubeNoVelObsEnvCfg):
def __post_init__(self):
# post init of parent
super().__post_init__()
# make a smaller scene for play
self.scene.num_envs = 50
# disable randomization for play
self.observations.policy.enable_corruption = False
# remove termination due to timeouts
self.terminations.time_out = None
| 1,870 | Python | 27.784615 | 98 | 0.683957 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/config/allegro_hand/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import gymnasium as gym
from . import agents, allegro_env_cfg
##
# Register Gym environments.
##
##
# Full kinematic state observations.
##
gym.register(
id="Isaac-Repose-Cube-Allegro-v0",
entry_point="omni.isaac.orbit.envs:RLTaskEnv",
disable_env_checker=True,
kwargs={
"env_cfg_entry_point": allegro_env_cfg.AllegroCubeEnvCfg,
"rsl_rl_cfg_entry_point": agents.rsl_rl_cfg.AllegroCubePPORunnerCfg,
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
},
)
gym.register(
id="Isaac-Repose-Cube-Allegro-Play-v0",
entry_point="omni.isaac.orbit.envs:RLTaskEnv",
disable_env_checker=True,
kwargs={
"env_cfg_entry_point": allegro_env_cfg.AllegroCubeEnvCfg_PLAY,
"rsl_rl_cfg_entry_point": agents.rsl_rl_cfg.AllegroCubePPORunnerCfg,
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
},
)
##
# Kinematic state observations without velocity information.
##
gym.register(
id="Isaac-Repose-Cube-Allegro-NoVelObs-v0",
entry_point="omni.isaac.orbit.envs:RLTaskEnv",
disable_env_checker=True,
kwargs={
"env_cfg_entry_point": allegro_env_cfg.AllegroCubeNoVelObsEnvCfg,
"rsl_rl_cfg_entry_point": agents.rsl_rl_cfg.AllegroCubeNoVelObsPPORunnerCfg,
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
},
)
gym.register(
id="Isaac-Repose-Cube-Allegro-NoVelObs-Play-v0",
entry_point="omni.isaac.orbit.envs:RLTaskEnv",
disable_env_checker=True,
kwargs={
"env_cfg_entry_point": allegro_env_cfg.AllegroCubeNoVelObsEnvCfg_PLAY,
"rsl_rl_cfg_entry_point": agents.rsl_rl_cfg.AllegroCubeNoVelObsPPORunnerCfg,
"rl_games_cfg_entry_point": f"{agents.__name__}:rl_games_ppo_cfg.yaml",
},
)
| 1,924 | Python | 28.615384 | 84 | 0.680353 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/config/allegro_hand/agents/rsl_rl_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit_tasks.utils.wrappers.rsl_rl import (
RslRlOnPolicyRunnerCfg,
RslRlPpoActorCriticCfg,
RslRlPpoAlgorithmCfg,
)
@configclass
class AllegroCubePPORunnerCfg(RslRlOnPolicyRunnerCfg):
num_steps_per_env = 24
max_iterations = 5000
save_interval = 50
experiment_name = "allegro_cube"
empirical_normalization = True
policy = RslRlPpoActorCriticCfg(
init_noise_std=1.0,
actor_hidden_dims=[512, 256, 128],
critic_hidden_dims=[512, 256, 128],
activation="elu",
)
algorithm = RslRlPpoAlgorithmCfg(
value_loss_coef=1.0,
use_clipped_value_loss=True,
clip_param=0.2,
entropy_coef=0.002,
num_learning_epochs=5,
num_mini_batches=4,
learning_rate=0.001,
schedule="adaptive",
gamma=0.998,
lam=0.95,
desired_kl=0.01,
max_grad_norm=1.0,
)
@configclass
class AllegroCubeNoVelObsPPORunnerCfg(AllegroCubePPORunnerCfg):
experiment_name = "allegro_cube_no_vel_obs"
| 1,213 | Python | 24.829787 | 63 | 0.664468 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/config/allegro_hand/agents/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from . import rsl_rl_cfg # noqa: F401, F403
| 168 | Python | 23.142854 | 56 | 0.720238 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/inhand/config/allegro_hand/agents/rl_games_ppo_cfg.yaml | params:
seed: 42
# environment wrapper clipping
env:
clip_observations: 5.0
clip_actions: 1.0
algo:
name: a2c_continuous
model:
name: continuous_a2c_logstd
network:
name: actor_critic
separate: False
space:
continuous:
mu_activation: None
sigma_activation: None
mu_init:
name: default
sigma_init:
name: const_initializer
val: 0
fixed_sigma: True
mlp:
units: [512, 256, 128]
activation: elu
d2rl: False
initializer:
name: default
regularizer:
name: None
load_checkpoint: False
load_path: ''
config:
name: allegro_cube
env_name: rlgpu
device: 'cuda:0'
device_name: 'cuda:0'
multi_gpu: False
ppo: True
mixed_precision: False
normalize_input: True
normalize_value: True
value_bootstrap: True
num_actors: -1 # configured from the script (based on num_envs)
reward_shaper:
scale_value: 0.1
normalize_advantage: True
gamma: 0.998
tau: 0.95
learning_rate: 5e-4
lr_schedule: adaptive
schedule_type: standard
kl_threshold: 0.016
score_to_win: 100000
max_epochs: 5000
save_best_after: 500
save_frequency: 200
print_stats: True
grad_norm: 1.0
entropy_coef: 0.002
truncate_grads: True
e_clip: 0.2
horizon_length: 24
minibatch_size: 16384 # 32768
mini_epochs: 5
critic_coef: 4
clip_value: True
seq_length: 4
bounds_loss_coef: 0.0005
player:
#render: True
deterministic: True
games_num: 100000
print_stats: True
| 1,655 | YAML | 18.255814 | 68 | 0.599396 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/reach/reach_env_cfg.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from dataclasses import MISSING
import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import ArticulationCfg, AssetBaseCfg
from omni.isaac.orbit.envs import RLTaskEnvCfg
from omni.isaac.orbit.managers import ActionTermCfg as ActionTerm
from omni.isaac.orbit.managers import CurriculumTermCfg as CurrTerm
from omni.isaac.orbit.managers import EventTermCfg as EventTerm
from omni.isaac.orbit.managers import ObservationGroupCfg as ObsGroup
from omni.isaac.orbit.managers import ObservationTermCfg as ObsTerm
from omni.isaac.orbit.managers import RewardTermCfg as RewTerm
from omni.isaac.orbit.managers import SceneEntityCfg
from omni.isaac.orbit.managers import TerminationTermCfg as DoneTerm
from omni.isaac.orbit.scene import InteractiveSceneCfg
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.utils.assets import ISAAC_NUCLEUS_DIR
from omni.isaac.orbit.utils.noise import AdditiveUniformNoiseCfg as Unoise
import omni.isaac.orbit_tasks.manipulation.reach.mdp as mdp
##
# Scene definition
##
@configclass
class ReachSceneCfg(InteractiveSceneCfg):
"""Configuration for the scene with a robotic arm."""
# world
ground = AssetBaseCfg(
prim_path="/World/ground",
spawn=sim_utils.GroundPlaneCfg(),
init_state=AssetBaseCfg.InitialStateCfg(pos=(0.0, 0.0, -1.05)),
)
table = AssetBaseCfg(
prim_path="{ENV_REGEX_NS}/Table",
spawn=sim_utils.UsdFileCfg(
usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/Mounts/SeattleLabTable/table_instanceable.usd",
),
init_state=AssetBaseCfg.InitialStateCfg(pos=(0.55, 0.0, 0.0), rot=(0.70711, 0.0, 0.0, 0.70711)),
)
# robots
robot: ArticulationCfg = MISSING
# lights
light = AssetBaseCfg(
prim_path="/World/light",
spawn=sim_utils.DomeLightCfg(color=(0.75, 0.75, 0.75), intensity=2500.0),
)
##
# MDP settings
##
@configclass
class CommandsCfg:
"""Command terms for the MDP."""
ee_pose = mdp.UniformPoseCommandCfg(
asset_name="robot",
body_name=MISSING,
resampling_time_range=(4.0, 4.0),
debug_vis=True,
ranges=mdp.UniformPoseCommandCfg.Ranges(
pos_x=(0.35, 0.65),
pos_y=(-0.2, 0.2),
pos_z=(0.15, 0.5),
roll=(0.0, 0.0),
pitch=MISSING, # depends on end-effector axis
yaw=(-3.14, 3.14),
),
)
@configclass
class ActionsCfg:
"""Action specifications for the MDP."""
arm_action: ActionTerm = MISSING
gripper_action: ActionTerm | None = None
@configclass
class ObservationsCfg:
"""Observation specifications for the MDP."""
@configclass
class PolicyCfg(ObsGroup):
"""Observations for policy group."""
# observation terms (order preserved)
joint_pos = ObsTerm(func=mdp.joint_pos_rel, noise=Unoise(n_min=-0.01, n_max=0.01))
joint_vel = ObsTerm(func=mdp.joint_vel_rel, noise=Unoise(n_min=-0.01, n_max=0.01))
pose_command = ObsTerm(func=mdp.generated_commands, params={"command_name": "ee_pose"})
actions = ObsTerm(func=mdp.last_action)
def __post_init__(self):
self.enable_corruption = True
self.concatenate_terms = True
# observation groups
policy: PolicyCfg = PolicyCfg()
@configclass
class EventCfg:
"""Configuration for events."""
reset_robot_joints = EventTerm(
func=mdp.reset_joints_by_scale,
mode="reset",
params={
"position_range": (0.5, 1.5),
"velocity_range": (0.0, 0.0),
},
)
@configclass
class RewardsCfg:
"""Reward terms for the MDP."""
# task terms
end_effector_position_tracking = RewTerm(
func=mdp.position_command_error,
weight=-0.2,
params={"asset_cfg": SceneEntityCfg("robot", body_names=MISSING), "command_name": "ee_pose"},
)
end_effector_orientation_tracking = RewTerm(
func=mdp.orientation_command_error,
weight=-0.05,
params={"asset_cfg": SceneEntityCfg("robot", body_names=MISSING), "command_name": "ee_pose"},
)
# action penalty
action_rate = RewTerm(func=mdp.action_rate_l2, weight=-0.0001)
joint_vel = RewTerm(
func=mdp.joint_vel_l2,
weight=-0.0001,
params={"asset_cfg": SceneEntityCfg("robot")},
)
@configclass
class TerminationsCfg:
"""Termination terms for the MDP."""
time_out = DoneTerm(func=mdp.time_out, time_out=True)
@configclass
class CurriculumCfg:
"""Curriculum terms for the MDP."""
action_rate = CurrTerm(
func=mdp.modify_reward_weight, params={"term_name": "action_rate", "weight": -0.005, "num_steps": 4500}
)
##
# Environment configuration
##
@configclass
class ReachEnvCfg(RLTaskEnvCfg):
"""Configuration for the reach end-effector pose tracking environment."""
# Scene settings
scene: ReachSceneCfg = ReachSceneCfg(num_envs=4096, env_spacing=2.5)
# Basic settings
observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg()
commands: CommandsCfg = CommandsCfg()
# MDP settings
rewards: RewardsCfg = RewardsCfg()
terminations: TerminationsCfg = TerminationsCfg()
events: EventCfg = EventCfg()
curriculum: CurriculumCfg = CurriculumCfg()
def __post_init__(self):
"""Post initialization."""
# general settings
self.decimation = 2
self.episode_length_s = 12.0
self.viewer.eye = (3.5, 3.5, 3.5)
# simulation settings
self.sim.dt = 1.0 / 60.0
| 5,704 | Python | 27.668342 | 111 | 0.660764 |
zoctipus/cse542Project/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/reach/__init__.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Fixed-arm environments with end-effector pose tracking commands."""
| 194 | Python | 26.857139 | 70 | 0.752577 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.