file_path
stringlengths
20
202
content
stringlengths
9
3.85M
size
int64
9
3.85M
lang
stringclasses
9 values
avg_line_length
float64
3.33
100
max_line_length
int64
8
993
alphanum_fraction
float64
0.26
0.93
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.franka/docs/CHANGELOG.md
# Changelog ## [0.4.0] - 2022-09-27 ### Removed - usd files local to extension ## [0.3.0] - 2022-07-26 ### Removed - Removed GripperController class and used the new ParallelGripper class instead. ### Changed - Changed gripper_dof_indices argument in PickPlaceController to gripper - Changed gripper_dof_indices argument in StackingController to gripper ### Added - Added deltas argument in Franka class for the gripper action deltas when openning or closing. ## [0.2.1] - 2022-07-22 ### Fixed - Bug with adding a custom usd for manipulator ## [0.2.0] - 2022-05-02 ### Changed - Changed InverseKinematicsSolver class to KinematicsSolver class, using the new LulaKinematicsSolver class in motion_generation ## [0.1.4] - 2022-04-21 ### Changed - Updated RmpFlowController class init alongside modifying motion_generation extension ## [0.1.3] - 2022-04-13 ### Changed - Fix Franka units in gripper open config. ## [0.1.2] - 2022-03-25 ### Changed - Updated RmpFlowController class alongside changes to motion_generation extension ## [0.1.1] - 2022-03-16 ### Changed - Replaced find_nucleus_server() with get_assets_root_path() ## [0.1.0] - 2021-09-01 ### Added - Added Franka class and and Franka Task Follower Class
1,234
Markdown
21.87037
128
0.724473
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.franka/docs/README.md
# Usage To enable this extension, go to the Extension Manager menu and enable omni.isaac.franka extension
106
Markdown
34.666655
97
0.811321
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.franka/docs/index.rst
Franka Robot [omni.isaac.franka] ################################ Franka ============= .. automodule:: omni.isaac.franka.franka :inherited-members: :members: :undoc-members: :exclude-members: Franka Kinematics Solver ========================= .. automodule:: omni.isaac.franka.kinematics_solver :inherited-members: :members: Franka Controllers ================== .. automodule:: omni.isaac.franka.controllers :inherited-members: :imported-members: :members: :undoc-members: :exclude-members: Franka Tasks ============= .. automodule:: omni.isaac.franka.tasks :inherited-members: :imported-members: :members: :undoc-members: :exclude-members:
717
reStructuredText
16.095238
51
0.585774
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/config/extension.toml
[core] reloadable = true order = 0 [package] version = "0.2.3" category = "Simulation" title = "Isaac Sim Debug Drawing" description = "Persistent Debug Drawing Helpers" authors = ["NVIDIA"] repository = "" keywords = ["isaac", "physics", "inspect",] changelog = "docs/CHANGELOG.md" readme = "docs/README.md" icon = "data/icon.png" writeTarget.kit = true # Other extensions that must be loaded before this one [dependencies] "omni.graph" = {} "omni.graph.tools" = {} "omni.debugdraw" = {} # needed to access drawing interfaces: "omni.kit.renderer.core" = {} "omni.kit.viewport.window" = {} "omni.hydra.rtx" = {} # The generated tests will make use of these modules "omni.usd" = {} "omni.kit.async_engine" = {} [[python.module]] name = "omni.isaac.debug_draw" [[python.module]] name = "omni.isaac.debug_draw.tests" # Watch the .ogn files for hot reloading (only for Python files) [fswatcher.patterns] include = ["*.ogn", "*.py"] exclude = ["Ogn*Database.py"] [[native.plugin]] path = "bin/*.plugin" recursive = false
1,022
TOML
21.733333
64
0.68591
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/omni/isaac/debug_draw/ogn/OgnDebugDrawPointCloudDatabase.py
"""Support for simplified access to data on nodes of type omni.isaac.debug_draw.DebugDrawPointCloud Take a point cloud as input and display it in the scene. """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn import carb import numpy class OgnDebugDrawPointCloudDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.isaac.debug_draw.DebugDrawPointCloud Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.color inputs.depthTest inputs.execIn inputs.pointCloudData inputs.transform inputs.width """ # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:color', 'color4f', 0, None, 'Color of points', {ogn.MetadataKeys.DEFAULT: '[0.75, 0.75, 1, 1]'}, True, [0.75, 0.75, 1, 1], False, ''), ('inputs:depthTest', 'bool', 0, 'Depth Test Points', 'If true, the points will not render when behind other objects.', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:execIn', 'execution', 0, None, 'The input execution port', {}, True, None, False, ''), ('inputs:pointCloudData', 'point3f[]', 0, None, 'Buffer of 3d points containing point cloud data', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('inputs:transform', 'matrix4d', 0, None, 'The matrix to transform the points by', {}, True, [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], False, ''), ('inputs:width', 'float', 0, None, 'Size of points', {ogn.MetadataKeys.DEFAULT: '0.02'}, True, 0.02, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.color = og.Database.ROLE_COLOR role_data.inputs.execIn = og.Database.ROLE_EXECUTION role_data.inputs.pointCloudData = og.Database.ROLE_POINT role_data.inputs.transform = og.Database.ROLE_MATRIX return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"color", "depthTest", "execIn", "transform", "width", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.color, self._attributes.depthTest, self._attributes.execIn, self._attributes.transform, self._attributes.width] self._batchedReadValues = [[0.75, 0.75, 1, 1], True, None, [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0], 0.02] @property def pointCloudData(self): data_view = og.AttributeValueHelper(self._attributes.pointCloudData) return data_view.get() @pointCloudData.setter def pointCloudData(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.pointCloudData) data_view = og.AttributeValueHelper(self._attributes.pointCloudData) data_view.set(value) self.pointCloudData_size = data_view.get_array_size() @property def color(self): return self._batchedReadValues[0] @color.setter def color(self, value): self._batchedReadValues[0] = value @property def depthTest(self): return self._batchedReadValues[1] @depthTest.setter def depthTest(self, value): self._batchedReadValues[1] = value @property def execIn(self): return self._batchedReadValues[2] @execIn.setter def execIn(self, value): self._batchedReadValues[2] = value @property def transform(self): return self._batchedReadValues[3] @transform.setter def transform(self, value): self._batchedReadValues[3] = value @property def width(self): return self._batchedReadValues[4] @width.setter def width(self, value): self._batchedReadValues[4] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnDebugDrawPointCloudDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnDebugDrawPointCloudDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnDebugDrawPointCloudDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
7,785
Python
48.910256
202
0.642518
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/omni/isaac/debug_draw/ogn/tests/TestOgnDebugDrawPointCloud.py
import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts import os class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.isaac.debug_draw.ogn.OgnDebugDrawPointCloudDatabase import OgnDebugDrawPointCloudDatabase test_file_name = "OgnDebugDrawPointCloudTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_isaac_debug_draw_DebugDrawPointCloud") database = OgnDebugDrawPointCloudDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:color")) attribute = test_node.get_attribute("inputs:color") db_value = database.inputs.color expected_value = [0.75, 0.75, 1, 1] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:depthTest")) attribute = test_node.get_attribute("inputs:depthTest") db_value = database.inputs.depthTest expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:execIn")) attribute = test_node.get_attribute("inputs:execIn") db_value = database.inputs.execIn self.assertTrue(test_node.get_attribute_exists("inputs:pointCloudData")) attribute = test_node.get_attribute("inputs:pointCloudData") db_value = database.inputs.pointCloudData expected_value = [] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:transform")) attribute = test_node.get_attribute("inputs:transform") db_value = database.inputs.transform expected_value = [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:width")) attribute = test_node.get_attribute("inputs:width") db_value = database.inputs.width expected_value = 0.02 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
3,705
Python
51.197182
107
0.676923
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/omni/isaac/debug_draw/tests/test_debug_draw.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 from omni.isaac.debug_draw import _debug_draw import random # 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 TestDebugDraw(omni.kit.test.AsyncTestCase): # Before running each test async def setUp(self): self._draw = _debug_draw.acquire_debug_draw_interface() pass # After running each test async def tearDown(self): await omni.kit.app.get_app().next_update_async() pass # Actual test, notice it is "async" function, so "await" can be used if needed async def test_draw_points(self): N = 10000 point_list_1 = [ (random.uniform(-1000, 1000), random.uniform(-1000, 1000), random.uniform(-1000, 1000)) for _ in range(N) ] point_list_2 = [ (random.uniform(-1000, 1000), random.uniform(1000, 3000), random.uniform(-1000, 1000)) for _ in range(N) ] point_list_3 = [ (random.uniform(-1000, 1000), random.uniform(-3000, -1000), random.uniform(-1000, 1000)) for _ in range(N) ] colors = [(random.uniform(0.5, 1), random.uniform(0.5, 1), random.uniform(0.5, 1), 1) for _ in range(N)] sizes = [random.randint(1, 50) for _ in range(N)] self._draw.draw_points(point_list_1, [(1, 0, 0, 1)] * N, [10] * N) self._draw.draw_points(point_list_2, [(0, 1, 0, 1)] * N, [10] * N) self._draw.draw_points(point_list_3, colors, sizes) self.assertEqual(self._draw.get_num_points(), 3 * N) self._draw.clear_points() self.assertEqual(self._draw.get_num_points(), 0) pass async def test_draw_lines(self): N = 10000 point_list_1 = [ (random.uniform(1000, 3000), random.uniform(-1000, 1000), random.uniform(-1000, 1000)) for _ in range(N) ] point_list_2 = [ (random.uniform(1000, 3000), random.uniform(-1000, 1000), random.uniform(-1000, 1000)) for _ in range(N) ] colors = [(random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1), 1) for _ in range(N)] sizes = [random.randint(1, 25) for _ in range(N)] self._draw.draw_lines(point_list_1, point_list_2, colors, sizes) self.assertEqual(self._draw.get_num_lines(), N) self._draw.clear_lines() self.assertEqual(self._draw.get_num_lines(), 0) pass async def test_draw_spline(self): point_list_1 = [ (random.uniform(-300, -100), random.uniform(-100, 100), random.uniform(-100, 100)) for _ in range(10) ] self._draw.draw_lines_spline(point_list_1, (1, 1, 1, 1), 10, False) point_list_2 = [ (random.uniform(-300, -100), random.uniform(-100, 100), random.uniform(-100, 100)) for _ in range(10) ] self._draw.draw_lines_spline(point_list_2, (1, 1, 1, 1), 5, True) self.assertGreater(self._draw.get_num_lines(), 0) self._draw.clear_lines() self.assertEqual(self._draw.get_num_lines(), 0) pass
3,735
Python
44.560975
142
0.627041
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/omni/isaac/debug_draw/tests/__init__.py
# Copyright (c) 2018-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. # """ Presence of this file allows the tests directory to be imported as a module so that all of its contents can be scanned to automatically add tests that are placed into this directory. """
624
Python
47.076919
103
0.799679
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/docs/ogn.rst
DebugDrawPointCloud ------------------- ['Take a point cloud as input and display it in the scene.'] **Inputs** - **execIn** (*execution*): The input execution port. - **depthTest** (*bool*): If true, the points will not render when behind other objects. Default to True. - **transform** (*matrixd[4]*): The matrix to transform the points by. - **pointCloudData** (*pointf[3][]*): Buffer of 3d points containing point cloud data. Default to []. - **color** (*colorf[4]*): Color of points. Default to [0.75, 0.75, 1, 1]. - **width** (*float*): Size of points. Default to 0.02.
608
reStructuredText
39.599997
109
0.616776
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/docs/CHANGELOG.md
# Changelog ## [0.2.3] - 2023-01-19 ### Fixed - crash when trying to draw without a valid renderer ## [0.2.2] - 2022-12-14 ### Fixed - crash when deleting ## [0.2.1] - 2022-10-18 ### Changed - Debug Draw Point Cloud takes transform - PrimitiveDrawingHelper::setVertices with poistion only ## [0.2.0] - 2022-10-06 ### Added - Debug Draw Point Cloud node - PrimitiveDrawingHelper::setVertices with constant color and width ### Changed - antialiasingWidth to 1 in PrimitiveDrawingHelper::draw() ## [0.1.4] - 2022-10-02 ### Fixed - Crash when stage was not ready ## [0.1.3] - 2022-09-07 ### Fixed - Fixes for kit 103.5 ## [0.1.2] - 2022-03-07 ### Added - Added flag to disable depth check ## [0.1.1] - 2021-08-20 ### Added - world space flag to specify if width value is in world coordinates. ## [0.1.0] - 2021-07-27 ### Added - Initial version of extension
869
Markdown
17.913043
71
0.667434
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.debug_draw/docs/index.rst
Debug Drawing [omni.isaac.debug_draw] ########################################### .. automodule:: omni.isaac.debug_draw._debug_draw :platform: Windows-x86_64, Linux-x86_64 :members: :undoc-members: :show-inheritance: :imported-members: :exclude-members: Omnigraph Nodes ======================= .. include:: ogn.rst
344
reStructuredText
20.562499
49
0.543605
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.benchmark_environments/config/extension.toml
[core] reloadable = true order = 0 [package] version = "0.4.0" category = "Simulation" title = "Simulated Environments for use in Isaac Sim" description = "Extension for programming simple environments for robots" authors = ["NVIDIA"] repository = "" keywords = ["isaac", "samples", "environments"] changelog = "docs/CHANGELOG.md" readme = "docs/README.md" icon = "data/icon.png" [dependencies] "omni.isaac.core" = {} [[python.module]] name = "omni.isaac.benchmark_environments" [[python.module]] name = "omni.isaac.benchmark_environments.tests"
550
TOML
21.039999
72
0.72
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.benchmark_environments/omni/isaac/benchmark_environments/objects.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 pxr import Gf import numpy as np from scipy.spatial.transform import Rotation as R from .object_interface import Object """ An Object allows the manipulation of a group of prims as a single unit. A subclass of Object must implement the construct() method to specify what prims comprise an object, and what their relative positions are. When an Object is created, the base pose is specified in the constructor. Inside the construct() method, the position of each prim in the object is specified relative to that base pose. For example, the Cubby Object is constructed from a set of blocks that have translations specified relative to the base of the Cubby. The relative rotation is not specified, and so is assumed to be the identity. Target, Block, Sphere, and Capsule are the most basic possible variants of Object, as they are comprised of just a single prim. """ class Target(Object): def construct(self, **kwargs): size = kwargs.get("size", 0.05) target_color = kwargs.get("target_color", np.array([1.0, 0, 0])) self.create_target(target_size=size, target_color=target_color) def get_target(self, make_visible=True): target = self.targets[0] target.set_visibility(make_visible) return target class Block(Object): def construct(self, **kwargs): self.size = kwargs.get("size", 0.10 * np.ones(3)) # self.scales = kwargs.get("scales", np.array([1.0, 1.0, 1.0])) self.create_block(self.size) def get_component(self): return self.components[0] class Sphere(Object): def construct(self, **kwargs): self.radius = kwargs.get("radius", 0.10) self.create_sphere(self.radius) def get_geom(self): return self.components[0] class Capsule(Object): def construct(self, **kwargs): self.radius = kwargs.get("radius", 0.05) self.height = kwargs.get("height", 0.10) self.create_capsule(self.radius, self.height) def get_geom(self): return self.components[0] class Cubbies(Object): def construct(self, **kwargs): self.size = kwargs.get("size", 1) self.num_rows = kwargs.get("num_rows", 3) self.num_cols = kwargs.get("num_cols", 3) self.height = kwargs.get("height", 1.00) # z axis self.width = kwargs.get("width", 1.00) # y axis self.depth = kwargs.get("depth", 0.30) # x axis self.target_depth = kwargs.get("target_depth", self.depth / 2) self.cub_height = self.height / self.num_rows self.cub_width = self.width / self.num_cols back = self.create_block( self.size * np.array([0.01, self.width, self.height]), relative_translation=np.array([self.depth / 2, 0, self.height / 2]), ) for i in range(self.num_rows + 1): shelf = self.create_block( self.size * np.array([self.depth, self.width, 0.01]), relative_translation=np.array([0, 0, self.cub_height * i]), ) for i in range(self.num_cols + 1): shelf = self.create_block( self.size * np.array([self.depth, 0.01, self.height]), relative_translation=np.array([0, self.cub_width * i - self.width / 2, self.height / 2]), ) # Put a target in each shelf. target_x_offset = self.target_depth - self.depth / 2 target_start = np.array([target_x_offset, -self.width / 2 + self.cub_width / 2, self.cub_height / 2]) target_rot = R.from_rotvec([0, np.pi / 2, 0]).as_matrix() for i in range(self.num_rows): for j in range(self.num_cols): pos = target_start + np.array([0, self.cub_width * j, self.cub_height * i]) target = self.create_target(relative_translation=pos, relative_rotation=target_rot) class Cage(Object): def construct(self, **kwargs): self.ceiling_height = kwargs.get("ceiling_height", 0.75) self.ceiling_thickenss = kwargs.get("ceiling_thickness", 0.01) self.cage_width = kwargs.get("cage_width", 0.3) self.cage_length = kwargs.get("cage_length", 0.3) self.num_pillars = kwargs.get("num_pillars", 3) self.pillar_thickness = kwargs.get("pillar_thickness", 0.1) self.target_scalar = kwargs.get("target_scalar", 1.15) ceiling = self.create_block( np.array([2 * self.cage_width, 2 * self.cage_length, self.ceiling_thickenss]), np.array([0, 0, self.ceiling_height]), np.eye(3), ) for i in range(self.num_pillars): angle = 2 * (i + 0.5) * np.pi / self.num_pillars pillar_x = self.cage_width * np.cos(angle) pillar_y = self.cage_length * np.sin(angle) pillar = self.create_block( np.array([self.pillar_thickness, self.pillar_thickness, self.ceiling_height]), np.array([pillar_x, pillar_y, self.ceiling_height / 2]), np.eye(3), ) for angle in np.arange(0, 2 * np.pi, 0.1): target_x = (self.cage_width + self.pillar_thickness) * self.target_scalar * np.cos(angle) target_y = (self.cage_length + self.pillar_thickness) * self.target_scalar * np.sin(angle) self.create_target(np.array([target_x, target_y, self.ceiling_height / 2])) class Windmill(Object): def construct(self, **kwargs): self.size = kwargs.get("size", 1) # scales entire windmill self.num_blades = kwargs.get("num_blades", 2) self.blade_width = kwargs.get("blade_width", 0.01) # y axis self.blade_height = kwargs.get("blade_height", 1.00) # z axis self.blade_depth = kwargs.get("blade_depth", 0.01) # x axis for i in range(self.num_blades): rot = R.from_rotvec([i * np.pi / self.num_blades, 0, 0]) blade = self.create_block( self.size * np.array([self.blade_depth, self.blade_width, self.blade_height]), relative_rotation=rot.as_matrix(), ) class Window(Object): def construct(self, **kwargs): self.width = kwargs.get("width", 1.00) # y axis self.depth = kwargs.get("depth", 0.05) # x axis self.height = kwargs.get("height", 1.00) # z axis self.size = kwargs.get("size", 1) # scales entire window self.window_width = kwargs.get("window_width", 0.50) self.window_height = kwargs.get("window_height", 0.50) side_width = (self.width - self.window_width) / 2 side = self.create_block( self.size * np.array([self.depth, side_width, self.height]), relative_translation=np.array([0, -self.width / 2 + side_width / 2, 0]), ) side = self.create_block( self.size * np.array([self.depth, side_width, self.height]), relative_translation=np.array([0, +self.width / 2 - side_width / 2, 0]), ) top_height = (self.height - self.window_height) / 2 top = self.create_block( self.size * np.array([self.depth, self.width, top_height]), relative_translation=np.array([0, 0, self.height / 2 - top_height / 2]), ) bottom = self.create_block( self.size * np.array([self.depth, self.width, top_height]), relative_translation=np.array([0, 0, -self.height / 2 + top_height / 2]), ) self.center_target = self.create_target() # in center of window self.behind_target = self.create_target(relative_translation=np.array([self.depth, 0, 0])) self.front_target = self.create_target(relative_translation=np.array([-self.depth, 0, 0]))
8,135
Python
37.928229
111
0.613645
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.benchmark_environments/omni/isaac/benchmark_environments/environment_interface.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. # import numpy as np import omni.usd from pxr import UsdPhysics, PhysxSchema """ Environments have a set of Objects in them that can move or change over time. The default environment doesn't have any objects in it. Subclasses of Environment implement build_environment: instantiate all objects/targets in the environment according to **kwargs update: called every frame, update moves all moving elements of the environment and does any necessary maintainence get_new_scenario: return a series of targets that the robot should follow Environments have random seeds to ensure repeatability. This means that all randomness in the environment should be achieved through numpy's random module. As a convention, environments are displaced from the robot along the positive x axis, and mostly centered about the y axis. Some robots (such as the UR10) may need the environment to be rotated about the robot. The UR10's environment config file rotates each environment by pi/2 about the z axis. """ class Environment: def __init__(self, random_seed=0, **kwargs): self._stage = omni.usd.get_context().get_stage() self.objects = [] self.targetable_objects = [] self.random_seed = random_seed np.random.seed(random_seed) # get the frequency in Hz of the simulation physxSceneAPI = None for prim in self._stage.Traverse(): if prim.IsA(UsdPhysics.Scene): physxSceneAPI = PhysxSchema.PhysxSceneAPI.Apply(prim) if physxSceneAPI is not None: self.fps = physxSceneAPI.GetTimeStepsPerSecondAttr().Get() else: self.fps = 60 self.timeout = 10 # simulated seconds before a test times out self.camera_position = [-2.00, -1.00, 1.00] self.camera_target = [0.50, 0, 0.50] # Set thresholds for robot reaching translation/rotation targets self.target_translation_thresh = 0.03 self.target_rotation_thresh = 0.1 self.name = "" self.initial_robot_cspace_position = None self.build_environment(**kwargs) def get_timeout(self): return self.timeout def build_environment(self, **kwargs): pass def update(self): # update positions of moving obstacles/targets in environment as a function of time pass def get_new_scenario(self): """ Returns start_config (USD Geom): desired starting position of the robot (should be easy to reach to start the test) if None, the robot should ignore this scenario waypoints (USD Geom): desired goal position of the robot if None, the robot will follow the start_target until timeout is reached timeout (float): stop trial when timeout (seconds) have passes """ return None, [], self.timeout def enable_collisions(self): for obj in self.objects: obj.set_enable_collisions(True) def disable_collisions(self): for obj in self.objects: obj.set_enable_collisions(False) def get_all_obstacles(self): prims = [] for obj in self.objects: prims.extend(obj.get_all_components()) return prims def get_random_target(self, make_visible=True): if len(self.targetable_objects) == 0: return None obj = np.random.choice(self.targetable_objects) return obj.get_random_target(make_visible=make_visible) def reset(self, new_seed=None): if new_seed is not None: self.random_seed = new_seed self.first_update = True np.random.seed(self.random_seed) for obj in self.objects: obj.reset() def delete_all_objects(self): for obj in self.targetable_objects: obj.delete() for obj in self.objects: obj.delete() def get_initial_robot_cspace_position(self): return self.initial_robot_cspace_position def get_target_thresholds(self): return self.target_translation_thresh, self.target_rotation_thresh def set_target_translation_threshold(self, thresh): self.target_translation_thresh = thresh def set_target_rotation_threshold(self, thresh): self.target_rotation_thresh = thresh
4,765
Python
34.834586
126
0.670724
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.benchmark_environments/omni/isaac/benchmark_environments/object_interface.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.client import delete from pxr import UsdGeom, Gf, UsdPhysics import numpy as np import asyncio import uuid import omni.kit.app from omni.isaac.core.utils.prims import delete_prim from omni.isaac.core.utils.rotations import matrix_to_euler_angles, euler_angles_to_quat from omni.isaac.core.objects import cuboid, sphere, capsule from omni.isaac.core.prims import XFormPrim, GeometryPrimView def matrix_to_quat(rot_mat): return euler_angles_to_quat(matrix_to_euler_angles(rot_mat)) class Object: """ An Object is a collection of prims that move and change their properties together. A base Object has no prims in it by default because the construct method is empty. The Object Class is inherited by specific types of objects in objects.py and the construct function is implemented Objects have a base translation and rotation. All prims that form the object have a (fixed) translation and rotation that is relative to the base. The base pose can be updated with set_base_pose, and the world coordinate positions of every prim will be updated by their relative position to the base. Objects have two lists of prims: self.components, and self.targets self.components: prims that for the object that the robot must avoid self.targets: possible targets to make a robot seek. Ex. the cubby object has possible targets in each cubby that are transformed along with the base. A random target can be retrieved with self.get_random_target() Objects are made up of three primitives: capsules, spheres, and rectangular prisms TODO: allow meshes to be loaded for an object """ def __init__(self, base_translation, base_rotation, color=np.array([1.0, 1.0, 0]), **kwargs): self.initial_base_trans = base_translation self.initial_base_rotation = base_rotation self.components = [] self.color = color self.targets = [] self.last_target = None # make a random USD path for all the prims in this object object_id = str(uuid.uuid4()) self.base_path = ("/scene/object-" + object_id).replace("-", "_") self.base_xform = XFormPrim(self.base_path) self.base_xform.set_world_pose(base_translation, matrix_to_quat(base_rotation)) self.construct(**kwargs) self._geometry_view = GeometryPrimView(self.base_path + "/.*") self._geometry_view.apply_collision_apis() self.set_enable_collisions(False) def construct(self, **kwargs): pass def get_random_target(self, make_visible=True): if self.last_target is not None: self.last_target.set_visibility(False) if len(self.targets) > 0: target = np.random.choice(self.targets) target.set_visibility(make_visible) self.last_target = target return target def get_all_components(self): # get all prims that the robot should avoid return self.components def create_target( self, relative_translation=np.zeros(3), relative_rotation=np.eye(3), target_color=np.array([1.0, 0, 0]), target_size=0.05, ): path = self.base_path + "/target_" + str(len(self.targets)) target = cuboid.VisualCuboid(path, size=target_size, color=target_color) target.set_local_pose(relative_translation, matrix_to_quat(relative_rotation)) target.set_visibility(False) self.targets.append(target) return target def create_block(self, size, relative_translation=np.zeros(3), relative_rotation=np.eye(3)): path = self.base_path + "/cuboid_" + str(len(self.components)) cube = cuboid.FixedCuboid(path, size=1.0, scale=size, color=self.color) cube.set_local_pose(relative_translation, matrix_to_quat(relative_rotation)) self.components.append(cube) return cube def create_sphere(self, radius, relative_translation=np.zeros(3), relative_rotation=np.eye(3)): path = self.base_path + "/sphere_" + str(len(self.components)) sphere = sphere.FixedSphere(path, radius=radius, color=self.color) sphere.set_local_pose(relative_translation, matrix_to_quat(relative_rotation)) self.components.append(sphere) return sphere def create_capsule(self, radius, height, relative_translation=np.zeros(3), relative_rotation=np.eye(3)): path = self.base_path + "/capsule_" + str(len(self.components)) capsule = capsule.FixedCapsule(path, radius=radius, height=height, color=self.color) capsule.set_local_pose(relative_translation, matrix_to_quat(relative_rotation)) self.components.append(capsule) return capsule def set_base_pose(self, translation=np.zeros(3), rotation=np.eye(3)): self.base_xform.set_world_pose(translation, matrix_to_quat(rotation)) def set_visibility(self, on=True): for component in self.components: component.set_visibility(on) def set_enable_collisions(self, collisions_enabled=True): if collisions_enabled: self._geometry_view.enable_collision() else: self._geometry_view.disable_collision() def delete(self): for component in self.components: delete_prim(component.prim_path) self.components = [] for target in self.targets: delete_prim(target.prim_path) self.targets = [] def reset(self): self.set_base_pose(self.initial_base_trans, self.initial_base_rotation) for target in self.targets: target.set_visibility(False)
6,127
Python
37.3
114
0.679615
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.benchmark_environments/omni/isaac/benchmark_environments/environments.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. import numpy as np from scipy.spatial.transform import Rotation as R from .environment_interface import Environment from .objects import * """ The environment creator is used by the UI in Isaac Sim for the automatic discovery of environments that appear in a drop down menu. Some environments may not be available for certain robots, and the environment creator stores any relevant excluding of robots per environment. The creator is also used to validate the choice of environment when testing from a standalone script. """ class EnvironmentCreator: def __init__(self): self.environments = ["Static Cage", "Cubby", "Window", "Evasion", "Guillotine"] self.robot_exclusion_lists = {"Windmill": ["UR10"]} self.policy_exclusion_list = {} def create_environment(self, env_name, random_seed=0, **kwargs): if env_name == "Cubby": return CubbyEnv(random_seed=random_seed, **kwargs) elif env_name == "Evasion": return EvasionEnv(random_seed=random_seed, **kwargs) elif env_name == "Window": return WindowEnv(random_seed=random_seed, **kwargs) elif env_name == "Windmill": return WindmillEnv(random_seed=random_seed, **kwargs) elif env_name == "Guillotine": return GuillotineEnv(random_seed=random_seed, **kwargs) elif env_name == "Static Cage": return CageEnv(random_seed=random_seed, **kwargs) elif env_name == "Empty": return EmptyEnv(random_seed=random_seed, **kwargs) else: return None def has_environment(self, env_name): return env_name in self.environments def get_environment_names(self): return self.environments def get_robot_exclusion_list(self, env_name): # some robots should not be used in certain environments return self.robot_exclusion_lists.get(env_name, []) def get_motion_policy_exclusion_list(self, env_name): # some motion policies should not be used in certain environments # For example, global motion policies with slow update rates may not make sense # for environments with quickly moving obstacles or targets. return self.policy_exclusion_list.get(env_name, []) """ See comments above the Environment class in ./template_classes.py for information about the general behavior of all environments. These comments explain some implementation details when implementing the Environment class. Different environments are implemented below. Each environment has **kwargs that it can accept as an argument. Each robot has an environment config file with the desired kwargs for each environment. Any kwargs that are explicitly listed in the environment config file override the default kwargs seen in the kwargs.get() lines. There is not a rigid style for naming kwargs or deciding what kwargs are in a certain environment. The environments are not made with the assumption that every possible detail will be specified by a kwarg. Most position information can be passed in as a kwarg, but the relative positions of some objects may not be changeable. There are some magic numbers in the placement of certain objects when it would overcomplicate things to use kwargs and it is not likely that the param will need to change. Most parameters that are chosen arbitrarily, such as the speed of moving obstacles, are given as kwargs. As a convention, environments are displaced from the robot along the positive x axis, and mostly centered about the y axis. Some robots (such as the UR10) may need the environment to be rotated about the robot. The UR10's environment config file rotates each environment by pi/2 about the z axis. In general, the code for these environments are not written with the expectation that the user will never need to touch the code for their desired custom behavior. The code serves as more of an example for how to create different behaviors in different environments as needed. """ class CubbyEnv(Environment): def build_environment(self, **kwargs): """ Kwargs: name: human-readable name of this environment (default: "Cubby") initial_robot_cspace_position: If specified, this parameter can be accessed to determine a good starting cspace position for a robot in this environment timeout: simulated time (in seconds) before a test times out (default: 10) collidable: turn on collision detection for the cubby (default: False) target_translation_thresh: threshold for how close the robot end effector must be to translation targets in meters (default: .03) target_rotation_thresh: threshold for how close the robot end effector must be to rotation targets in radians (default: .1) base_rotation: axis-angle rotation of the cubby base (default: [0,0,0]) base_offset: 3d translation of the cubby base (default [45.0,0,0]) depth: The depth of the cubby shelves (default 30) target_depth: how deep the target is into the cubby (default half the depth) """ self.name = kwargs.get("name", "Cubby") self.initial_robot_cspace_position = kwargs.get("initial_robot_cspace_position", None) self.timeout = kwargs.get("timeout", 20) self.target_translation_thresh = kwargs.get("target_translation_thresh", 0.03) self.target_rotation_thresh = kwargs.get("target_rotation_thresh", 0.1) cub_rot = R.from_rotvec(kwargs.get("base_rotation", [0, 0, 0])) base_offset = np.array(kwargs.get("base_offset", [0.45, 0.0, 0])) depth = kwargs.get("depth", 0.30) target_depth = kwargs.get("target_depth", depth / 2) self.require_orientation = kwargs.get("require_orientation", True) # add an orientation target cub_pos = base_offset + np.array([0, 0, 0.20]) c = Cubbies(cub_pos, cub_rot.as_matrix(), require_orientation=False, depth=depth, target_depth=target_depth) target_pos = cub_pos / 2 + np.array([0.0, 0.0, c.height / 2]) self.start_target = Target( target_pos, R.from_rotvec([0, np.pi, 0]).as_matrix(), target_color=np.array([0, 0, 1.0]), require_orientation=True, ) base_pos = base_offset + np.array([0, 0, 0.10]) cubby_base = Block(base_pos, cub_rot.as_matrix(), size=np.array([c.depth, c.width, 0.20])) self.objects.append(c) self.objects.append(cubby_base) self.targetable_objects.append(c) def get_new_scenario(self): t1 = self.get_random_target(make_visible=False) t2 = self.get_random_target(make_visible=False) while t2 == t1: t2 = self.get_random_target(make_visible=False) waypoints = [t1, t2] return self.start_target.get_target(make_visible=True), waypoints, self.timeout class EvasionEnv(Environment): def build_environment(self, **kwargs): """ Kwargs: name: human-readable name of this environment (default: "Evasion") timeout: simulated time (in seconds) before a test times out (default: 300) target_translation_thresh: threshold for how close the robot end effector must be to translation targets in meters (default: .03) target_rotation_thresh: threshold for how close the robot end effector must be to rotation targets in radians (default: .1) target_speed: speed of the target along a sinusoidal path in rad/sec (default: .2) block_speeds: 6d vector of speeds for the blocks moving along sinusoidal paths in rad/sec (default: np.linspace(.1, .3, num=6)) block_sizes: 6d vector of the sizes of each block (default [15,15,15,15,15,15]) frames_per_update: number of frames that should pass before obstacle/target positions are updated (default: 1) -- This approximates lag in perception target_position_std_dev: standard deviation of target position offset from the set path on every frame (default: 0) obstacle_position_std_dev: standard deviation of obstacle positions offset from their set path on every frame (default: 0) height: height of target/average heights of obstacles off the ground """ self.name = kwargs.get("name", "Evasion") self.initial_robot_cspace_position = kwargs.get("initial_robot_cspace_position", None) self.timeout = kwargs.get("timeout", 300) self.target_translation_thresh = kwargs.get("target_translation_thresh", 0.03) self.target_rotation_thresh = kwargs.get("target_rotation_thresh", 0.1) self.target_speed = kwargs.get("target_speed", 0.2) # rad/sec # blocks move sinusoidally with the given frequencies self.block_speeds = np.array(kwargs.get("block_speeds", np.linspace(0.1, 0.3, num=6))) self.block_sizes = np.array(kwargs.get("block_sizes", [0.15] * 6), dtype=int) # the size of each block # Update postions once every frame by default. self.frames_per_update = kwargs.get("frames_per_update", 1) # std_dev of gaussian noise to target position self.target_position_std_dev = kwargs.get("target_position_std_dev", 0) self.obstacle_position_std_dev = kwargs.get("obstacle_position_std_dev", 0) height = kwargs.get("height", 0.50) self.target = Target(np.array([0.60, 0.0, height]), np.eye(3)) self.objects.append(self.target) self.blocks = [] for i, position in enumerate(np.linspace([0.40, -0.50, height], [0.40, 0.50, height], num=6)): self.blocks.append(Block(position, np.eye(3), size=0.150 * np.ones(3))) self.objects.extend(self.blocks) self.first_update = True def get_new_scenario(self): self.first_update = True return self.target.get_target(make_visible=True), [], self.timeout def update(self): if self.first_update: self.frame_number = 0 self.first_update = False else: self.frame_number += 1 # Because robot perception can be slow, this slows down the world updates by a factor of self.frames_per_update. t = (self.frame_number // self.frames_per_update) * self.frames_per_update pos = ( self.target.initial_base_trans + np.array([0, 0.50 * np.sin(self.target_speed / self.fps * t), 0]) + np.random.normal(0, self.target_position_std_dev) ) self.target.set_base_pose(translation=pos) for block, speed in zip(self.blocks, self.block_speeds): pos = ( block.initial_base_trans + np.array([0, 0, 0.40 * np.sin(speed / self.fps * t)]) + np.random.normal(0, self.obstacle_position_std_dev) ) block.set_base_pose(translation=pos) class WindmillEnv(Environment): def build_environment(self, **kwargs): """ Kwargs: name: human-readable name of this environment (default: "Windmill") timeout: simulated time (in seconds) before a test times out (default: 300) target_translation_thresh: threshold for how close the robot end effector must be to translation targets in meters (default: .03) target_rotation_thresh: threshold for how close the robot end effector must be to rotation targets in radians (default: .1) windmill_1_speed: rotational speed of windmill 1 in rad/sec (default: pi/15) windmill_2_speed: rotational speed of windmill 2 in rad/sec (default: pi/15) windmill_1_translation: translational position of windmill 1 (default [35,0,50]) windmill_2_translation: translational position of windmill 1 (default [40,0,50]) target_pos: position of target behind windmills (default [50,0,70]) env_rotation: axis rotation of environmnet at the world origin (default [0,0,0]) """ self.name = kwargs.get("name", "Windmill") self.timeout = kwargs.get("timeout", 300) self.initial_robot_cspace_position = kwargs.get("initial_robot_cspace_position", None) self.target_translation_thresh = kwargs.get("target_translation_thresh", 0.03) self.target_rotation_thresh = kwargs.get("target_rotation_thresh", 0.1) self.speed1 = kwargs.get("windmill_1_speed", np.pi / 15) self.speed2 = kwargs.get("windmill_2_speed", np.pi / 25) self.bt1 = np.array(kwargs.get("windmill_1_translation", [0.40, 0, 0.50])) self.bt2 = np.array(kwargs.get("windmill_2_translation", [0.45, 0, 0.50])) self.br1 = np.eye(3) self.br2 = np.eye(3) self.t_pos = np.array(kwargs.get("target_pos", [0.50, 0, 0.70])) self.env_rotation = R.from_rotvec( np.array(kwargs.get("env_rotation", [0, 0, 0])) ).as_matrix() # Rotate the entire environment about the robot. self.bt1 = self.env_rotation @ self.bt1 self.bt2 = self.env_rotation @ self.bt2 self.br1 = self.env_rotation @ self.br1 self.br2 = self.env_rotation @ self.br2 self.t_pos = self.env_rotation @ self.t_pos self.rot_axs = self.env_rotation @ np.array([1, 0, 0]) self.w1 = Windmill(self.bt1, self.br1) self.w2 = Windmill(self.bt2, self.br2, num_blades=3) self.objects.append(self.w1) self.objects.append(self.w2) self.target = Target(self.t_pos, np.eye(3)) self.start_target = Target(self.w1.initial_base_trans / 2, np.eye(3), target_color=np.array([0, 0, 1.0])) self.mid_target = Target(self.w1.initial_base_trans / 2, np.eye(3)) self.frame_number = 0 def update(self): self.frame_number += 1 t = self.frame_number p1 = self.w1.initial_base_trans p2 = self.w2.initial_base_trans rot1 = R.from_rotvec(self.speed1 / self.fps * t * self.rot_axs).as_matrix() @ self.w1.initial_base_rotation rot2 = R.from_rotvec(self.speed2 / self.fps * t * self.rot_axs).as_matrix() @ self.w2.initial_base_rotation self.w1.set_base_pose(p1, rot1) self.w2.set_base_pose(p2, rot2) def get_new_scenario(self): sg = self.start_target.get_target(make_visible=True) mg = self.mid_target.get_target() tg = self.target.get_target() return sg, [tg, mg, tg], self.timeout class WindowEnv(Environment): def build_environment(self, **kwargs): """ Kwargs: name: human-readable name of this environment (default: "Window") timeout: simulated time (in seconds) before a test times out (default: 20) target_translation_thresh: threshold for how close the robot end effector must be to translation targets in meters (default: .03) target_rotation_thresh: threshold for how close the robot end effector must be to rotation targets in radians (default: .1) window_translation: translational position of window (default [45,-30, 50]) env_rotation: axis rotation of environmnet at the world origin (default [0,0,0]) """ self.name = kwargs.get("name", "Window") self.timeout = kwargs.get("timeout", 20) self.initial_robot_cspace_position = kwargs.get("initial_robot_cspace_position", None) self.target_translation_thresh = kwargs.get("target_translation_thresh", 0.03) self.target_rotation_thresh = kwargs.get("target_rotation_thresh", 0.1) self.window_trans = np.array(kwargs.get("window_translation", [0.45, -0.30, 0.50])) self.window_rotation = np.eye(3) env_rotation = R.from_rotvec( np.array(kwargs.get("env_rotation", [0, 0, 0])) ).as_matrix() # Rotate the entire environment about the robot. self.window_trans = env_rotation @ self.window_trans self.window_rotation = env_rotation @ self.window_rotation self.window = Window(self.window_trans, self.window_rotation, window_width=0.30, window_height=0.30) self.start_target = Target(self.window_trans / 2, self.window_rotation, target_color=np.array([0, 0, 1.0])) self.objects.append(self.window) self.end_target = Target(np.array([*1.3 * self.window_trans[:2], self.window_trans[2]]), self.window_rotation) def get_new_scenario(self): return ( self.start_target.get_target(), [ self.window.front_target, self.window.center_target, self.window.behind_target, self.end_target.get_target(make_visible=False), ], self.timeout, ) class GuillotineEnv(Environment): def build_environment(self, **kwargs): """ Kwargs: name: human-readable name of this environment (default: "Guillotine") timeout: simulated time (in seconds) before a test times out (default: 20) target_translation_thresh: threshold for how close the robot end effector must be to translation targets in meters (default: .03) target_rotation_thresh: threshold for how close the robot end effector must be to rotation targets in radians (default: .1) wall_height: height of wall the robot has to reach through (default: 100) windmill_speed: speed of windmill embedded in wall in rad/sec (default: pi/15) window_translation: translational position of window embedded in wall (default [50,0, wall_height/2]) windmill_translation: translational position of windmill (default: [55,0,wall_height/2+30]) env_rotation: axis rotation of environmnet at the world origin (default [0,0,0]) """ self.name = kwargs.get("name", "Guillotine") self.timeout = kwargs.get("timeout", 20) self.initial_robot_cspace_position = kwargs.get("initial_robot_cspace_position", None) self.target_translation_thresh = kwargs.get("target_translation_thresh", 0.03) self.target_rotation_thresh = kwargs.get("target_rotation_thresh", 0.1) self.wall_height = kwargs.get("wall_height", 1.00) self.speed = kwargs.get("windmill_speed", np.pi / 15) self.window_trans = np.array(kwargs.get("window_translation", [0.50, 0, self.wall_height / 2])) end_target_trans = np.array([1.5 * self.window_trans[0], 0, self.wall_height / 2]) self.window_rotation = np.eye(3) self.windmill_trans = np.array(kwargs.get("windmill_translation", [0.55, 0, self.wall_height / 2 + 0.30])) self.windmill_rot_axs = np.array([1, 0, 0]) self.windmill_rotation = self.window_rotation self.env_rotation = R.from_rotvec( np.array(kwargs.get("env_rotation", [0, 0, 0])) ).as_matrix() # Rotate the entire environment about the robot. self.window_trans = self.env_rotation @ self.window_trans self.window_rotation = self.env_rotation @ self.window_rotation self.windmill_trans = self.env_rotation @ self.windmill_trans self.windmill_rotation = self.env_rotation @ self.windmill_rotation self.windmill_rot_axs = self.env_rotation @ self.windmill_rot_axs self.window = Window( self.window_trans, self.window_rotation, height=self.wall_height, window_width=0.30, window_height=0.30, depth=0.20, ) self.windmill = Windmill(self.windmill_trans, self.windmill_rotation, blade_width=0.10) self.start_target = Target(self.window_trans / 2, self.window_rotation, target_color=np.array([0, 0, 1.0])) self.objects.append(self.window) self.objects.append(self.windmill) self.end_target = Target(self.env_rotation @ end_target_trans, self.window_rotation) self.frame_number = 0 self.camera_position = self.env_rotation @ np.array([2.00, -1.00, 1.00]) self.camera_target = self.env_rotation @ np.array([0, 0, 0.50]) def update(self): self.frame_number += 1 t = self.frame_number rot = ( R.from_rotvec(self.speed / self.fps * t * self.windmill_rot_axs).as_matrix() @ self.windmill.initial_base_rotation ) self.windmill.set_base_pose(self.windmill.initial_base_trans, rot) end_tgt = self.end_target.initial_base_trans + self.env_rotation @ ( 10 * np.array([0, np.cos(t * self.speed / self.fps), np.sin(t * self.speed / self.fps)]) ) self.end_target.set_base_pose(end_tgt, self.window_rotation) def get_new_scenario(self): return ( self.start_target.get_target(), [ self.window.front_target, self.window.center_target, self.window.behind_target, self.end_target.get_target(make_visible=True), ], self.timeout, ) class CageEnv(Environment): def build_environment(self, **kwargs): """ Kwargs: name: human-readable name of this environment (default: "Cage") timeout: simulated time (in seconds) before a test times out (default: 20) target_translation_thresh: threshold for how close the robot end effector must be to translation targets in meters (default: .03) target_rotation_thresh: threshold for how close the robot end effector must be to rotation targets in radians (default: .1) ceiling_height: height of ceiling of cage (default .75 m) ceiling_thickness: thickness (along z axis) of ceiling (default .01 m) cage_width: width (along x axis) of cage (default .35 m) cage_length: length (along y axis) of cage (default .35 m) num_pillars: number of pillars defining the "bars" of the cage. The pillars will be evenly spaced by angle around the elipse defined by cage_width and cage_length pillar_thickness: thickness of pillars (default .1 m) target_scalar: a scalar defining the distance from the robot to the targets. Potential targets are arranged in an ovoid around the robot with a width of target_scalar*cage_width and a length of target_scalar*cage_length. A value of 1 would place some targets inside the pillars (default 1.15) """ self.name = kwargs.get("name", "Cage") self.timeout = kwargs.get("timeout", 20) self.initial_robot_cspace_position = kwargs.get("initial_robot_cspace_position", None) self.target_translation_thresh = kwargs.get("target_translation_thresh", 0.03) self.target_rotation_thresh = kwargs.get("target_rotation_thresh", 0.1) self.ceiling_height = kwargs.get("ceiling_height", 0.75) self.ceiling_thickenss = kwargs.get("ceiling_thickness", 0.01) self.cage_width = kwargs.get("cage_width", 0.35) self.cage_length = kwargs.get("cage_length", 0.35) self.num_pillars = kwargs.get("num_pillars", 4) self.pillar_thickness = kwargs.get("pillar_thickness", 0.1) self.target_scalar = kwargs.get("target_scalar", 1.15) self.objects = [] self.cage = Cage( np.zeros(3), np.eye(3), ceiling_height=self.ceiling_height, ceiling_thickness=self.ceiling_thickenss, cage_width=self.cage_width, cage_length=self.cage_length, num_pillars=self.num_pillars, pillar_thickness=self.pillar_thickness, target_scalar=self.target_scalar, ) self.objects.append(self.cage) self.start_target = Target( np.array([(self.cage_width - self.pillar_thickness / 2) / 1.25, 0, self.ceiling_height / 2]), np.eye(3), target_color=np.array([0, 0, 1.0]), ) def get_new_scenario(self): return ( self.start_target.get_target(), [ self.cage.get_random_target(False), self.cage.get_random_target(False), self.cage.get_random_target(False), ], self.timeout, ) class EmptyEnv(Environment): def build_environment(self, **kwargs): self.name = "Empty" def get_new_scenario(self): return None, [], self.timeout
25,286
Python
43.363158
148
0.635371
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.benchmark_environments/docs/CHANGELOG.md
# Changelog ## [0.4.0] - 2022-07-06 ### Added - Added Cage environment ## [0.3.0] - 2022-05-09 ### Changed - Updated all hard coded USD object values to meters ## [0.2.0] - 2022-02-10 ### Changed - updated object instantiation to use Core API ## [0.1.2] - 2021-10-22 ### Changed - use delete_prim from omni.isaac.core ## [0.1.1] - 2021-10-09 ### Changed - Folder structure reorganized ## [0.1.0] - 2021-08-10 ### Added - Initial version of Isaac Sim Benchmark Environments Extension
494
Markdown
14.967741
63
0.653846
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.benchmark_environments/docs/README.md
# Usage To enable this extension, go to the Extension Manager menu and enable omni.isaac.benchmark_environments extension.
125
Markdown
24.199995
114
0.808
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.urdf/config/extension.toml
[core] reloadable = true order = 0 [package] version = "0.5.9" category = "Simulation" title = "Isaac Sim URDF Importer" description = "URDF Importer for Isaac Sim" authors = ["NVIDIA"] repository = "" keywords = ["isaac", "urdf", "import"] changelog = "docs/CHANGELOG.md" readme = "docs/README.md" icon = "data/icon.png" writeTarget.kit = true [dependencies] "omni.kit.uiapp" = {} "omni.isaac.ui" = {} "omni.kit.window.filepicker" = {} "omni.kit.window.content_browser" = {} "omni.kit.viewport.utility" = {} "omni.kit.pip_archive" = {} # pulls in pillow "omni.physx" = {} [[python.module]] name = "omni.isaac.urdf" [[python.module]] name = "omni.isaac.urdf.tests" [[python.module]] name = "omni.isaac.urdf.scripts.samples.import_carter" [[python.module]] name = "omni.isaac.urdf.scripts.samples.import_franka" [[python.module]] name = "omni.isaac.urdf.scripts.samples.import_kaya" [[python.module]] name = "omni.isaac.urdf.scripts.samples.import_ur10" [[native.plugin]] path = "bin/*.plugin" recursive = false [[test]] # this is to catch issues where our assimp is out of sync with the one that comes with # asset importer as this can cause segfaults due to binary incompatibility. dependencies = ["omni.kit.tool.asset_importer"] stdoutFailPatterns.exclude = [ "*extension object is still alive, something holds a reference on it*", # exclude warning as failure ]
1,384
TOML
22.87931
104
0.70448
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.urdf/omni/isaac/urdf/scripts/commands.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. # import omni.kit.commands import omni.kit.utils from omni.isaac.urdf import _urdf import os from pxr import Usd from omni.client._omniclient import Result import omni.client class URDFCreateImportConfig(omni.kit.commands.Command): """ Returns an ImportConfig object that can be used while parsing and importing. Should be used with `URDFParseFile` and `URDFParseAndImportFile` commands Returns: :obj:`omni.isaac.urdf._urdf.ImportConfig`: Parsed URDF stored in an internal structure. """ def __init__(self) -> None: pass def do(self) -> _urdf.ImportConfig: return _urdf.ImportConfig() def undo(self) -> None: pass class URDFParseFile(omni.kit.commands.Command): """ This command parses a given urdf and returns a UrdfRobot object Args: arg0 (:obj:`str`): The absolute path to where the urdf file is arg1 (:obj:`omni.isaac.urdf._urdf.ImportConfig`): Import Configuration Returns: :obj:`omni.isaac.urdf._urdf.UrdfRobot`: Parsed URDF stored in an internal structure. """ def __init__(self, urdf_path: str = "", import_config: _urdf.ImportConfig = _urdf.ImportConfig()) -> None: self._root_path, self._filename = os.path.split(os.path.abspath(urdf_path)) self._import_config = import_config self._urdf_interface = _urdf.acquire_urdf_interface() pass def do(self) -> _urdf.UrdfRobot: return self._urdf_interface.parse_urdf(self._root_path, self._filename, self._import_config) def undo(self) -> None: pass class URDFParseAndImportFile(omni.kit.commands.Command): """ This command parses and imports a given urdf and returns a UrdfRobot object Args: arg0 (:obj:`str`): The absolute path to where the urdf file is arg1 (:obj:`omni.isaac.urdf._urdf.ImportConfig`): Import Configuration arg2 (:obj:`str`): destination path for robot usd. Default is "" which will load the robot in-memory on the open stage. Returns: :obj:`str`: Path to the robot on the USD stage. """ def __init__(self, urdf_path: str = "", import_config=_urdf.ImportConfig(), dest_path: str = "") -> None: self.dest_path = dest_path self._urdf_path = urdf_path self._root_path, self._filename = os.path.split(os.path.abspath(urdf_path)) self._import_config = import_config self._urdf_interface = _urdf.acquire_urdf_interface() pass def do(self) -> str: status, imported_robot = omni.kit.commands.execute( "URDFParseFile", urdf_path=self._urdf_path, import_config=self._import_config ) if self.dest_path: self.dest_path = self.dest_path.replace( "\\", "/" ) # Omni client works with both slashes cross platform, making it standard to make it easier later on result = omni.client.read_file(self.dest_path) if result[0] != Result.OK: stage = Usd.Stage.CreateNew(self.dest_path) stage.Save() return self._urdf_interface.import_robot( self._root_path, self._filename, imported_robot, self._import_config, self.dest_path ) def undo(self) -> None: pass omni.kit.commands.register_all_commands_in_module(__name__)
3,772
Python
33.614679
127
0.659332
swadaskar/Isaac_Sim_Folder/exts/omni.isaac.urdf/docs/README.md
# Usage To enable this extension, go to the Extension Manager menu and enable omni.isaac.urdf extension.
107
Markdown
20.599996
96
0.785047
swadaskar/Isaac_Sim_Folder/ros2_workspace/src/navigation/carter_navigation/launch/carter_navigation.launch.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. import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description(): use_sim_time = LaunchConfiguration("use_sim_time", default="True") map_dir = LaunchConfiguration( "map", default=os.path.join( get_package_share_directory("carter_navigation"), "maps", "carter_warehouse_navigation.yaml" ), ) param_dir = LaunchConfiguration( "params_file", default=os.path.join( get_package_share_directory("carter_navigation"), "params", "carter_navigation_params.yaml" ), ) nav2_bringup_launch_dir = os.path.join(get_package_share_directory("nav2_bringup"), "launch") rviz_config_dir = os.path.join(get_package_share_directory("carter_navigation"), "rviz2", "carter_navigation.rviz") return LaunchDescription( [ DeclareLaunchArgument("map", default_value=map_dir, description="Full path to map file to load"), DeclareLaunchArgument( "params_file", default_value=param_dir, description="Full path to param file to load" ), DeclareLaunchArgument( "use_sim_time", default_value="true", description="Use simulation (Omniverse Isaac Sim) clock if true" ), IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(nav2_bringup_launch_dir, "rviz_launch.py")), launch_arguments={"namespace": "", "use_namespace": "False", "rviz_config": rviz_config_dir}.items(), ), IncludeLaunchDescription( PythonLaunchDescriptionSource([nav2_bringup_launch_dir, "/bringup_launch.py"]), launch_arguments={"map": map_dir, "use_sim_time": use_sim_time, "params_file": param_dir}.items(), ), ] )
2,582
Python
42.77966
119
0.684741
swadaskar/Isaac_Sim_Folder/extension_examples/path_planning/path_planning.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 .path_planning_task import FrankaPathPlanningTask from .path_planning_controller import FrankaRrtController class PathPlanning(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(FrankaPathPlanningTask("Plan To Target Task")) 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 async def setup_post_load(self): self._franka_task = list(self._world.get_current_tasks().values())[0] self._task_params = self._franka_task.get_params() my_franka = self._world.scene.get_object(self._task_params["robot_name"]["value"]) self._controller = FrankaRrtController(name="franka_rrt_controller", robot_articulation=my_franka) self._articulation_controller = my_franka.get_articulation_controller() return async def _on_follow_target_event_async(self): world = self.get_world() self._pass_world_state_to_controller() await world.play_async() if not world.physics_callback_exists("sim_step"): world.add_physics_callback("sim_step", self._on_follow_target_simulation_step) def _pass_world_state_to_controller(self): self._controller.reset() for wall in self._franka_task.get_obstacles(): self._controller.add_obstacle(wall) def _on_follow_target_simulation_step(self, step_size): if self._franka_task.target_reached(): return observations = self._world.get_observations() actions = self._controller.forward( target_end_effector_position=observations[self._task_params["target_name"]["value"]]["position"], target_end_effector_orientation=observations[self._task_params["target_name"]["value"]]["orientation"], ) kps, kds = self._franka_task.get_custom_gains() self._articulation_controller.set_gains(kps, kds) self._articulation_controller.apply_action(actions) return def _on_add_wall_event(self): world = self.get_world() current_task = list(world.get_current_tasks().values())[0] cube = current_task.add_obstacle() return def _on_remove_wall_event(self): world = self.get_world() current_task = list(world.get_current_tasks().values())[0] obstacle_to_delete = current_task.get_obstacle_to_delete() current_task.remove_obstacle() return def _on_logging_event(self, val): world = self.get_world() data_logger = world.get_data_logger() if not world.get_data_logger().is_started(): robot_name = self._task_params["robot_name"]["value"] target_name = self._task_params["target_name"]["value"] def frame_logging_func(tasks, scene): return { "joint_positions": scene.get_object(robot_name).get_joint_positions().tolist(), "applied_joint_positions": scene.get_object(robot_name) .get_applied_action() .joint_positions.tolist(), "target_position": scene.get_object(target_name).get_world_pose()[0].tolist(), } data_logger.add_data_frame_logging_func(frame_logging_func) if val: data_logger.start() else: data_logger.pause() return def _on_save_data_event(self, log_path): world = self.get_world() data_logger = world.get_data_logger() data_logger.save(log_path=log_path) data_logger.reset() return
4,442
Python
38.669643
115
0.632823
swadaskar/Isaac_Sim_Folder/extension_examples/path_planning/path_planning_task.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. from omni.isaac.core.tasks import BaseTask from omni.isaac.franka import Franka from omni.isaac.core.prims import XFormPrim from omni.isaac.core.utils.prims import is_prim_path_valid from omni.isaac.core.utils.string import find_unique_string_name from omni.isaac.core.utils.rotations import euler_angles_to_quat from omni.isaac.core.scenes.scene import Scene from omni.isaac.core.objects import FixedCuboid, VisualCuboid from omni.isaac.core.utils.stage import get_stage_units from collections import OrderedDict from typing import Optional, List, Tuple import numpy as np class PathPlanningTask(BaseTask): def __init__( self, name: str, target_prim_path: Optional[str] = None, target_name: Optional[str] = None, target_position: Optional[np.ndarray] = None, target_orientation: Optional[np.ndarray] = None, offset: Optional[np.ndarray] = None, ) -> None: BaseTask.__init__(self, name=name, offset=offset) self._robot = None self._target_name = target_name self._target = None self._target_prim_path = target_prim_path self._target_position = target_position self._target_orientation = target_orientation self._target_visual_material = None self._obstacle_walls = OrderedDict() if self._target_position is None: self._target_position = np.array([0.8, 0.3, 0.4]) / get_stage_units() return def set_up_scene(self, scene: Scene) -> None: """[summary] Args: scene (Scene): [description] """ super().set_up_scene(scene) scene.add_default_ground_plane() if self._target_orientation is None: self._target_orientation = euler_angles_to_quat(np.array([-np.pi, 0, np.pi])) if self._target_prim_path is None: self._target_prim_path = find_unique_string_name( initial_name="/World/TargetCube", is_unique_fn=lambda x: not is_prim_path_valid(x) ) if self._target_name is None: self._target_name = find_unique_string_name( initial_name="target", is_unique_fn=lambda x: not self.scene.object_exists(x) ) self.set_params( target_prim_path=self._target_prim_path, target_position=self._target_position, target_orientation=self._target_orientation, target_name=self._target_name, ) self._robot = self.set_robot() scene.add(self._robot) self._task_objects[self._robot.name] = self._robot self._move_task_objects_to_their_frame() return def set_params( self, target_prim_path: Optional[str] = None, target_name: Optional[str] = None, target_position: Optional[np.ndarray] = None, target_orientation: Optional[np.ndarray] = None, ) -> None: """[summary] Args: target_prim_path (Optional[str], optional): [description]. Defaults to None. target_name (Optional[str], optional): [description]. Defaults to None. target_position (Optional[np.ndarray], optional): [description]. Defaults to None. target_orientation (Optional[np.ndarray], optional): [description]. Defaults to None. """ if target_prim_path is not None: if self._target is not None: del self._task_objects[self._target.name] if is_prim_path_valid(target_prim_path): self._target = self.scene.add( XFormPrim( prim_path=target_prim_path, position=target_position, orientation=target_orientation, name=target_name, ) ) else: self._target = self.scene.add( VisualCuboid( name=target_name, prim_path=target_prim_path, position=target_position, orientation=target_orientation, color=np.array([1, 0, 0]), size=1.0, scale=np.array([0.03, 0.03, 0.03]) / get_stage_units(), ) ) self._task_objects[self._target.name] = self._target self._target_visual_material = self._target.get_applied_visual_material() if self._target_visual_material is not None: if hasattr(self._target_visual_material, "set_color"): self._target_visual_material.set_color(np.array([1, 0, 0])) else: self._target.set_local_pose(position=target_position, orientation=target_orientation) return def get_params(self) -> dict: """[summary] Returns: dict: [description] """ params_representation = dict() params_representation["target_prim_path"] = {"value": self._target.prim_path, "modifiable": True} params_representation["target_name"] = {"value": self._target.name, "modifiable": True} position, orientation = self._target.get_local_pose() params_representation["target_position"] = {"value": position, "modifiable": True} params_representation["target_orientation"] = {"value": orientation, "modifiable": True} params_representation["robot_name"] = {"value": self._robot.name, "modifiable": False} return params_representation def get_task_objects(self) -> dict: """[summary] Returns: dict: [description] """ return self._task_objects def get_observations(self) -> dict: """[summary] Returns: dict: [description] """ joints_state = self._robot.get_joints_state() target_position, target_orientation = self._target.get_local_pose() return { self._robot.name: { "joint_positions": np.array(joints_state.positions), "joint_velocities": np.array(joints_state.velocities), }, self._target.name: {"position": np.array(target_position), "orientation": np.array(target_orientation)}, } def target_reached(self) -> bool: """[summary] Returns: bool: [description] """ end_effector_position, _ = self._robot.end_effector.get_world_pose() target_position, _ = self._target.get_world_pose() if np.mean(np.abs(np.array(end_effector_position) - np.array(target_position))) < (0.035 / get_stage_units()): return True else: return False def pre_step(self, time_step_index: int, simulation_time: float) -> None: """[summary] Args: time_step_index (int): [description] simulation_time (float): [description] """ if self._target_visual_material is not None: if hasattr(self._target_visual_material, "set_color"): if self.target_reached(): self._target_visual_material.set_color(color=np.array([0, 1.0, 0])) else: self._target_visual_material.set_color(color=np.array([1.0, 0, 0])) return def add_obstacle(self, position: np.ndarray = None, orientation=None): """[summary] Args: position (np.ndarray, optional): [description]. Defaults to np.array([0.1, 0.1, 1.0]). """ # TODO: move to task frame if there is one cube_prim_path = find_unique_string_name( initial_name="/World/WallObstacle", is_unique_fn=lambda x: not is_prim_path_valid(x) ) cube_name = find_unique_string_name(initial_name="wall", is_unique_fn=lambda x: not self.scene.object_exists(x)) if position is None: position = np.array([0.6, 0.1, 0.3]) / get_stage_units() if orientation is None: orientation = euler_angles_to_quat(np.array([0, 0, np.pi / 3])) cube = self.scene.add( VisualCuboid( name=cube_name, position=position + self._offset, orientation=orientation, prim_path=cube_prim_path, size=1.0, scale=np.array([0.1, 0.5, 0.6]) / get_stage_units(), color=np.array([0, 0, 1.0]), ) ) self._obstacle_walls[cube.name] = cube return cube def remove_obstacle(self, name: Optional[str] = None) -> None: """[summary] Args: name (Optional[str], optional): [description]. Defaults to None. """ if name is not None: self.scene.remove_object(name) del self._obstacle_walls[name] else: obstacle_to_delete = list(self._obstacle_walls.keys())[-1] self.scene.remove_object(obstacle_to_delete) del self._obstacle_walls[obstacle_to_delete] return def get_obstacles(self) -> List: return list(self._obstacle_walls.values()) def get_obstacle_to_delete(self) -> None: """[summary] Returns: [type]: [description] """ obstacle_to_delete = list(self._obstacle_walls.keys())[-1] return self.scene.get_object(obstacle_to_delete) def obstacles_exist(self) -> bool: """[summary] Returns: bool: [description] """ if len(self._obstacle_walls) > 0: return True else: return False def cleanup(self) -> None: """[summary] """ obstacles_to_delete = list(self._obstacle_walls.keys()) for obstacle_to_delete in obstacles_to_delete: self.scene.remove_object(obstacle_to_delete) del self._obstacle_walls[obstacle_to_delete] return def get_custom_gains(self) -> Tuple[np.array, np.array]: return None, None class FrankaPathPlanningTask(PathPlanningTask): def __init__( self, name: str, target_prim_path: Optional[str] = None, target_name: Optional[str] = None, target_position: Optional[np.ndarray] = None, target_orientation: Optional[np.ndarray] = None, offset: Optional[np.ndarray] = None, franka_prim_path: Optional[str] = None, franka_robot_name: Optional[str] = None, ) -> None: PathPlanningTask.__init__( self, name=name, target_prim_path=target_prim_path, target_name=target_name, target_position=target_position, target_orientation=target_orientation, offset=offset, ) self._franka_prim_path = franka_prim_path self._franka_robot_name = franka_robot_name self._franka = None return def set_robot(self) -> Franka: """[summary] Returns: Franka: [description] """ if self._franka_prim_path is None: self._franka_prim_path = find_unique_string_name( initial_name="/World/Franka", is_unique_fn=lambda x: not is_prim_path_valid(x) ) if self._franka_robot_name is None: self._franka_robot_name = find_unique_string_name( initial_name="my_franka", is_unique_fn=lambda x: not self.scene.object_exists(x) ) self._franka = Franka(prim_path=self._franka_prim_path, name=self._franka_robot_name) return self._franka def get_custom_gains(self) -> Tuple[np.array, np.array]: return ( 6 * np.array([1.0e08, 1.0e08, 1.0e08, 1.0e08, 1.0e08, 1.0e08, 1.0e08, 1.0e07, 1.0e07]), 10 * np.array( [ 10000000.0, 10000000.0, 10000000.0, 10000000.0, 10000000.0, 10000000.0, 10000000.0, 1000000.0, 1000000.0, ] ), )
12,634
Python
36.716418
120
0.56435
swadaskar/Isaac_Sim_Folder/extension_examples/path_planning/path_planning_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.path_planning import PathPlanning import asyncio import omni.ui as ui from omni.isaac.ui.ui_utils import btn_builder, str_builder, state_btn_builder import carb class PathPlanningExtension(BaseSampleExtension): def on_startup(self, ext_id: str): super().on_startup(ext_id) super().start_extension( menu_name="Manipulation", submenu_name="", name="Path Planning", title="Path Planning Task", doc_link="https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/overview.html", overview="This Example shows how to plan a path through a complicated static environment with the Franka robot in Isaac Sim.\n\nPress the 'Open in IDE' button to view the source code.", sample=PathPlanning(), file_path=os.path.abspath(__file__), number_of_extra_frames=2, ) self.task_ui_elements = {} frame = self.get_frame(index=0) self.build_task_controls_ui(frame) frame = self.get_frame(index=1) self.build_data_logging_ui(frame) return def _on_follow_target_button_event(self): asyncio.ensure_future(self.sample._on_follow_target_event_async()) return def _on_add_wall_button_event(self): self.sample._on_add_wall_event() self.task_ui_elements["Remove Wall"].enabled = True return def _on_remove_wall_button_event(self): self.sample._on_remove_wall_event() world = self.sample.get_world() current_task = list(world.get_current_tasks().values())[0] if not current_task.obstacles_exist(): self.task_ui_elements["Remove Wall"].enabled = False return def _on_logging_button_event(self, val): self.sample._on_logging_event(val) self.task_ui_elements["Save Data"].enabled = True return def _on_save_data_button_event(self): self.sample._on_save_data_event(self.task_ui_elements["Output Directory"].get_value_as_string()) return def post_reset_button_event(self): self.task_ui_elements["Move To Target"].enabled = True self.task_ui_elements["Remove Wall"].enabled = False self.task_ui_elements["Add Wall"].enabled = True self.task_ui_elements["Start Logging"].enabled = True self.task_ui_elements["Save Data"].enabled = False return def post_load_button_event(self): self.task_ui_elements["Move To Target"].enabled = True self.task_ui_elements["Add Wall"].enabled = True self.task_ui_elements["Start Logging"].enabled = True self.task_ui_elements["Save Data"].enabled = False return def post_clear_button_event(self): self.task_ui_elements["Move To Target"].enabled = False self.task_ui_elements["Remove Wall"].enabled = False self.task_ui_elements["Add Wall"].enabled = False self.task_ui_elements["Start Logging"].enabled = False self.task_ui_elements["Save Data"].enabled = False return def shutdown_cleanup(self): 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": "Move To Target", "type": "button", "text": "Move To Target", "tooltip": "Plan a Path and Move to Target", "on_clicked_fn": self._on_follow_target_button_event, } self.task_ui_elements["Move To Target"] = btn_builder(**dict) self.task_ui_elements["Move To Target"].enabled = False dict = { "label": "Add Wall", "type": "button", "text": "ADD", "tooltip": "Add a Wall", "on_clicked_fn": self._on_add_wall_button_event, } self.task_ui_elements["Add Wall"] = btn_builder(**dict) self.task_ui_elements["Add Wall"].enabled = False dict = { "label": "Remove Wall", "type": "button", "text": "REMOVE", "tooltip": "Remove Wall", "on_clicked_fn": self._on_remove_wall_button_event, } self.task_ui_elements["Remove Wall"] = btn_builder(**dict) self.task_ui_elements["Remove Wall"].enabled = False def build_data_logging_ui(self, frame): with frame: with ui.VStack(spacing=5): frame.title = "Data Logging" frame.visible = True dict = { "label": "Output Directory", "type": "stringfield", "default_val": os.path.join(os.getcwd(), "output_data.json"), "tooltip": "Output Directory", "on_clicked_fn": None, "use_folder_picker": False, "read_only": False, } self.task_ui_elements["Output Directory"] = str_builder(**dict) dict = { "label": "Start Logging", "type": "button", "a_text": "START", "b_text": "PAUSE", "tooltip": "Start Logging", "on_clicked_fn": self._on_logging_button_event, } self.task_ui_elements["Start Logging"] = state_btn_builder(**dict) self.task_ui_elements["Start Logging"].enabled = False dict = { "label": "Save Data", "type": "button", "text": "Save Data", "tooltip": "Save Data", "on_clicked_fn": self._on_save_data_button_event, } self.task_ui_elements["Save Data"] = btn_builder(**dict) self.task_ui_elements["Save Data"].enabled = False return
6,745
Python
39.154762
197
0.553595
swadaskar/Isaac_Sim_Folder/extension_examples/path_planning/path_planning_controller.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. from omni.isaac.core.controllers import BaseController from omni.isaac.motion_generation import PathPlannerVisualizer, PathPlanner from omni.isaac.motion_generation.lula import RRT from omni.isaac.core.utils.types import ArticulationAction from omni.isaac.core.articulations import Articulation from omni.isaac.motion_generation import interface_config_loader import omni.isaac.core.objects import carb from typing import Optional import numpy as np class PathPlannerController(BaseController): def __init__( self, name: str, path_planner_visualizer: PathPlannerVisualizer, cspace_interpolation_max_dist: float = 0.5, frames_per_waypoint: int = 30, ): BaseController.__init__(self, name) self._path_planner_visualizer = path_planner_visualizer self._path_planner = path_planner_visualizer.get_path_planner() self._cspace_interpolation_max_dist = cspace_interpolation_max_dist self._frames_per_waypoint = frames_per_waypoint self._plan = None self._frame_counter = 1 def _make_new_plan( self, target_end_effector_position: np.ndarray, target_end_effector_orientation: Optional[np.ndarray] = None ) -> None: self._path_planner.set_end_effector_target(target_end_effector_position, target_end_effector_orientation) self._path_planner.update_world() self._plan = self._path_planner_visualizer.compute_plan_as_articulation_actions( max_cspace_dist=self._cspace_interpolation_max_dist ) if self._plan is None or self._plan == []: carb.log_warn("No plan could be generated to target pose: " + str(target_end_effector_position)) def forward( self, target_end_effector_position: np.ndarray, target_end_effector_orientation: Optional[np.ndarray] = None ) -> ArticulationAction: if self._plan is None: # This will only happen the first time the forward function is used self._make_new_plan(target_end_effector_position, target_end_effector_orientation) if len(self._plan) == 0: # The plan is completed; return null action to remain in place self._frame_counter = 1 return ArticulationAction() if self._frame_counter % self._frames_per_waypoint != 0: # Stop at each waypoint in the plan for self._frames_per_waypoint frames self._frame_counter += 1 return self._plan[0] else: self._frame_counter += 1 return self._plan.pop(0) def add_obstacle(self, obstacle: omni.isaac.core.objects, static: bool = False) -> None: self._path_planner.add_obstacle(obstacle, static) def remove_obstacle(self, obstacle: omni.isaac.core.objects) -> None: self._path_planner.remove_obstacle(obstacle) def reset(self) -> None: # PathPlannerController will make one plan per reset self._path_planner.reset() self._plan = None self._frame_counter = 1 def get_path_planner_visualizer(self) -> PathPlannerVisualizer: return self._path_planner_visualizer def get_path_planner(self) -> PathPlanner: return self._path_planner class FrankaRrtController(PathPlannerController): def __init__( self, name, robot_articulation: Articulation, cspace_interpolation_max_dist: float = 0.5, frames_per_waypoint: int = 30, ): rrt_config = interface_config_loader.load_supported_path_planner_config("Franka", "RRT") rrt = RRT(**rrt_config) visualizer = PathPlannerVisualizer(robot_articulation, rrt) PathPlannerController.__init__(self, name, visualizer, cspace_interpolation_max_dist, frames_per_waypoint)
4,221
Python
38.830188
116
0.685383
swadaskar/Isaac_Sim_Folder/extension_examples/unitree_quadruped/quadruped_example.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 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 RobotsPlaying(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]*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 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/RG2_v2/RG2_v2.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([-6.10078, -5.19303, 0.24168]), orientation=np.array([0,0,0,1]), 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([-3.78767, -5.00871, 0.24168]), orientation=np.array([0, 0, 0, 1]), 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])) 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.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.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.engine_bringer.get_world_pose() current_joint_positions_ur10 = self.ur10.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.name: { "joint_positions": current_joint_positions_ur10, }, self.screw_ur10.name: { "joint_positions": current_joint_positions_ur10, }, "bool_counter": self._bool_event } 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} 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.engine_bringer.get_world_pose() ee_pose = self.give_location("/World/UR10/ee_link") screw_ee_pose = self.give_location("/World/Screw_driving_UR10/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]<-5.3: 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.00127, -4.80822, 0.53949])))<0.02: self._task_event = 71 self._bool_event+=1 elif self._task_event == 71: if np.mean(np.abs(screw_ee_pose.p - np.array([-3.70349, -4.41856, 0.56125])))<0.058: self._task_event=2 elif self._task_event == 2: 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 == 3: pass return def post_reset(self): self._task_event = 0 return class QuadrupedExample(BaseSample): def __init__(self) -> None: super().__init__() self.done = False return def setup_scene(self): world = self.get_world() # 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(RobotsPlaying(name="awesome_task")) self.isDone = [False]*120 self.bool_done = [False]*120 self.motion_task_counter=0 self.delay=0 print("inside setup_scene", self.motion_task_counter) return async def setup_post_load(self): self._world = self.get_world() task_params = self._world.get_task("awesome_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"]) # static suspensions on the table self.add_part_custom("World/Environment","FSuspensionBack", "FSuspensionBack", 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", 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._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() 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 move_ur10(self, locations): target_location = locations[self.motion_task_counter] print("Doing "+str(target_location["index"])+"th motion plan") actions, success = self.my_controller.compute_inverse_kinematics( target_position=target_location["position"], target_orientation=target_location["orientation"], ) # actions.joint_velocities = [0.0001,0.0001,0.0001,0.0001,0.0001,0.0001] # actions.joint_velocities = [1,1,1,1,1,1] print(actions) if success: print("still homing on this location") self.articulation_controller.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("/World/UR10/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.015: self.motion_task_counter+=1 # time.sleep(0.3) print("Completed one motion plan: ", self.motion_task_counter) def do_screw_driving(self, locations): target_location = locations[self.motion_task_counter] print("Doing "+str(target_location["index"])+"th motion plan") actions, success = self.screw_my_controller.compute_inverse_kinematics( target_position=target_location["position"], target_orientation=target_location["orientation"], ) if success: print("still homing on this location") self.screw_articulation_controller.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("/World/Screw_driving_UR10/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(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") # actions, success = self.screw_my_controller.compute_inverse_kinematics( # target_position=target_location["position"], # target_orientation=target_location["orientation"], # ) # if success: # print("still homing on this location") # controller_name = getattr(self,"screw_articulation_controller"+task_name) # 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 transform_for_screw_ur10(self, position): position[0]-=0 position[1]+=0 position[2]+=-0 return position def send_robot_actions(self, step_size): current_observations = self._world.get_observations() task_params = self._world.get_task("awesome_task").get_params() ## Task event numbering: # 1 - 30 normal events: forward, stop and add piece, turn # 51 - 61 smaller moving platforms events: forward, stop, disappear piece # 71 - pick place tasks # Terminology # mp - moving platform # iteration 1 # go forward if current_observations["task_event"] == 1: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5,0])) if not self.isDone[current_observations["task_event"]]: self.isDone[current_observations["task_event"]]=True # small mp brings in part elif current_observations["task_event"] == 51: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0,0])) if not self.isDone[current_observations["task_event"]]: motion_plan = [{"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":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])}] # {"index":0, "position": np.array([1.11096, -0.01839, 0.31929-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-7.2154, -5.17695, 0.56252]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}, # {"index":1, "position": np.array([1.11096, -0.01839, 0.19845-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-7.2154, -5.17695, 0.44167]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}, # {"index":2, "position": np.array([1.11096, -0.01839, 0.31929]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-7.2154, -5.17695, 0.56252]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}, self.move_ur10(motion_plan) if self.motion_task_counter==2 and not self.bool_done[current_observations["bool_counter"]]: self.bool_done[current_observations["bool_counter"]] = True self.remove_part("World/Environment", "FSuspensionBack_01") self.add_part_custom("World/UR10/ee_link","FSuspensionBack", "qFSuspensionBack", np.array([0.001,0.001,0.001]), np.array([0.16839, 0.158, -0.44332]), np.array([0,0,0,1])) if self.motion_task_counter==6: print("Done motion plan") self.isDone[current_observations["task_event"]]=True # arm_robot picks and places part elif current_observations["task_event"] == 71: if not self.isDone[current_observations["task_event"]]: if not self.bool_done[current_observations["bool_counter"]]: self.bool_done[current_observations["bool_counter"]] = True print("Part removal done") self.remove_part("World/UR10/ee_link", "qFSuspensionBack") self.motion_task_counter=0 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])) motion_plan = [{"index":0, "position": self.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.70349, -4.41856, 0.56125]), "goal_orientation":np.array([0.70711,0,0.70711,0])}] print(self.motion_task_counter) self.do_screw_driving(motion_plan) if self.motion_task_counter==13: self.isDone[current_observations["task_event"]]=True self.done = True self.motion_task_counter=0 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.07, -0.81, 0.21]), "orientation": np.array([-0.69, 0, 0, 0.72]), "goal_position":np.array([-4.18372, 7.03628, 0.44567]), "goal_orientation":np.array([0.9999, 0, 0, 0])}] self.move_ur10(motion_plan) # self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5,0])) print("done", self.motion_task_counter) # remove engine and add engine elif current_observations["task_event"] == 2: if not self.isDone[current_observations["task_event"]]: self.isDone[current_observations["task_event"]]=True self.done = True self.motion_task_counter=0 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.07, -0.81, 0.21]), "orientation": np.array([-0.69, 0, 0, 0.72]), "goal_position":np.array([-4.18372, 7.03628, 0.44567]), "goal_orientation":np.array([0.9999, 0, 0, 0])}] self.move_ur10(motion_plan) print("task 2 delay") elif current_observations["task_event"] == 3: print("task 3") self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5,0])) return 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/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): 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"/{parent_prim_name}/{prim_name}") # gives asset ref path part= 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}" # world = self.get_world() prims.delete_prim(prim_path) def move(self, task): mp = self._world.get_observations()[self._world.get_task("awesome_task").get_params()["mp_name"]["value"]] print(mp) position, orientation, goal_position = mp['position'], mp['orientation'], mp['goal_position'][task-1] # 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) # 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)
35,604
Python
63.268953
441
0.605578
swadaskar/Isaac_Sim_Folder/extension_examples/franka_nut_and_bolt/franka_nut_and_bolt_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.franka_nut_and_bolt import FrankaNutAndBolt class FrankaNutAndBoltExtension(BaseSampleExtension): def on_startup(self, ext_id: str): super().on_startup(ext_id) super().start_extension( menu_name="Manipulation", submenu_name="", name="Franka Nut and Bolt", title="Franka Nut and Bolt", doc_link="", overview="Franka robot arms picking and screwing nuts onto bolts", file_path=os.path.abspath(__file__), sample=FrankaNutAndBolt(), ) return
1,103
Python
38.42857
78
0.698096
swadaskar/Isaac_Sim_Folder/extension_examples/omnigraph_keyboard/omnigraph_keyboard_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.omnigraph_keyboard import OmnigraphKeyboard class OmnigraphKeyboardExtension(BaseSampleExtension): def on_startup(self, ext_id: str): super().on_startup(ext_id) overview = "This Example shows how to change the size of a cube using the keyboard through omnigraph progrmaming in Isaac Sim." overview += "\n\tKeybord Input:" overview += "\n\t\ta: Grow" overview += "\n\t\td: Shrink" overview += "\n\nPress the 'Open in IDE' button to view the source code." overview += "\nOpen Visual Scripting Window to see Omnigraph" super().start_extension( menu_name="Input Devices", submenu_name="", name="Omnigraph Keyboard", title="NVIDIA Omnigraph Scripting 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=OmnigraphKeyboard(), )
1,557
Python
44.823528
135
0.696853
swadaskar/Isaac_Sim_Folder/extension_examples/omnigraph_keyboard/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. import omni.ext import numpy as np import omni.graph.core as og from omni.isaac.core.utils.viewports import set_camera_view from omni.isaac.examples.base_sample import BaseSample from omni.isaac.core.objects import VisualCuboid class OmnigraphKeyboard(BaseSample): def __init__(self) -> None: super().__init__() self._gamepad_gains = (40.0, 40.0, 2.0) self._gamepad_deadzone = 0.15 def setup_scene(self): world = self.get_world() world.scene.add( VisualCuboid( prim_path="/Cube", # The prim path of the cube in the USD stage name="cube", # The unique name used to retrieve the object from the scene later on position=np.array([0, 0, 10.0]), # Using the current stage units which is cms by default. size=10.0, # most arguments accept mainly numpy arrays. color=np.array([0, 1.0, 1.0]), # RGB channels, going from 0-1 ) ) world.scene.add_default_ground_plane() set_camera_view(eye=np.array([75, 75, 45]), target=np.array([0, 0, 0])) # setup graph keys = og.Controller.Keys og.Controller.edit( {"graph_path": "/controller_graph", "evaluator_name": "execution"}, { keys.CREATE_NODES: [ ("OnTick", "omni.graph.action.OnTick"), ("A", "omni.graph.nodes.ReadKeyboardState"), ("D", "omni.graph.nodes.ReadKeyboardState"), ("ToDouble1", "omni.graph.nodes.ToDouble"), ("ToDouble2", "omni.graph.nodes.ToDouble"), ("Negate", "omni.graph.nodes.Multiply"), ("DeltaAdd", "omni.graph.nodes.Add"), ("SizeAdd", "omni.graph.nodes.Add"), ("NegOne", "omni.graph.nodes.ConstantInt"), ("CubeWrite", "omni.graph.nodes.WritePrimAttribute"), # write prim property translate ("CubeRead", "omni.graph.nodes.ReadPrimAttribute"), ], keys.SET_VALUES: [ ("A.inputs:key", "A"), ("D.inputs:key", "D"), ("OnTick.inputs:onlyPlayback", True), # only tick when simulator is playing ("NegOne.inputs:value", -1), ("CubeWrite.inputs:name", "size"), ("CubeWrite.inputs:primPath", "/Cube"), ("CubeWrite.inputs:usePath", True), ("CubeRead.inputs:name", "size"), ("CubeRead.inputs:primPath", "/Cube"), ("CubeRead.inputs:usePath", True), ], keys.CONNECT: [ ("OnTick.outputs:tick", "CubeWrite.inputs:execIn"), ("A.outputs:isPressed", "ToDouble1.inputs:value"), ("D.outputs:isPressed", "ToDouble2.inputs:value"), ("ToDouble2.outputs:converted", "Negate.inputs:a"), ("NegOne.inputs:value", "Negate.inputs:b"), ("ToDouble1.outputs:converted", "DeltaAdd.inputs:a"), ("Negate.outputs:product", "DeltaAdd.inputs:b"), ("DeltaAdd.outputs:sum", "SizeAdd.inputs:a"), ("CubeRead.outputs:value", "SizeAdd.inputs:b"), ("SizeAdd.outputs:sum", "CubeWrite.inputs:value"), ], }, ) def world_cleanup(self): pass
3,957
Python
45.564705
106
0.544099
swadaskar/Isaac_Sim_Folder/extension_examples/isaac_demo/isaac_demo.py
from omni.isaac.examples.base_sample import BaseSample import numpy as np from omni.isaac.core.objects import DynamicCuboid class IsaacDemo(BaseSample): def __init__(self) -> None: super().__init__() return def setup_scene(self): world = self.get_world() world.scene.add_default_ground_plane() fancy_cube = world.scene.add( DynamicCuboid( prim_path="/World/random_cube", name="fancy_cube", position=np.array([0, 0, 1.0]), scale=np.array([0.5015, 0.5015, 0.5015]), color=np.array([0, 0, 1.0]), )) return async def setup_post_load(self): self._world = self.get_world() self._cube = self._world.scene.get_object("fancy_cube") self._world.add_physics_callback("sim_step", callback_fn=self.print_cube_info) #callback names have to be unique return # here we define the physics callback to be called before each physics step, all physics callbacks must take # step_size as an argument def print_cube_info(self, step_size): position, orientation = self._cube.get_world_pose() linear_velocity = self._cube.get_linear_velocity() # will be shown on terminal print("Cube position is : " + str(position)) print("Cube's orientation is : " + str(orientation)) print("Cube's linear velocity is : " + str(linear_velocity)) # # 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. # from omni.isaac.examples.base_sample import BaseSample # # Note: checkout the required tutorials at https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/overview.html # class HelloWorld(BaseSample): # def __init__(self) -> None: # super().__init__() # return # def setup_scene(self): # world = self.get_world() # world.scene.add_default_ground_plane() # return # async def setup_post_load(self): # return # async def setup_pre_reset(self): # return # async def setup_post_reset(self): # return # def world_cleanup(self): # return
2,649
Python
15.060606
120
0.613439
swadaskar/Isaac_Sim_Folder/extension_examples/bin_filling/bin_filling.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.core.utils.rotations import euler_angles_to_quat from omni.isaac.examples.base_sample import BaseSample from omni.isaac.universal_robots.tasks import BinFilling as BinFillingTask from omni.isaac.universal_robots.controllers import PickPlaceController import numpy as np class BinFilling(BaseSample): def __init__(self) -> None: super().__init__() self._controller = None self._articulation_controller = None self._added_screws = False def setup_scene(self): world = self.get_world() world.add_task(BinFillingTask(name="bin_filling")) return async def setup_post_load(self): self._ur10_task = self._world.get_task(name="bin_filling") self._task_params = self._ur10_task.get_params() my_ur10 = self._world.scene.get_object(self._task_params["robot_name"]["value"]) self._controller = PickPlaceController( name="pick_place_controller", gripper=my_ur10.gripper, robot_articulation=my_ur10 ) self._articulation_controller = my_ur10.get_articulation_controller() return def _on_fill_bin_physics_step(self, step_size): observations = self._world.get_observations() actions = self._controller.forward( picking_position=observations[self._task_params["bin_name"]["value"]]["position"], placing_position=observations[self._task_params["bin_name"]["value"]]["target_position"], current_joint_positions=observations[self._task_params["robot_name"]["value"]]["joint_positions"], end_effector_offset=np.array([0, -0.098, 0.03]), end_effector_orientation=euler_angles_to_quat(np.array([np.pi, 0, np.pi / 2.0])), ) if not self._added_screws and self._controller.get_current_event() == 6 and not self._controller.is_paused(): self._controller.pause() self._ur10_task.add_screws(screws_number=20) self._added_screws = True if self._controller.is_done(): self._world.pause() self._articulation_controller.apply_action(actions) return async def on_fill_bin_event_async(self): world = self.get_world() world.add_physics_callback("sim_step", self._on_fill_bin_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() self._added_screws = False return def world_cleanup(self): self._controller = None self._added_screws = False return
3,149
Python
40.999999
117
0.662115
swadaskar/Isaac_Sim_Folder/extension_examples/user_examples/simple_case.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 argparse from omni.isaac.kit import SimulationApp import numpy as np import omni # This sample loads a usd stage and starts simulation CONFIG = {"width": 1280, "height": 720, "sync_loads": True, "headless": False, "renderer": "RayTracedLighting"} # Set up command line arguments parser = argparse.ArgumentParser("Usd Load sample") parser.add_argument("--headless", default=False, action="store_true", help="Run stage headless") args, unknown = parser.parse_known_args() # Start the omniverse application CONFIG["headless"] = args.headless simulation_app = SimulationApp(launch_config=CONFIG) from omni.isaac.core import World from omni.isaac.core.robots import Robot from omni.isaac.core.utils.types import ArticulationAction # open stage omni.usd.get_context().open_stage("simple_case.usd") # wait two frames so that stage starts loading simulation_app.update() simulation_app.update() print("Loading stage...") from omni.isaac.core.utils.stage import is_stage_loading while is_stage_loading(): simulation_app.update() print("Loading Complete") world = World(stage_units_in_meters=1.0) robot = world.scene.add(Robot(prim_path="/World/panda", name="robot")) world.reset() while simulation_app.is_running(): world.step(render=not args.headless) # deal with pause/stop if world.is_playing(): if world.current_time_step_index == 0: world.reset() # apply actions robot.get_articulation_controller().apply_action( ArticulationAction(joint_positions=np.random.random(9)) ) simulation_app.close()
2,016
Python
30.515625
111
0.745536
swadaskar/Isaac_Sim_Folder/extension_examples/user_examples/disassembly_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.user_examples.disassembly import Disassembly class DisassemblyExtension(BaseSampleExtension): def on_startup(self, ext_id: str): super().on_startup(ext_id) super().start_extension( menu_name="", submenu_name="", name="Awesome example", title="Awesome 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=Disassembly(), ) return
1,221
Python
42.642856
135
0.710074
swadaskar/Isaac_Sim_Folder/extension_examples/user_examples/disassembly.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, Gf 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 from omni.physx.scripts import utils import time 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 RobotsPlaying(BaseTask): def __init__(self, name): super().__init__(name=name, offset=None) self.mp_goal_position = [np.array([-28.07654, 18.06421, 0]), np.array([-25.04914, 18.06421, 0])] self._task_event = 0 self.task_done = [False]*120 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_show_without_robots_l.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" # add floor add_reference_to_stage(usd_path=asset_path, prim_path="/World/Environment") 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 = "/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/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([-17.73638,-17.06779, 0.81965]), 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_02 for pick and place add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_02") 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_02/ee_link") gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_02/ee_link", translate=0.1611, direction="x") self.ur10_02 = scene.add( SingleManipulator(prim_path="/World/UR10_02", name="my_ur10_02", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-14.28725, -16.26194, 0.24133]), orientation=np.array([1,0,0,0]), scale=np.array([1,1,1])) ) self.ur10_02.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_01 for pick and place add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/UR10_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_01/ee_link") gripper = SurfaceGripper(end_effector_prim_path="/World/UR10_01/ee_link", translate=0.1611, direction="x") self.ur10_01 = scene.add( SingleManipulator(prim_path="/World/UR10_01", name="my_ur10_01", end_effector_prim_name="ee_link", gripper=gripper, translation = np.array([-14.28725, -18.32192, 0.24133]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1])) ) self.ur10_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 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([-15.71653, -16.26185, 0.24133]), orientation=np.array([1,0,0,0]), 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])) # adding UR10_01 for screwing in part add_reference_to_stage(usd_path=robot_arm_path, prim_path="/World/Screw_driving_UR10_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_01/ee_link") screw_gripper = SurfaceGripper(end_effector_prim_path="/World/Screw_driving_UR10_01/ee_link", translate=0, direction="x") self.screw_ur10_01 = scene.add( SingleManipulator(prim_path="/World/Screw_driving_UR10_01", name="my_screw_ur10_01", end_effector_prim_name="ee_link", gripper=screw_gripper, translation = np.array([-15.7071, -18.31962, 0.24133]), orientation=np.array([0,0,0,1]), scale=np.array([1,1,1])) ) self.screw_ur10_01.set_joints_default_state(positions=np.array([-np.pi / 2, -np.pi / 2, -np.pi / 2, -np.pi / 2, np.pi / 2, 0])) # add moving platform self.moving_platform = scene.add( WheeledRobot( prim_path="/mobile_platform", 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([-16.80027, -17.26595, 0]), orientation=np.array([0.70711, 0, 0, -0.70711]) ) ) return def get_observations(self): current_mp_position, current_mp_orientation = self.moving_platform.get_world_pose() current_joint_positions_ur10 = self.ur10.get_joint_positions() observations= { "task_event": self._task_event, "delay": self.delay, self.moving_platform.name: { "position": current_mp_position, "orientation": current_mp_orientation, "goal_position": self.mp_goal_position }, self.ur10.name: { "joint_positions": current_joint_positions_ur10, } } return observations def get_params(self): params_representation = {} params_representation["arm_name"] = {"value": self.ur10.name, "modifiable": False} params_representation["mp_name"] = {"value": self.moving_platform.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/ee_link") # iteration 1 if self._task_event == 0: print(self._task_event) self._task_event =21 if self.task_done[self._task_event]: self._task_event =21 self.task_done[self._task_event] = True elif self._task_event == 21: if np.mean(np.abs(ee_pose.p-np.array([-18.01444, -15.97435, 1.40075])))<0.01: self._task_event = 60 elif self._task_event == 60: if self.task_done[self._task_event]: if self.delay == 320: self._task_event = 11 self.delay=0 else: self.delay+=1 self.task_done[self._task_event] = True elif self._task_event == 11: if self.task_done[self._task_event] and current_mp_position[1]<-24.98: self._task_event =12 self.task_done[self._task_event] = True elif self._task_event == 12: print(np.mean(np.abs(current_mp_orientation-np.array([0,0,0,-1])))) if self.task_done[self._task_event] and np.mean(np.abs(current_mp_orientation-np.array([0,0,0,-1]))) < 0.503: self._task_event = 13 self.task_done[self._task_event] = True elif self._task_event == 13: if self.task_done[self._task_event] and current_mp_position[0]<-36.3: self._task_event =14 self.task_done[self._task_event] = True elif self._task_event == 14: print(np.mean(np.abs(current_mp_orientation-np.array([0.70711,0,0,0.70711])))) if self.task_done[self._task_event] and np.mean(np.abs(current_mp_orientation-np.array([0.70711,0,0,0.70711]))) < 0.0042: 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]>17.3: self._task_event +=1 self.task_done[self._task_event] = True elif self._task_event == 2: print(np.mean(np.abs(current_mp_orientation-np.array([1,0,0,0])))) if self.task_done[self._task_event] and np.mean(np.abs(current_mp_orientation-np.array([1,0,0,0]))) < 0.008: self._task_event += 1 self.task_done[self._task_event] = True elif self._task_event == 3: if self.task_done[self._task_event] and current_mp_position[0]>-20.25: self._task_event +=1 self.task_done[self._task_event] = True # disassembling parts elif self._task_event == 4: 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 == 5: 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 == 6: 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 == 7: 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 == 8: 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 == 9: 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 == 10: 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 == 11: pass # iteration 9 elif self._task_event == 22: _, current_mp_orientation = self.moving_platform.get_world_pose() if self.task_done[self._task_event] and np.mean(np.abs(current_mp_orientation-np.array([0, 0, 0.70711, 0.70711]))) < 0.035: self._task_event += 1 self.task_done[self._task_event] = True elif self._task_event == 23: current_mp_position, _ = self.moving_platform.get_world_pose() if self.task_done[self._task_event] and current_mp_position[0]<-36: self._task_event += 1 self.task_done[self._task_event] = True elif self._task_event == 24: if self.count >100: if self.task_done[self._task_event]: self._task_event += 1 self.count=0 else: self.count+=1 self.task_done[self._task_event] = True elif self._task_event == 25: if self.count >100: if self.task_done[self._task_event]: self._task_event += 1 self.count=0 else: self.count+=1 self.task_done[self._task_event] = True return def post_reset(self): self._task_event = 0 return class Disassembly(BaseSample): def __init__(self) -> None: super().__init__() self.done = False return def setup_scene(self): world = self.get_world() # 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(RobotsPlaying(name="awesome_task")) self.isDone = [False]*120 self.bool_done = [False]*120 self.motion_task_counter=0 return async def setup_post_load(self): self._world = self.get_world() task_params = self._world.get_task("awesome_task").get_params() # bring in moving platforms self.moving_platform = self._world.scene.get_object(task_params["mp_name"]["value"]) # add main cover on table self.add_part_custom("World","main_cover", "ymain_cover", np.array([0.001,0.001,0.001]), np.array([-18.7095, -15.70872, 0.28822]), np.array([0.70711, 0.70711,0,0])) # add parts self.add_part_custom("mobile_platform/platform/unfinished_stuff","FFrame", "FFrame", np.array([1,1,1]), np.array([-5.82832, 0, 0]), np.array([0.5,0.5,0.5,0.5])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","engine_no_rigid", "engine", np.array([1,1,1]), np.array([311.20868, 598.91546, 181.74458]), np.array([0.7,-0.1298,-0.10842,-0.69374])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","FSuspensionFront", "FSuspensionFront", np.array([1,1,1]), np.array([721.62154, 101.55373, 215.10539]), np.array([0.5564, -0.43637, -0.43637, 0.5564])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","FSuspensionFront", "FSuspensionFront_01", np.array([1,1,1]), np.array([797.10001, 103.5, 422.80001]), np.array([0.44177, -0.55212, -0.55212, 0.44177])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","FSuspensionBack", "FSuspensionBack", np.array([1,1,1]), np.array([443.3, 1348.4, 462.9]), np.array([0.09714, -0.03325, -0.76428, 0.63666])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","battery", "battery", np.array([1,1,1]), np.array([377.63, 788.49883, 270.90454]), np.array([0, 0, -0.70711, -0.70711])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","fuel", "fuel", np.array([1,1,1]), np.array([230.13538, 289.31525, 377.64262]), np.array([0.5,0.5,0.5,0.5])) # self.add_part_custom("mobile_platform/platform/unfinished_stuff","main_cover", "main_cover", np.array([1,1,1]), np.array([596.47952, 1231.52815, -151.59531]), np.array([0.51452, 0.48504, -0.51452, -0.48504])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","lower_cover", "lower_cover", np.array([1,1,1]), np.array([435.65021, 418.57531,21.83379]), np.array([0.50942, 0.50942,0.4904, 0.4904])) self.add_part_custom("mobile_platform/platform/unfinished_stuff","lower_cover", "lower_cover_01", np.array([1,1,1]), np.array([36.473, 415.8277, 25.66846]), np.array([0.5,0.5, 0.5, 0.5])) # self.add_part_custom("mobile_platform/platform/unfinished_stuff","Seat", "Seat", np.array([1,1,1]), np.array([179.725, 448.55839, 383.33431]), np.array([0.5,0.5, 0.5, 0.5])) self.add_part_custom(f"mobile_platform/platform/unfinished_stuff","FWheel", f"wheel_03", np.array([1,1,1]), np.array([0.15255, -0.1948, 0.56377]), np.array([0.5, -0.5, 0.5, -0.5])) self.add_part_custom(f"mobile_platform/platform/unfinished_stuff","FWheel", f"wheel_01", np.array([1,1,1]), np.array([0.1522, 0.33709, 0.56377]), np.array([0.5, -0.5, 0.5, -0.5])) self.add_part_custom(f"mobile_platform/platform/unfinished_stuff","FWheel", f"wheel_04", np.array([1,1,1]), np.array([-0.80845, -0.22143, 0.43737]), np.array([0.5, -0.5, 0.5, -0.5])) self.add_part_custom(f"mobile_platform/platform/unfinished_stuff","FWheel", f"wheel_02", np.array([1,1,1]), np.array([-0.80934, 0.35041, 0.43888]), np.array([0.5, -0.5, 0.5, -0.5])) # self.moving_platform = self._world.scene.get_object("moving_platform") 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.my_controller = KinematicsSolver(self.ur10, attach_gripper=True) self.articulation_controller = self.ur10.get_articulation_controller() # add ee cover on robot # self.add_part_custom("World/UR10/ee_link","main_cover", "main_cover", 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])) # human body movements declaration # self.set_new_transform("/World/male_human_01/Character_Source/Root/Root/Pelvis/Spine1", [0, 7.16492, -0.03027], [-0.68407, 0.6840694, 0.1790224, -0.1790201]) # self.set_new_transform("/World/male_human/Character_Source/Root/Root/Pelvis/Spine1/Spine2/Spine3/Chest/L_Clavicle/L_UpArm", [18.5044, 0.00001, 0], [0.5378302, -0.2149462, 0.791071, 0.1968338]) # self.set_new_transform("/World/male_human/Character_Source/Root/Root/Pelvis/Spine1/Spine2/Spine3/Chest/R_Clavicle/R_UpArm", [-18.50437, -0.00021, -0.00001], [0.5108233, -0.1681133, 0.8128292, 0.223844]) # for i in range(4): # if i==0: # self.set_new_transform("/World/male_human/Character_Source/Root/Root/Pelvis/Spine1", [0, 7.16492, -0.03027], [-0.68407, 0.6840694, 0.1790224, -0.1790201]) # self.set_new_transform("/World/male_human/Character_Source/Root/Root/Pelvis/Spine1/Spine2/Spine3/Chest/L_Clavicle/L_UpArm", [18.5044, 0.00001, 0], [0.5378302, -0.2149462, 0.791071, 0.1968338]) # self.set_new_transform("/World/male_human/Character_Source/Root/Root/Pelvis/Spine1/Spine2/Spine3/Chest/R_Clavicle/R_UpArm", [-18.50437, -0.00021, -0.00001], [0.5108233, -0.1681133, 0.8128292, 0.223844]) # else: # self.set_new_transform("/World/male_human"+f"_0{i}"+"/Character_Source/Root/Root/Pelvis/Spine1", [0, 7.16492, -0.03027], [-0.68407, 0.6840694, 0.1790224, -0.1790201]) # self.set_new_transform("/World/male_human"+f"_0{i}"+"/Character_Source/Root/Root/Pelvis/Spine1/Spine2/Spine3/Chest/L_Clavicle/L_UpArm", [18.5044, 0.00001, 0], [0.5378302, -0.2149462, 0.791071, 0.1968338]) # self.set_new_transform("/World/male_human"+f"_0{i}"+"/Character_Source/Root/Root/Pelvis/Spine1/Spine2/Spine3/Chest/R_Clavicle/R_UpArm", [-18.50437, -0.00021, -0.00001], [0.5108233, -0.1681133, 0.8128292, 0.223844]) return async def setup_post_reset(self): self._my_controller.reset() await self._world.play_async() return def set_new_transform(self, prim_path, translation, orientation): dc = _dynamic_control.acquire_dynamic_control_interface() # Get the prim you want to move prim = dc.get_rigid_body(prim_path) # Set the new location new_location = Gf.Vec3f(translation[0], translation[1], translation[2]) # Replace with your desired location new_rotation = Gf.Rotation(orientation[0], orientation[1], orientation[2], orientation[3]) # Replace with your desired rotation # Create a new transform new_transform = UsdGeom.TransformAPI(prim) new_transform.SetTransform(UsdGeom.XformOp.Transform(Gf.Matrix4d(new_rotation.GetMatrix(), new_location))) # Apply the new transform dc.set_rigid_body_pose(prim, new_transform.GetLocalTransformation()) 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): target_location = locations[self.motion_task_counter] print("Doing "+str(target_location["index"])+"th motion plan") actions, success = self.my_controller.compute_inverse_kinematics( target_position=target_location["position"], target_orientation=target_location["orientation"], ) print(actions) if success: print("still homing on this location") self.articulation_controller.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("/World/UR10/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.05: self.motion_task_counter+=1 print("Completed one motion plan: ", self.motion_task_counter) def send_robot_actions(self, step_size): current_observations = self._world.get_observations() task_params = self._world.get_task("awesome_task").get_params() ## Task event numbering: # 1 - 30 normal events: forward, stop and add piece, turn # 51 - 61 smaller moving platforms events: forward, stop, disappear piece # 71 - pick place tasks if current_observations["task_event"] == 0: print("task 0") print(current_observations["task_event"]) if not self.isDone[current_observations["task_event"]]: self.isDone[current_observations["task_event"]]=True if current_observations["task_event"] == 21: # self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]]: motion_plan = [{"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, -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, -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, -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, -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, -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, -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, -16.77844, 1.33072]), "goal_orientation":np.array([0.54043, 0.456, 0.54043, -0.456])}, {"index":7, "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, -17.17995, 1.31062]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}, {"index":8, "position": np.array([0.11095, 0.94627, 0.2926-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175, -17.17995, 1.11226]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}, {"index":9, "position": np.array([0.11095, 0.94627, 0.19682-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175, -17.17995, 1.01648]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}, {"index":10, "position": np.array([0.11095, 0.94627, 0.15697-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175, -17.17995, 0.97663]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}, {"index":11, "position": np.array([0.11095, 0.94627, 0.11895-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175, -17.17995, 0.93861]), "goal_orientation":np.array([0.5,0.5,0.5,-0.5])}, {"index":12, "position": np.array([0.11095, 0.94627, 0.07882-0.16]), "orientation": np.array([0.70711, 0, 0.70711, 0]), "goal_position":np.array([-16.79175, -17.17995, 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, -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, -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, -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, -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, -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, -15.97435, 1.40075]), "goal_orientation":np.array([0.70711, 0, 0.70711, 0])}] self.move_ur10(motion_plan) # remove world main cover and add ee main cover if self.motion_task_counter==2 and not self.bool_done[20]: self.bool_done[20] = True self.remove_part_custom("World", "ymain_cover") self.add_part_custom("World/UR10/ee_link","main_cover", "main_cover", 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.motion_task_counter==13 and not self.bool_done[21]: self.bool_done[21] = True self.remove_part_custom("World/UR10/ee_link", "main_cover") self.add_part_custom("mobile_platform/platform/unfinished_stuff","main_cover", "xmain_cover", np.array([1,1,1]), np.array([596.47952, 1231.52815, -151.59531]), np.array([0.51452, 0.48504, -0.51452, -0.48504])) if self.motion_task_counter==19: print("Done motion plan") self.isDone[current_observations["task_event"]]=True # delay elif current_observations["task_event"] == 60: # self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5, 0])) print("task 60 delay:", current_observations["delay"]) # iteration 0 # go forward elif current_observations["task_event"] == 11: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5, 0])) print("task 11") # turns elif current_observations["task_event"] == 12: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) self.moving_platform.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/2])) print("task 12") # go forward elif current_observations["task_event"] == 13: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5, 0])) print("task 13") # turn elif current_observations["task_event"] == 14: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) self.moving_platform.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/2])) print("task 14") # iteration 1 # go forward elif current_observations["task_event"] == 1: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5, 0])) print("task 1") # turn elif current_observations["task_event"] == 2: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) self.moving_platform.apply_action(self._my_custom_controller.turn(command=[[0,0,0,0],np.pi/2])) print("task 2") # go forward elif current_observations["task_event"] == 3: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5, 0])) print("task 3") # stop, remove and add part elif current_observations["task_event"] == 10: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]] and current_observations["delay"]==100: self.remove_part("engine") # prims.delete_prim("/mobile_platform/platform/engine") self.add_part_custom("World/Environment/disassembled_parts","engine_no_rigid", "qengine", np.array([1,1,1]), np.array([-19511.01549, 16368.42662, 451.93828]), np.array([0.99362,0,-0.11281,0])) self.isDone[current_observations["task_event"]]=True # remove and add part elif current_observations["task_event"] == 9: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]] and current_observations["delay"]==100: self.remove_part("FSuspensionFront") self.remove_part("FSuspensionFront_01") self.remove_part("FSuspensionBack") # self.add_part_custom("World/Environment/disassembled_parts","FSuspensionFront", "suspension_front", np.array([1,1,1]), np.array([-21252.07916, 16123.85255, -95.12237]), np.array([0.68988,-0.15515,0.17299,0.68562])) # self.add_part_custom("World/Environment/disassembled_parts","FSuspensionFront", "suspension_front_1", np.array([1,1,1]), np.array([-21253.69102, 15977.78923, -98.17269]), np.array([0.68988,-0.15515,0.17299,0.68562])) self.add_part_custom("World/Environment/disassembled_parts","FSuspensionBack", "suspension_back", np.array([1,1,1]), np.array([-21250.02819, 16296.28288, -79.20706]), np.array([0.69191,-0.16341,0.16465,0.6837])) self.isDone[current_observations["task_event"]]=True # remove and add part elif current_observations["task_event"] == 7: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]] and current_observations["delay"]==100: self.remove_part("fuel") self.add_part_custom("World/Environment/disassembled_parts","FFuelTank", "FFuelTank", np.array([1,1,1]), np.array([-23473.90962, 16316.56526, 266.94776]), np.array([0.5,0.5,0.5,0.5])) self.isDone[current_observations["task_event"]]=True # remove and add part elif current_observations["task_event"] == 8: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]] and current_observations["delay"]==100: self.remove_part("battery") self.add_part_custom("World/Environment/disassembled_parts","battery", "qbattery", np.array([1,1,1]), np.array([-18656.70206, 19011.82244, 283.39021]), np.array([0.5,0.5,0.5,0.5])) self.isDone[current_observations["task_event"]]=True # remove and add part elif current_observations["task_event"] == 6: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]] and current_observations["delay"]==100: self.remove_part("wheel_01") self.remove_part("wheel_02") self.remove_part("wheel_03") self.remove_part("wheel_04") self.add_part_custom("World/Environment/disassembled_parts","FWheel", "qwheel_01", np.array([1,1,1]), np.array([-18656.70206, 19011.82244, 283.39021]), np.array([0.5,0.5,0.5,0.5])) self.add_part_custom("World/Environment/disassembled_parts","FWheel", "qwheel_02", np.array([1,1,1]), np.array([-18656.70206, 19011.82244, 283.39021]), np.array([0.5,0.5,0.5,0.5])) self.add_part_custom("World/Environment/disassembled_parts","FWheel", "qwheel_03", np.array([1,1,1]), np.array([-18656.70206, 19011.82244, 283.39021]), np.array([0.5,0.5,0.5,0.5])) self.add_part_custom("World/Environment/disassembled_parts","FWheel", "qwheel_04", np.array([1,1,1]), np.array([-18656.70206, 19011.82244, 283.39021]), np.array([0.5,0.5,0.5,0.5])) self.isDone[current_observations["task_event"]]=True # remove and add part elif current_observations["task_event"] == 5: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]] and current_observations["delay"]==100: self.remove_part("lower_cover") self.remove_part("lower_cover_01") self.add_part_custom("World/Environment/disassembled_parts","lower_cover", "qlower_cover", np.array([1,1,1]), np.array([-20141.19845, 18913.49002, 272.27849]), np.array([0.5,0.5,0.5,0.5])) self.add_part_custom("World/Environment/disassembled_parts","lower_cover", "qlower_cover_1", np.array([1,1,1]), np.array([-21228.07681, 18923.38351, 272.27849]), np.array([0.5,0.5,0.5,0.5])) self.isDone[current_observations["task_event"]]=True # remove and add part elif current_observations["task_event"] == 4: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0, 0])) if not self.isDone[current_observations["task_event"]] and current_observations["delay"]==100: self.remove_part("xmain_cover") self.add_part_custom("World/Environment/disassembled_parts","main_cover", "qmain_cover", np.array([1,1,1]), np.array([-23651.85127, 19384.76572, 102.60316]), np.array([0.70428,0.70428,0.06314,-0.06314])) self.isDone[current_observations["task_event"]]=True elif current_observations["task_event"] == 11: print("delay") elif current_observations["task_event"] == 12: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5, 0])) return 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/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_world(self, parent_prim_name, 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"/{parent_prim_name}/{prim_name}") # gives asset ref path part= 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_world_pose(position=position, orientation=orientation) return part def add_part_custom(self, parent_prim_name, 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"/{parent_prim_name}/{prim_name}") # gives asset ref path part= 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, prim_path): prims.delete_prim("/mobile_platform/platform/unfinished_stuff/"+prim_path) def remove_part_custom(self, parent_prim_name, child_prim_name): prim_path = f"/{parent_prim_name}/{child_prim_name}" # world = self.get_world() prims.delete_prim(prim_path) def move(self, task): mp = self._world.get_observations()[self._world.get_task("awesome_task").get_params()["mp_name"]["value"]] print(mp) position, orientation, goal_position = mp['position'], mp['orientation'], mp['goal_position'][task-1] # 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) # 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)
46,252
Python
63.062327
353
0.611887
swadaskar/Isaac_Sim_Folder/extension_examples/replay_follow_target/replay_follow_target_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.replay_follow_target import ReplayFollowTarget import asyncio import omni.ui as ui from omni.isaac.ui.ui_utils import btn_builder, str_builder class ReplayFollowTargetExtension(BaseSampleExtension): def on_startup(self, ext_id: str): super().on_startup(ext_id) super().start_extension( menu_name="Manipulation", submenu_name="", name="Replay Follow Target", title="Replay Follow Target Task", doc_link="https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_advanced_data_logging.html", overview="This Example shows how to use data logging to replay data collected\n\n from the follow target extension example.\n\n Press the 'Open in IDE' button to view the source code.", sample=ReplayFollowTarget(), file_path=os.path.abspath(__file__), number_of_extra_frames=2, window_width=700, ) self.task_ui_elements = {} frame = self.get_frame(index=0) self.build_data_logging_ui(frame) return def _on_replay_trajectory_button_event(self): asyncio.ensure_future( self.sample._on_replay_trajectory_event_async(self.task_ui_elements["Data File"].get_value_as_string()) ) self.task_ui_elements["Replay Trajectory"].enabled = False self.task_ui_elements["Replay Scene"].enabled = False return def _on_replay_scene_button_event(self): asyncio.ensure_future( self.sample._on_replay_scene_event_async(self.task_ui_elements["Data File"].get_value_as_string()) ) self.task_ui_elements["Replay Trajectory"].enabled = False self.task_ui_elements["Replay Scene"].enabled = False return def post_reset_button_event(self): self.task_ui_elements["Replay Trajectory"].enabled = True self.task_ui_elements["Replay Scene"].enabled = True return def post_load_button_event(self): self.task_ui_elements["Replay Trajectory"].enabled = True self.task_ui_elements["Replay Scene"].enabled = True return def post_clear_button_event(self): self.task_ui_elements["Replay Trajectory"].enabled = False self.task_ui_elements["Replay Scene"].enabled = False return def build_data_logging_ui(self, frame): with frame: with ui.VStack(spacing=5): frame.title = "Data Replay" frame.visible = True example_data_file = os.path.abspath( os.path.join(os.path.abspath(__file__), "../../../../../data/example_data_file.json") ) dict = { "label": "Data File", "type": "stringfield", "default_val": example_data_file, "tooltip": "Data File", "on_clicked_fn": None, "use_folder_picker": False, "read_only": False, } self.task_ui_elements["Data File"] = str_builder(**dict) dict = { "label": "Replay Trajectory", "type": "button", "text": "Replay Trajectory", "tooltip": "Replay Trajectory", "on_clicked_fn": self._on_replay_trajectory_button_event, } self.task_ui_elements["Replay Trajectory"] = btn_builder(**dict) self.task_ui_elements["Replay Trajectory"].enabled = False dict = { "label": "Replay Scene", "type": "button", "text": "Replay Scene", "tooltip": "Replay Scene", "on_clicked_fn": self._on_replay_scene_button_event, } self.task_ui_elements["Replay Scene"] = btn_builder(**dict) self.task_ui_elements["Replay Scene"].enabled = False return
4,564
Python
41.663551
197
0.586766
swadaskar/Isaac_Sim_Folder/extension_examples/replay_follow_target/replay_follow_target.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.core.utils.types import ArticulationAction from omni.isaac.examples.base_sample import BaseSample from omni.isaac.franka.tasks import FollowTarget as FollowTargetTask import numpy as np class ReplayFollowTarget(BaseSample): def __init__(self) -> None: super().__init__() self._articulation_controller = None def setup_scene(self): world = self.get_world() world.add_task(FollowTargetTask()) return async def setup_pre_reset(self): world = self.get_world() if world.physics_callback_exists("replay_trajectory"): world.remove_physics_callback("replay_trajectory") if world.physics_callback_exists("replay_scene"): world.remove_physics_callback("replay_scene") return async def setup_post_load(self): self._franka_task = list(self._world.get_current_tasks().values())[0] self._task_params = self._franka_task.get_params() my_franka = self._world.scene.get_object(self._task_params["robot_name"]["value"]) self._articulation_controller = my_franka.get_articulation_controller() self._data_logger = self._world.get_data_logger() return async def _on_replay_trajectory_event_async(self, data_file): self._data_logger.load(log_path=data_file) world = self.get_world() await world.play_async() world.add_physics_callback("replay_trajectory", self._on_replay_trajectory_step) return async def _on_replay_scene_event_async(self, data_file): self._data_logger.load(log_path=data_file) world = self.get_world() await world.play_async() world.add_physics_callback("replay_scene", self._on_replay_scene_step) return def _on_replay_trajectory_step(self, step_size): if self._world.current_time_step_index < self._data_logger.get_num_of_data_frames(): data_frame = self._data_logger.get_data_frame(data_frame_index=self._world.current_time_step_index) self._articulation_controller.apply_action( ArticulationAction(joint_positions=data_frame.data["applied_joint_positions"]) ) return def _on_replay_scene_step(self, step_size): if self._world.current_time_step_index < self._data_logger.get_num_of_data_frames(): target_name = self._task_params["target_name"]["value"] data_frame = self._data_logger.get_data_frame(data_frame_index=self._world.current_time_step_index) self._articulation_controller.apply_action( ArticulationAction(joint_positions=data_frame.data["applied_joint_positions"]) ) self._world.scene.get_object(target_name).set_world_pose( position=np.array(data_frame.data["target_position"]) ) return
3,297
Python
42.973333
111
0.67061
swadaskar/Isaac_Sim_Folder/extension_examples/robo_factory/robo_factory.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 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 RobotsPlaying(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]*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/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/RG2_v2/RG2_v2.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([-6.09744, -16.5124, 0.24168]), orientation=np.array([0,0,0,1]), 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.02094, -16.52902, 0.24168]), orientation=np.array([0, 0, 0, 1]), 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])) 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 = self.ur10.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.name: { "joint_positions": current_joint_positions_ur10, }, self.screw_ur10.name: { "joint_positions": current_joint_positions_ur10, }, "bool_counter": self._bool_event } 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} 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/ee_link") screw_ee_pose = self.give_location("/World/Screw_driving_UR10/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 class RoboFactory(BaseSample): def __init__(self) -> None: super().__init__() self.done = False return def setup_scene(self): world = self.get_world() # 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(RobotsPlaying(name="awesome_task")) self.isDone = [False]*120 self.bool_done = [False]*120 self.motion_task_counter=0 self.delay=0 print("inside setup_scene", self.motion_task_counter) return async def setup_post_load(self): self._world = self.get_world() task_params = self._world.get_task("awesome_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.add_part_custom("engine_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("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("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._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() 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 move_ur10(self, locations): target_location = locations[self.motion_task_counter] print("Doing "+str(target_location["index"])+"th motion plan") actions, success = self.my_controller.compute_inverse_kinematics( target_position=target_location["position"], target_orientation=target_location["orientation"], ) # actions.joint_velocities = [0.0001,0.0001,0.0001,0.0001,0.0001,0.0001] # actions.joint_velocities = [1,1,1,1,1,1] print(actions) if success: print("still homing on this location") self.articulation_controller.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("/World/UR10/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.015: self.motion_task_counter+=1 # time.sleep(0.3) print("Completed one motion plan: ", self.motion_task_counter) def do_screw_driving(self, locations): target_location = locations[self.motion_task_counter] print("Doing "+str(target_location["index"])+"th motion plan") actions, success = self.screw_my_controller.compute_inverse_kinematics( target_position=target_location["position"], target_orientation=target_location["orientation"], ) if success: print("still homing on this location") self.screw_articulation_controller.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("/World/Screw_driving_UR10/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.015: self.motion_task_counter+=1 print("Completed one motion plan: ", self.motion_task_counter) def transform_for_screw_ur10(self, position): position[0]+=0.16171 position[1]+=0.00752 position[2]+=-0.00419 return position def send_robot_actions(self, step_size): current_observations = self._world.get_observations() task_params = self._world.get_task("awesome_task").get_params() ## Task event numbering: # 1 - 30 normal events: forward, stop and add piece, turn # 51 - 61 smaller moving platforms events: forward, stop, disappear piece # 71 - pick place tasks # Terminology # mp - moving platform # iteration 1 # go forward if current_observations["task_event"] == 1: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5,0])) if not self.isDone[current_observations["task_event"]]: self.isDone[current_observations["task_event"]]=True # small mp brings in part elif current_observations["task_event"] == 51: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0,0])) if not self.isDone[current_observations["task_event"]]: motion_plan = [{"index":0, "position": np.array([0.90691+0.16, 0.01077, 0.19514]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-7.00386, -16.5233, 0.43633]), "goal_orientation":np.array([0,0, 0.70711, 0.70711])}, {"index":1, "position": np.array([0.97165+0.16, 0.01077, 0.19514]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-7.00686, -16.5233, 0.43633]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}, {"index":2, "position": np.array([0.97165+0.16, 0.01077, 0.31194]), "orientation": np.array([0.70711,0.70711,0,0]), "goal_position":np.array([-7.0686, -16.5233, 0.55313]), "goal_orientation":np.array([0, 0, 0.70711, 0.70711])}, {"index":3, "position": np.array([-1.09292-0.16, 0.24836, 0.52594]), "orientation": np.array([0,0,0.70711,0.70711]), "goal_position":np.array([-5.005, -16.7606, 0.76714]), "goal_orientation":np.array([0.70711, 0.70711, 0,0])}] self.move_ur10(motion_plan) ee_pose = self.give_location("/World/UR10/ee_link") print(ee_pose) if self.motion_task_counter==2 and not self.bool_done[current_observations["bool_counter"]]: self.bool_done[current_observations["bool_counter"]] = True print("position:", ee_pose.p) print("rotation:", ee_pose.r) self.remove_part("engine_bringer/platform", "fuel") self.add_part_custom("World/UR10/ee_link","fuel", "qfuel", np.array([0.001,0.001,0.001]), np.array([0.22927, -0.16445, -0.08733]), np.array([0.70711,0,-0.70711,0])) if self.motion_task_counter==4: print("Done motion plan") self.isDone[current_observations["task_event"]]=True # arm_robot picks and places part elif current_observations["task_event"] == 71: if not self.isDone[current_observations["task_event"]]: if not self.bool_done[current_observations["bool_counter"]]: self.bool_done[current_observations["bool_counter"]] = True print("Part removal done") self.remove_part("World/UR10/ee_link", "qfuel") self.motion_task_counter=0 self.add_part_custom("mock_robot/platform","fuel", "xfuel", np.array([0.001,0.001,0.001]), np.array([-0.03273, 0.09227, 0.58731]), np.array([0.70711,0.70711,0,0])) def transform(points): points[0]-=0.16 points[2]-=0.15 return points motion_plan = [{"index":0, "position": self.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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.transform_for_screw_ur10(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])}] print(self.motion_task_counter) self.do_screw_driving(motion_plan) ee_pose = self.give_location("/World/Screw_driving_UR10/ee_link") print("EE_Pose",ee_pose) if np.mean(np.abs(ee_pose.p - motion_plan[6]["goal_position"]))<0.058: self.isDone[current_observations["task_event"]]=True self.motion_task_counter=0 motion_plan = [{"index":0, "position": np.array([0.07, -0.81, 0.21]), "orientation": np.array([-0.69, 0, 0, 0.72]), "goal_position":np.array([-4.18372, 7.03628, 0.44567]), "goal_orientation":np.array([0.9999, 0, 0, 0])}] self.move_ur10(motion_plan) self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5,0])) print("done", self.motion_task_counter) # remove engine and add engine elif current_observations["task_event"] == 2: self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0.5,0])) # elif current_observations["task_event"] == 3: # self.moving_platform.apply_action(self._my_custom_controller.turn(command=[[-0.5, 0.5, -0.5, 0.5],0])) # self.motion_task_counter=0 # elif current_observations["task_event"] == 4: # self.moving_platform.apply_action(self._my_custom_controller.forward(command=[0,0])) # if not self.isDone[current_observations["task_event"]]: # motion_plan = [{"index":0, "position": self.transform_for_screw_ur10(np.array([0.7558, 0.59565, 0.17559])), "orientation": np.array([0.24137, -0.97029, -0.00397, -0.0163]), "goal_position":np.array([-5.3358, 5.42428, 0.41358]), "goal_orientation":np.array([0.18255, -0.68481, -0.68739, 0.15875])}, # {"index":1, "position": self.transform_for_screw_ur10(np.array([0.92167, 0.59565, 0.17559])), "orientation": np.array([0.24137, -0.97029, -0.00397, -0.0163]), "goal_position":np.array([-5.3358, 5.59014, 0.41358]), "goal_orientation":np.array([0.18255, -0.68481, -0.68739, 0.15875])}, # {"index":2, "position": self.transform_for_screw_ur10(np.array([0.7743, 0.13044, 0.24968])), "orientation": np.array([0.14946, 0.98863, 0.00992, 0.01353]), "goal_position":np.array([-4.8676, 5.44277, 0.48787]), "goal_orientation":np.array([0.09521, 0.6933, 0.70482, 0.1162])}, # {"index":3, "position": self.transform_for_screw_ur10(np.array([0.92789, 0.13045, 0.24968])), "orientation": np.array([0.14946, 0.98863, 0.00992, 0.01353]), "goal_position":np.array([-4.8676, 5.59636, 0.48787]), "goal_orientation":np.array([0.09521, 0.6933, 0.70482, 0.1162])}, # {"index":4, "position": np.array([-0.03152, -0.69498, 0.14425]), "orientation": np.array([0.69771, -0.07322, 0.09792, -0.70587]), "goal_position":np.array([-4.04212, 4.63272, 0.38666]), "goal_orientation":np.array([0.99219, -0.12149, 0.01374, 0.02475])}] # self.do_screw_driving(motion_plan) # ee_pose = self.give_location("/World/Screw_driving_UR10/ee_link") # print("EE_Pose",ee_pose) # if self.motion_task_counter>1 and np.mean(np.abs(ee_pose.p - motion_plan[4]["goal_position"]))<0.058: # self.isDone[current_observations["task_event"]]=True # print("done", self.motion_task_counter) return 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/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): 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"/{parent_prim_name}/{prim_name}") # gives asset ref path part= 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}" # world = self.get_world() prims.delete_prim(prim_path) def move(self, task): mp = self._world.get_observations()[self._world.get_task("awesome_task").get_params()["mp_name"]["value"]] print(mp) position, orientation, goal_position = mp['position'], mp['orientation'], mp['goal_position'][task-1] # 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) # 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)
30,709
Python
58.515504
441
0.610766
swadaskar/Isaac_Sim_Folder/extension_examples/follow_target/follow_target.py
import carb import asyncio from omni.isaac.examples.base_sample import BaseSample from omni.isaac.core.utils.stage import add_reference_to_stage from omni.isaac.core.robots import Robot import rospy import rosgraph # import actionlib # # Isaac sim cannot find these two modules for some reason... # from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal # from obstacle_map import GridMap # # Using /move_base_simple/goal for now from geometry_msgs.msg import PoseStamped import numpy as np class FollowTarget(BaseSample): def __init__(self) -> None: super().__init__() return def setup_scene(self): world = self.get_world() world.scene.add_default_ground_plane() # FIXME add_reference_to_stage(usd_path='/home/lm-2023/Isaac_Sim/navigation/Collected_real_microfactory_show/real_microfactory_show.usd', prim_path="/World") world.scene.add(Robot(prim_path="/World/damobile_platform", name="damobile_platform")) return async def setup_post_load(self): self._world = self.get_world() self._mp = self._world.scene.get_object("damobile_platform") if not rosgraph.is_master_online(): print("Please run roscore before executing this script") return try: rospy.init_node("set_goal_py") 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) self._goal_pub = rospy.Publisher("/move_base_simple/goal", PoseStamped, queue_size=1) return # def __send_initial_pose(self): # mp_position, mp_orientation = self._mp.get_world_pose() # current_pose = PoseWithCovarianceStamped() # current_pose.header.frame_id = "map" # current_pose.header.stamp = rospy.get_rostime() # current_pose.pose.pose.position.x = mp_position[0] # current_pose.pose.pose.position.y = mp_position[1] # current_pose.pose.pose.position.z = mp_position[2] # current_pose.pose.pose.orientation.x = mp_orientation[0] # current_pose.pose.pose.orientation.y = mp_orientation[1] # current_pose.pose.pose.orientation.z = mp_orientation[2] # current_pose.pose.pose.orientation.w = mp_orientation[3] # # rospy.sleep will stall Isaac sim simulation # # rospy.sleep(1) # self._initial_goal_publisher.publish(current_pose) # def __goal_response_callback(self, current_state, result): # if current_state not in [0, 1, 3]: # print("Goal rejected :(") # return # print("Goal accepted :)") # wait = self._action_client.wait_for_result() # self.__get_result_callback(wait) # def __get_result_callback(self, wait): # print("Result: "+str(wait)) # def send_navigation_goal(self, x, y, a): # FIXME # map_yaml_path = "/home/shihanzh/ros_ws/src/mp_2dnav/map/mp_microfactory_navigation.yaml" # grid_map = GridMap(map_yaml_path) # # generate random goal # if x is None: # print("No goal received. Generating random goal...") # range_ = grid_map.get_range() # x = np.random.uniform(range_[0][0], range_[0][1]) # y = np.random.uniform(range_[1][0], range_[1][1]) # orient_x = 0 # not needed because robot is in x,y plane # orient_y = 0 # not needed because robot is in x,y plane # orient_z = np.random.uniform(0, 1) # orient_w = np.random.uniform(0, 1) # else: # orient_x, orient_y, orient_z, orient_w = quaternion_from_euler(0, 0, a) # pose = [x, y, orient_x, orient_y, orient_z, orient_w] # if grid_map.is_valid_pose([x, y], 0.2): # self._action_client.wait_for_server() # goal_msg = MoveBaseGoal() # goal_msg.target_pose.header.frame_id = "map" # goal_msg.target_pose.header.stamp = rospy.get_rostime() # print("goal pose: "+str(pose)) # goal_msg.target_pose.pose.position.x = pose[0] # goal_msg.target_pose.pose.position.y = pose[1] # goal_msg.target_pose.pose.orientation.x = pose[2] # goal_msg.target_pose.pose.orientation.y = pose[3] # goal_msg.target_pose.pose.orientation.z = pose[4] # goal_msg.target_pose.pose.orientation.w = pose[5] # self._action_client.send_goal(goal_msg, done_cb=self.__goal_response_callback) # else: # print("Invalid goal "+str(pose)) # return async def setup_pre_reset(self): return async def setup_post_reset(self): return def world_cleanup(self): return
5,080
Python
39.325397
157
0.605906
swadaskar/Isaac_Sim_Folder/extension_examples/follow_target/follow_target_extension.py
import os from omni.isaac.examples.base_sample import BaseSampleExtension from omni.isaac.examples.follow_target import FollowTarget import omni.ext import omni.ui as ui from omni.isaac.ui.ui_utils import setup_ui_headers, get_style, btn_builder import asyncio import numpy as np import rospy from geometry_msgs.msg import PoseStamped from tf.transformations import euler_from_quaternion, quaternion_from_euler from math import pi class FollowTargetExtension(BaseSampleExtension): # same as in mp_2dnav package base_local_planner_params.yaml _xy_goal_tolerance = 0.25 _yaw_goal_tolerance = 0.05 def on_startup(self, ext_id: str): super().on_startup(ext_id) super().start_extension( menu_name="", submenu_name="", name="Navigation", title="My Awesome 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=FollowTarget(), ) return def _build_ui( self, name, title, doc_link, overview, file_path, number_of_extra_frames, window_width, keep_window_open ): self._window = omni.ui.Window( name, width=window_width, height=0, visible=keep_window_open, dockPreference=ui.DockPreference.LEFT_BOTTOM ) with self._window.frame: with ui.VStack(spacing=5, height=0): setup_ui_headers(self._ext_id, file_path, title, doc_link, overview) self._controls_frame = ui.CollapsableFrame( title="World Controls", width=ui.Fraction(1), height=0, collapsed=False, style=get_style(), horizontal_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_AS_NEEDED, vertical_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_ALWAYS_ON, ) with ui.VStack(style=get_style(), spacing=5, height=0): for i in range(number_of_extra_frames): self._extra_frames.append( ui.CollapsableFrame( title="", width=ui.Fraction(0.33), height=0, visible=False, collapsed=False, style=get_style(), horizontal_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_AS_NEEDED, vertical_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_ALWAYS_ON, ) ) with self._controls_frame: with ui.VStack(style=get_style(), spacing=5, height=0): dict = { "label": "Load World", "type": "button", "text": "Load", "tooltip": "Load World and Task", "on_clicked_fn": self._on_load_world, } self._buttons["Load World"] = btn_builder(**dict) self._buttons["Load World"].enabled = True dict = { "label": "Reset", "type": "button", "text": "Reset", "tooltip": "Reset robot and environment", "on_clicked_fn": self._on_reset, } self._buttons["Reset"] = btn_builder(**dict) self._buttons["Reset"].enabled = False dict = { "label": "Send Goal", "type": "button", "text": "Goal", "tooltip": "", "on_clicked_fn": self._send_navigation_goal, } self._buttons["Send Goal"] = btn_builder(**dict) self._buttons["Send Goal"].enabled = False return def post_load_button_event(self): self._buttons["Send Goal"].enabled = True 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._sample._mp.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 = -1,7,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] self._sample._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))
6,559
Python
44.241379
135
0.523403
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_replay_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 from omni.isaac.core.utils.extensions import get_extension_path_from_name 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.replay_follow_target import ReplayFollowTarget from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async import os class TestReplayFollowTargetExampleExtension(omni.kit.test.AsyncTestCase): # Before running each test async def setUp(self): await create_new_stage_async() await update_stage_async() self._sample = ReplayFollowTarget() 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 async def test_replay_trajectory(self): await self._sample.reset_async() await update_stage_async() await self._sample._on_replay_trajectory_event_async( os.path.abspath( os.path.join(get_extension_path_from_name("omni.isaac.examples"), "data/example_data_file.json") ) ) await update_stage_async() # run for 2500 frames and print time for i in range(500): await update_stage_async() pass async def test_replay_scene(self): await self._sample.reset_async() await update_stage_async() await self._sample._on_replay_scene_event_async( os.path.abspath( os.path.join(get_extension_path_from_name("omni.isaac.examples"), "data/example_data_file.json") ) ) await update_stage_async() # run for 2500 frames and print time for i in range(500): await update_stage_async() pass
3,296
Python
37.337209
119
0.668386
swadaskar/Isaac_Sim_Folder/extension_examples/tests/test_nut_bolt.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.franka_nut_and_bolt import FrankaNutAndBolt from omni.isaac.core.utils.stage import create_new_stage_async, is_stage_loading, update_stage_async from math import isclose class NutBoltExampleExtension(omni.kit.test.AsyncTestCase): # Before running each test async def setUp(self): await create_new_stage_async() await update_stage_async() self._sample = FrankaNutAndBolt() 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_nut_bolt(self): world = self._sample.get_world() await update_stage_async() # run for 4000 frames for i in range(4000): await update_stage_async() nut_on_bolt = False bolt = world.scene.get_object(f"bolt0_geom") bolt_pos, _ = bolt.get_world_pose() for j in range(self._sample._num_nuts): nut = world.scene.get_object(f"nut{j}_geom") nut_pos, _ = nut.get_world_pose() if ( isclose(nut_pos[0], bolt_pos[0], abs_tol=0.0009) and isclose(nut_pos[1], bolt_pos[1], abs_tol=0.0009) and isclose(nut_pos[2], bolt_pos[2] + 0.09, abs_tol=0.015) ): nut_on_bolt = True self.assertTrue(nut_on_bolt) pass async def test_reset(self): await self._sample.reset_async() await update_stage_async() world = self._sample.get_world() await update_stage_async() for i in range(4000): await update_stage_async() nut_on_bolt = False bolt = world.scene.get_object(f"bolt0_geom") bolt_pos, _ = bolt.get_world_pose() for j in range(self._sample._num_nuts): nut = world.scene.get_object(f"nut{j}_geom") nut_pos, _ = nut.get_world_pose() if ( isclose(nut_pos[0], bolt_pos[0], abs_tol=0.0009) and isclose(nut_pos[1], bolt_pos[1], abs_tol=0.0009) and isclose(nut_pos[2], bolt_pos[2] + 0.09, abs_tol=0.015) ): nut_on_bolt = True self.assertTrue(nut_on_bolt) pass
3,659
Python
37.526315
119
0.626401
swadaskar/Isaac_Sim_Folder/extension_examples/tests/__init__.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. # from .test_kaya_gamepad import * from .test_bin_filling import * from .test_follow_target import * from .test_omnigraph_keyboard import * from .test_robo_factory import * from .test_robo_party import * from .test_simple_stack import * from .test_hello_world import * from .test_replay_follow_target import * from .test_path_planning import * from .test_nut_bolt import *
805
Python
37.380951
76
0.785093
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_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/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/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/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.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/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/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/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/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
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/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_assets/test/test_valid_configs.py
# Copyright (c) 2022-2024, The ORBIT Project Developers. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # ignore private usage of variables warning # pyright: reportPrivateUsage=none """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 unittest import omni.isaac.orbit_assets as orbit_assets # noqa: F401 from omni.isaac.orbit.assets import AssetBase, AssetBaseCfg from omni.isaac.orbit.sensors import SensorBase, SensorBaseCfg from omni.isaac.orbit.sim import build_simulation_context class TestValidEntitiesConfigs(unittest.TestCase): """Test cases for all registered entities configurations.""" @classmethod def setUpClass(cls): # load all registered entities configurations from the module cls.registered_entities: dict[str, AssetBaseCfg | SensorBaseCfg] = {} # inspect all classes from the module for obj_name in dir(orbit_assets): obj = getattr(orbit_assets, obj_name) # store all registered entities configurations if isinstance(obj, (AssetBaseCfg, SensorBaseCfg)): cls.registered_entities[obj_name] = obj # print all existing entities names print(">>> All registered entities:", list(cls.registered_entities.keys())) """ Test fixtures. """ def test_asset_configs(self): """Check all registered asset configurations.""" # iterate over all registered assets for asset_name, entity_cfg in self.registered_entities.items(): for device in ("cuda:0", "cpu"): with self.subTest(asset_name=asset_name, device=device): with build_simulation_context(device=device, auto_add_lighting=True) as sim: # print the asset name print(">>> Testing entities:", asset_name) # name the prim path entity_cfg.prim_path = "/World/asset" # create the asset / sensors entity: AssetBase | SensorBase = entity_cfg.class_type(entity_cfg) # type: ignore # play the sim sim.reset() # check asset is initialized successfully self.assertTrue(entity._is_initialized) if __name__ == "__main__": run_tests()
2,541
Python
34.305555
106
0.630067
zoctipus/cse542Project/docker/x11.yaml
services: orbit-base: environment: - DISPLAY - TERM - QT_X11_NO_MITSHM=1 - XAUTHORITY=${__ORBIT_TMP_XAUTH} volumes: - type: bind source: ${__ORBIT_TMP_XAUTH} target: ${__ORBIT_TMP_XAUTH} - type: bind source: /tmp/.X11-unix target: /tmp/.X11-unix - type: bind source: /etc/localtime target: /etc/localtime read_only: true orbit-ros2: environment: - DISPLAY - TERM - QT_X11_NO_MITSHM=1 - XAUTHORITY=${__ORBIT_TMP_XAUTH} volumes: - type: bind source: ${__ORBIT_TMP_XAUTH} target: ${__ORBIT_TMP_XAUTH} - type: bind source: /tmp/.X11-unix target: /tmp/.X11-unix - type: bind source: /etc/localtime target: /etc/localtime read_only: true
809
YAML
20.891891
39
0.546354
Generlate/model_generator/CODE_OF_CONDUCT.md
# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [email protected]. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
5,228
Markdown
39.534883
80
0.811974
Generlate/model_generator/contributing.md
# Contributing to Generlate Hey! :wave: So - you want to contribute huh?... Well, THANK YOU. Generlate is making architectural design easier and any help is greatly appreciated! ## Code of Conduct This project and everyone participating in it is governed by the Generlate [Code of Conduct](https://github.com/Generlate/Generlate/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected]. ## What should I know before getting started? ### Generlate Structure To get a sense for the files that are included with Generlate, you can go to Generlate Core's default branch on the GitHub page and take a look around. ## How Can I Contribute? When suggesting changes, please include as many details as possible. Generlate Core's default branch is intentionally a stable release, so that anyone downloading the code and compiling it gets a stable release. Active development occurs on branches named after the version they are targeting, for example the 1.0.0 branch is named `1.0.0-dev.` When raising PRs, please raise against the relevant development branch and __not__ against the `master` branch The codebase is maintained using the "contributor workflow" where everyone without exception contributes patch proposals using "pull requests". This facilitates social contribution, easy testing and peer review. To contribute a patch, the workflow is as follows: * Fork the repository in GitHub, and clone it your development machine. * Create a topic branch from the relevant development branch. * Commit changes to the branch. * Test your changes, which must include the unit and RPC tests passing. * Push topic branch to your copy of the repository. * Raise a Pull Request via GitHub. Commit messages should be verbose by default consisting of a short subject line (50 chars max), a blank line and detailed explanatory text as separate paragraph(s); unless the title alone is self-explanatory (like "Corrected typo in init.cpp") then a single title line is sufficient. Commit messages should be helpful to people reading your code in the future, so explain the reasoning for your decisions. Please refer to the [Git manual](https://git-scm.com/doc) for more information about Git. The body of the pull request should contain enough description about what the patch does together with any justification/reasoning. You should include references to any discussions (for example other tickets or mailing list discussions). At this stage one should expect comments and review from other contributors. You can add more commits to your pull request by committing them locally and pushing to your fork until you have satisfied feedback. If your pull request is accepted for merging, you may be asked by a maintainer to squash and or rebase your commits before it will be merged. Please refrain from creating several pull requests for the same change. Use the pull request that is already open (or was created earlier) to amend changes. This preserves the discussion and review that happened earlier for the respective change set. The length of time required for peer review is unpredictable and will vary between pull requests. ## Pull Request Philosophy Pull Requests should always be focused. For example, a pull request could add a feature, fix a bug, or refactor code; but not a mixture. Please avoid submitting pull requests that attempt to do too much, are overly large, or overly complex as this makes review difficult. ### Features When adding a new feature, thought must be given to the long term technical debt and maintenance that feature may require after inclusion. Before proposing a new feature that will require maintenance, please consider if you are willing to maintain it (including bug fixing). If features get orphaned with no maintainer in the future, they may be removed. ## "Decision Making" Process Whether a pull request is merged into Generlate Core rests with the repository maintainers. Maintainers will take into consideration if a patch is in line with the general principles of Generlate; meets the minimum standards for inclusion; and will take into account the consensus among frequent contributors. In general, all pull requests must: * have a clear use case, fix a demonstrable bug or serve the greater good of Generlate; * be peer reviewed; * have functional tests; * follow code style guidelines; ### Peer Review Anyone may participate in peer review which is expressed by comments in the pull request. Typically reviewers will review the code for obvious errors, as well as test out the patch set and opine on the technical merits of the patch. Repository maintainers take into account the peer review when determining if there is consensus to merge a pull request. Maintainers reserve the right to weigh the opinions of peer reviewers using common sense judgement and also may weight based on meritocracy: Those that have demonstrated a deeper commitment and understanding towards Generlate (over time) or have clear domain expertise may naturally have more weight, as one would expect in all walks of life. # Copyright By contributing to this repository, you agree to license your work under the [Apach-2.0 license](https://github.com/Generlate/Generlate/blob/main/License), unless specified otherwise. Any work contributed where you are not the original author must contain its license header with the original author(s) and source. ## Styleguides ### Git Commit Messages ### JavaScript StyleGuide ### CoffeeScript Styleguide ### Specs Styleguide ### Documentation Styleguide ## Additional Notes ### Issues and Pull Request Labels
5,716
Markdown
55.049019
447
0.795136
Generlate/model_generator/README.md
<p align="center"> <img width="300" src="https://github.com/Generlate/model_generator/assets/85384584/93659fd6-ed44-44f0-b9bb-8124e0fe1966"> </p> The idea for this program came from interest in generative machine learning models. Human beating results have been generated by computers in chess, images and text. Naturally, I wonder if these results can be produced in another mode, 3d models. Not only will generative 3d models allow greater creative expression but also save massive amounts of time. So, I made this project as a first step. ![Group 1](https://github.com/Generlate/model_generator/assets/85384584/f0b014db-4579-4f15-97f4-4950ee23289b) I prioritized simplicity. This lead to the choices of python, a feed forward neural network and .off boxes. The program is composed of the datasets, a data loader, a data formatter, a neural network and the main file. Data is often a limiting factor for machine learning models. I didn't want the dataset to be another variable. So, I made a super simple dataset of randomly generated boxes. This was synthetically made from an algorithm. ![Screencast from 2023-07-17 08-29-57](https://github.com/Generlate/model_generator/assets/85384584/652c2424-ae9c-4022-bec7-210ffad87134) Example boxes are loaded from a directory, formatted into coordinate values, used to train the neural network and a .off box is exported. Given machine learning models' superior results, it's important to create generative systems for virtually everything that humans produce. This is the path to automating the economy. My focus is architecture. So, I'd like to develop these projects until they can generate entire cities. ## Directions #### For the Model Generator - Create a virtual environment with the dependencies installed - Download the repository (unzip if you downloaded the zipped file) - navigate to model_generator/machine_learning_model/machine_learning_model.py - open in zsh/bash and run ```python3 main.py``` - this should generate a box in /model_generator/generated_boxes/ titled "generated_box.off" - this box can be viewed on websites like https://3dviewer.net/ ![Screencast from 2023-07-17 06-24-45](https://github.com/Generlate/model_generator/assets/85384584/a3c493f3-cadf-4d56-b06f-7fe7a436927f) - in model_generator/Datasets/AustensBoxes/ you can find the training and testing datasets. These are filled with boxes, generated from a simpler, box generating algorithm. #### For the Omniverse Plugin - Sign up to Nvidia's Omniverse programs https://www.nvidia.com/en-us/omniverse/download/ - install Omniverse Code through the Omniverse Launcher ![Screenshot 2023-07-17 053003](https://github.com/Generlate/model_generator/assets/85384584/16b8adc5-3919-4905-b330-68157fd86525) - (In Omniverse Code) click on the extensions tab ![Screenshot 2023-07-17 053111](https://github.com/Generlate/model_generator/assets/85384584/a01f41e4-d916-4663-8481-754c8b2f6e04) - Click on the THIRD PARTY tab ![Screenshot 2023-07-17 053140](https://github.com/Generlate/model_generator/assets/85384584/64d9f91d-0e94-487e-a864-1fd2880ffc08) - Find MAKE A RANDOM CUBE by me (Austen Cabret) and toggle the grey switch that activates the plugin. - a moveable window should pop up that has two buttons. - click the add button to add random cubes and the delete button the remove them. ![Recording 2023-07-17-050924](https://github.com/Generlate/model_generator/assets/85384584/4633d6ed-abb5-4f7f-9333-c3b2e1fa8e1f) ## Dependencies - Python3 - Pytorch - Numpy - Omniverse ## Features To Come * More supported file types (.obj, .usd, .fbx) * Faster generation speeds * Plugin to Omniverse UI * Generate more than just boxes * Text as input * Neural network improvements * Easier execution
3,773
Markdown
51.416666
439
0.781606
Generlate/model_generator/omniverse-random-cubes/exts/austen.random.cube/austen/random/cube/extension.py
import omni.ext import omni.ui as ui import omni.kit.commands import random # Functions and vars are available to other extension as usual in python: `example.python_ext.some_public_function(x)` def some_public_function(x: int): print("[austen.random.cube] some_public_function was called with x: ", x) return x**x # Any class derived from `omni.ext.IExt` in top level module (defined in `python.modules` of `extension.toml`) will be # instantiated when extension gets enabled and `on_startup(ext_id)` will be called. Later when extension gets disabled # on_shutdown() is called. class AustenRandomCubeExtension(omni.ext.IExt): # ext_id is current extension id. It can be used with extension manager to query additional information, like where # this extension is located on filesystem. def on_startup(self): print("[austen.random.cube] austen random cube startup") self._window = ui.Window("Make Random Cube", width=300, height=300) with self._window.frame: with ui.VStack(): def generate_random_algorithm_cube(): omni.kit.commands.execute( "CreateMeshPrimWithDefaultXform", prim_type="Cube" ) omni.kit.commands.execute( "TransformMultiPrimsSRTCpp", count=1, paths=["/World/Cube"], new_translations=[0.0, 0.0, 0.0], new_rotation_eulers=[0.0, 0.0, 0.0], new_rotation_orders=[0, 1, 2], new_scales=[ (random.uniform(0.05, 3)), (random.uniform(0.05, 3)), (random.uniform(0.05, 3)), ], old_translations=[0.0, 0.0, 0.0], old_rotation_eulers=[0.0, 0.0, 0.0], old_rotation_orders=[0, 1, 2], old_scales=[1.0, 1.0, 1.0], usd_context_name="", time_code=0.0, ) def delete(): omni.kit.commands.execute( "DeletePrims", paths=[ "/World/Cube", "/World/Cube_01", "/World/Cube_02", "/World/Cube_03", "/World/Cube_04", "/World/Cube_05", "/World/Cube_06", "/World/Cube_07", "/World/Cube_08", "/World/Cube_09", "/World/Cube_10", ], destructive=False, ) with ui.HStack(): with ui.VStack(): ui.Button( "Add a random algorithm cube", clicked_fn=generate_random_algorithm_cube, ) ui.Button("Delete", clicked_fn=delete, width=110) def on_shutdown(self): print("[austen.random.cube] austen random cube shutdown")
3,326
Python
40.074074
119
0.454901
Generlate/model_generator/model_generator/main.py
#!/usr/bin/env python3 """ Runs a formatted dataset through a neural network, formats the output to be viewed as a 3d object and file name.""" import os import numpy import torch.nn as nn import torch.optim as optim import utils.data_formatter from utils.neural_network import NeuralNetwork if __name__ == "__main__": # Create an instance of the neural network. model = NeuralNetwork() # Define the loss function and optimizer. CRITERION = nn.MSELoss() OPTIMIZER = optim.SGD(model.parameters(), lr=0.01) # Load the datasets. TRAINING_INPUT = utils.data_formatter.TRAINING_COMBINED_TENSOR TESTING_INPUT = utils.data_formatter.TESTING_COMBINED_TENSOR # Set number of epochs. I found three to give the lowest loss score. NUMBER_OF_EPOCHS = 3 TESTING_DATA_ITERATOR = iter(TESTING_INPUT) # The training loop. for EPOCH in range(NUMBER_OF_EPOCHS): # Get the next testing data tensor. TESTING_DATA_TENSOR = next(TESTING_DATA_ITERATOR) # Generate box coordinates. OUTPUT = model(TRAINING_INPUT) # Compare the generated coordinates against the test coordinates. LOSS = CRITERION(OUTPUT, TESTING_DATA_TENSOR) # Print the loss every epoch. # print(f"Epoch: {epoch+1}, Loss: {loss.item()}") # List the generated coordinates. ARRAY = OUTPUT.detach().numpy().flatten() # Format to .off. FORMATTED_ARRAY = "OFF\n8 6 0\n" for i, VALUE in enumerate(ARRAY): FORMATTED_ARRAY += str(VALUE * 22) + " " if (i + 1) % 3 == 0: FORMATTED_ARRAY += "\n" ADDITIONAL_STRING = """4 0 1 2 3 4 1 5 6 2 4 5 4 7 6 4 4 0 3 7 4 3 2 6 7 4 4 5 1 0""" FORMATTED_ARRAY += ADDITIONAL_STRING file_path = "./generated_boxes/generated_box.off" # Check if the file already exists. FILE_EXISTS = os.path.exists(file_path) if FILE_EXISTS: # Find the next available file name by incrementing a counter. FILE_COUNTER = 1 while FILE_EXISTS: FILE_NAME, FILE_EXTENSION = os.path.splitext(file_path) INCREMENTED_FILE_PATH = ( f"{FILE_NAME}_{FILE_COUNTER}{FILE_EXTENSION}" ) FILE_EXISTS = os.path.exists(INCREMENTED_FILE_PATH) FILE_COUNTER += 1 file_path = INCREMENTED_FILE_PATH # Save the .off file. with open(file_path, "w") as FILE: FILE.write(FORMATTED_ARRAY) print("File generated successfully. Saved as:", file_path)
2,523
Python
29.409638
119
0.633373
Generlate/model_generator/model_generator/datasets/austens_boxes/algorithmic_box_generator.py
import random VERTICES = [ [-1, -1, -1], # Vertex 0 [1, -1, -1], # Vertex 1 [1, 1, -1], # Vertex 2 [-1, 1, -1], # Vertex 3 [-1, -1, 1], # Vertex 4 [1, -1, 1], # Vertex 5 [1, 1, 1], # Vertex 6 [-1, 1, 1] # Vertex 7 ] FACES = [ [0, 1, 2, 3], # Face 0 [1, 5, 6, 2], # Face 1 [5, 4, 7, 6], # Face 2 [4, 0, 3, 7], # Face 3 [3, 2, 6, 7], # Face 4 [4, 5, 1, 0] # Face 5 ] def generate_box(width, height, depth, filename): with open(filename, 'w') as f: f.write('OFF\n') f.write(f'{len(VERTICES)} {len(FACES)} 0\n') for vertex in VERTICES: f.write(f'{vertex[0]:.2f} {vertex[1]:.2f} {vertex[2]:.2f}\n') for face in FACES: f.write(f'{len(face)} {" ".join(map(str, face))}\n') def generate_multiple_boxes(num_boxes): for i in range(num_boxes): width, height, depth = [random.randint(1, 10) for _ in range(3)] filename = f'box{i}.off' generate_box(width, height, depth, filename) print(f'Box {i} with dimensions ' f'{width:.2f}x{height:.2f}x{depth:.2f} ' f'exported to {filename}.') generate_multiple_boxes(100)
1,219
Python
24.416666
73
0.483183
Generlate/model_generator/model_generator/utils/data_formatter.py
""" Formats the dataset to the proper format for the neural network to process. """ import torch from utils.data_loader import TrainingDataLoader, TestingDataLoader # Specify where the training and testing boxes are stored and how many to load. training_data_directory = "./datasets/austens_boxes/training/" testing_data_directory = "./datasets/austens_boxes/testing/" training_number_of_files = 60 testing_number_of_files = 10 # Apply the class that loads and formats the box data. TRAINING_DATASET = TrainingDataLoader( training_data_directory, training_number_of_files ) TESTING_DATASET = TestingDataLoader( testing_data_directory, testing_number_of_files ) # Get numbers from the files and convert to tensor. TRAINING_NUMBER_LISTS = [ torch.tensor( [ LIST[INDEX] for LIST in TRAINING_DATASET.file_contents if len(LIST) > INDEX ] ) for INDEX in range(24) ] TRAINING_NUMBER_LISTS_FLOAT32 = [ TENSOR.to(torch.float32) for TENSOR in TRAINING_NUMBER_LISTS ] # Get testing tensors for each file. TESTING_TENSORS = [ TESTING_DATASET[INDEX] for INDEX in range(len(TESTING_DATASET)) ] # Combine tensors into a single tensor. TRAINING_COMBINED_TENSOR = torch.stack(TRAINING_NUMBER_LISTS_FLOAT32, dim=0) TESTING_COMBINED_TENSOR = torch.stack(TESTING_TENSORS, dim=0)
1,349
Python
27.723404
83
0.727947
Generlate/model_generator/model_generator/utils/data_loader.py
""" Module to get data from a directory and convert it to a python dataset.""" import os import torch from torch.utils.data import Dataset class TrainingDataLoader(Dataset): """Allows a training dataset to be created from a directory of files.""" def __init__(self, training_data_directory, training_number_of_files): """Initializes a Dataset by loading files from a directory.""" # The sorted file paths limited to the number specified. file_paths = [ os.path.join(training_data_directory, file_name) for file_name in sorted(os.listdir(training_data_directory)) ][:training_number_of_files] self.file_contents = self.load_file_contents(file_paths) def __len__(self): """Returns the dataset's length.""" return len(self.file_contents) def __getitem__(self, index): """Return as a tensor.""" return torch.tensor(self.file_contents[index]) def load_file_contents(self, file_paths): """Loads file contents.""" file_contents = [] for file_path in file_paths: with open(file_path, "r") as file: lines = file.readlines()[2:10] content = "".join(lines) organized_content = self.organize_content(content) file_contents.append(organized_content) return file_contents def organize_content(self, content): """Organize the dataset.""" lines = content.split("\n") organized_lines = [ list(map(round, map(float, line.split()))) for line in lines if line.strip() ] return [val for sublist in organized_lines for val in sublist] class TestingDataLoader(Dataset): """Allows a testing dataset to be created from a directory of files.""" def __init__(self, testing_data_directory, testing_number_of_files): """To fill.""" # The sorted file paths limited to the number specified. file_names = sorted(os.listdir(testing_data_directory))[ :testing_number_of_files ] self.file_paths = [ os.path.join(testing_data_directory, file_name) for file_name in file_names ] def __len__(self): """Return the dataset's length.""" return len(self.file_paths) def __getitem__(self, index): """Return file contents as a tensor.""" file_path = self.file_paths[index] file_contents = self.load_file_contents(file_path) return torch.tensor(file_contents, dtype=torch.float32) def load_file_contents(self, file_path): """Loads file contents.""" with open(file_path, "r") as file: lines = file.readlines()[2:10] content = "".join(lines) formatted_content = self.organize_content(content) return formatted_content def organize_content(self, content): """Organize the dataset.""" lines = content.split("\n") organized_lines = [ list(map(round, map(float, line.split()))) for line in lines if line.strip() ] flattened_list = [ val for sublist in organized_lines for val in sublist ] reshaped_array = torch.tensor(flattened_list).reshape(-1, 1) return reshaped_array
3,368
Python
34.463158
78
0.59709
Generlate/model_generator/model_generator/utils/neural_network.py
""" Takes in tensors and returns new tensors.""" import torch import torch.nn as nn # Define the neural network structure. More hidden layers had negligent effect on loss. class NeuralNetwork(nn.Module): """Calls Pytorch functions to process a tensor through a neural network.""" def __init__(self): """Initializes a Neural network with three hidden layers.""" super(NeuralNetwork, self).__init__() self.hidden1 = nn.Linear(60, 80) self.hidden2 = nn.Linear(80, 80) self.hidden3 = nn.Linear(80, 80) self.output = nn.Linear(80, 1) def forward(self, x): """Applies a relu activation function.""" x = torch.relu(self.hidden1(x)) x = torch.relu(self.hidden2(x)) x = torch.relu(self.hidden3(x)) x = self.output(x) return x
830
Python
30.961537
87
0.626506
tudelft/autoGDMplus/main.py
import os import re import json import glob import numpy as np import pandas as pd from pathlib import Path from datetime import datetime from colorama import Fore, Back, Style from layout_gen import generate_recipes from utils import GDMConfig, flow_field, is_float, read_gas_data, read_wind_data, read_occ_csv HOME_DIR = Path.home() main_path = os.path.abspath(__file__) AutoGDM2_dir = os.path.dirname(main_path) class AutoGDM2: def __init__(self, settings:dict): self.settings = settings self.isaac_dir = self.settings["isaac_dir"] self.wh_gen_dir = self.settings["wh_gen_dir"] self.blender_dir = self.settings["blender_dir"] self.env_lst = self.settings["env_list"] self.env_lst_failed = [] # different color and formatting to display the terminal def printGDMStyle(self, string): print(Fore.GREEN + Style.BRIGHT + string) print(Style.RESET_ALL) # get list of environment names def get_envs(self) -> None: return os.listdir(self.settings["geometry_dir"]) def remove_envs(self, indexes:list) -> None: for index in sorted(indexes, reverse=True): self.env_lst_failed.append(self.env_lst[index]) del self.env_lst[index] # cleanup func the AutoGDM2 directories def cleanup(self) -> None: self.printGDMStyle("[AutoGDM2] Performing cleanup...") # remove everything in ./environments/recipes if os.listdir(self.settings["recipe_dir"]): os.system(f"cd {self.settings['recipe_dir']} && rm -v *") else: self.printGDMStyle("[AutoGDM2] No recipies to clean.") # remove everything in ./environments/geometry if os.listdir(self.settings["geometry_dir"]): os.system(f"cd {self.settings['geometry_dir']} && rm -rv *") else: self.printGDMStyle("[AutoGDM2] No mockup scenes to clean.") # remove everything in ./environments/isaac_sim if os.listdir(self.settings["usd_scene_dir"]): os.system(f"cd {self.settings['usd_scene_dir']} && rm -v *") else: self.printGDMStyle("[AutoGDM2] No usd scenes to clean.") # remove everything in ./environments/cfd EXCEPT the 'default_cfd_case' directory rm_string = ' '.join([str(item) for item in [x for x in os.listdir(self.settings["cfd_dir"]) if 'default' not in x]]) if rm_string: os.system(f"cd {self.settings['cfd_dir']} && rm -rv {rm_string}") else: self.printGDMStyle("[AutoGDM2] No CFD cases to clean.") # remove all directories in gaden_env_dir (NOT CMakelLists.txt and package.xml) if os.listdir(self.settings["gaden_env_dir"]): os.system(f"cd {self.settings['gaden_env_dir']} && rm -rv */") else: self.printGDMStyle("[AutoGDM2] No usd scenes to clean.") # remove everything in ./environments/gas_data if os.listdir(self.settings["gas_data_dir"]): os.system(f"cd {self.settings['gas_data_dir']} && rm -rv *") else: self.printGDMStyle("[AutoGDM2] No gas data to clean.") # remove everything in ./environments/wind_data if os.listdir(self.settings["wind_data_dir"]): os.system(f"cd {self.settings['wind_data_dir']} && rm -rv *") else: self.printGDMStyle("[AutoGDM2] No wind data to clean.") # remove everything in ./environments/occupancy if os.listdir(self.settings["occ_data_dir"]): os.system(f"cd {self.settings['occ_data_dir']} && rm -rv *") else: self.printGDMStyle("[AutoGDM2] No occupancy data to clean.") self.printGDMStyle("[AutoGDM2] Cleanup completed.") # layout generator, results in recipes.txt def layout_gen(self): self.printGDMStyle(f"[AutoGDM2] Generating {self.settings['env_amount']} recipes for type {self.settings['env_type']}...") generate_recipes(self.settings) self.printGDMStyle("[AutoGDM2] Completed environment recipe generation. ") # blender .stl generator, results in stls in environments/mockup_scenes def blender_asset_placer(self): self.printGDMStyle("[AutoGDM2] Creating .stl files...") blender_exe = os.path.join(self.blender_dir, 'blender') command = f"{blender_exe} --background --python blender_asset_placer.py -- {self.settings['recipe_dir']} {self.settings['geometry_dir']}" # run blender in the background os.system(command) self.printGDMStyle("[AutoGDM2] Completed .stl file creation.") # isaac usd scene generator, results in usd scenes in environments/isaac_sim def isaac_asset_placer(self): self.printGDMStyle("[AutoGDM2] Creating .usd scenes...") isaac_exe = os.path.join(self.isaac_dir, 'python.sh') wh_gen_exe= os.path.join(self.wh_gen_dir, 'isaac_asset_placer.py') command = f"{isaac_exe} {wh_gen_exe} -- {self.settings['recipe_dir']} {self.settings['usd_scene_dir']}" os.system(command) self.printGDMStyle("[AutoGDM2] Completed .usd scene creation.") # run cfMesh for created .stl files def cfd_mesh(self): self.printGDMStyle("[AutoGDM2] Creating CFD meshes...") for scenedir in self.env_lst: currentdir = f"{self.settings['geometry_dir']}{scenedir}/mesh/" self.printGDMStyle(f"[AutoGDM2] Meshing environment {scenedir}...") # remove comined.stl if it already exists if os.path.isfile(f"{currentdir}combined.stl"): os.remove(f"{currentdir}combined.stl") stls = glob.glob(f"{currentdir}*.stl") # gather all stls stls_str = ' '.join([str(item) for item in stls]) # put them in one string separated by spaces # edit the solid name at the start and end of each .stl file # (bad method for large files but it works for now) for stl_path in stls: with open(f"{stl_path}", "r") as f: stl_name = stl_path.rsplit('/', 1)[-1][:-4] data = f.readlines() data[0] = f"solid {stl_name}\n" # don't forget to add a newline! data[-1] = f"endsolid {stl_name}\n" with open(f"{stl_path}", "w") as f: f.writelines(data) f.close() # combine .stls with cat command and change to a .fms file catcommand = f"cat {stls_str} >> combined.stl" fmscommand = "surfaceFeatureEdges combined.stl combined.fms" os.system(f"cd {currentdir} && {catcommand} && {fmscommand}") # change boundary conditions at the start of combined.fms with open(f"{currentdir}combined.fms", "r") as f: data = f.readlines() for i,line in enumerate(data[0:20]): # check only the first 20 lines if "outlet" in line: data[i] = "outlet patch\n" elif "interior" in line: data[i] = "interior wall\n" elif "inlet" in line: data[i] = "inlet patch\n" elif "sides" in line: data[i] = "sides wall\n" with open(f"{currentdir}combined.fms", "w") as f: f.writelines(data) f.close() # create cfd case directory if it does not exist already from defualt_cfd_case cfd_case_dir = f"{self.settings['cfd_dir']}{scenedir}/" if not os.path.isdir(cfd_case_dir): os.system(f"cp -r {self.settings['cfd_dir']}default_cfd_case {cfd_case_dir}") # move .fms to separate cfd dir in environments/cfd os.system(f"cp {currentdir}combined.fms {cfd_case_dir}") # set mesh settings with open(f"{cfd_case_dir}system/meshDict", "r") as f: data = f.readlines() data[20] = f"minCellSize {self.settings['cfd_mesh_settings']['minCellSize']};\n" data[22] = f"maxCellSize {self.settings['cfd_mesh_settings']['maxCellSize']};\n" data[24] = f"boundaryCellSize {self.settings['cfd_mesh_settings']['boundaryCellSize']};\n" if self.settings['cfd_mesh_settings']["localRefinement"] != 0: data[26] = "localRefinement\n" # uncomment localRefinement setting data[30] = f" cellSize {self.settings['cfd_mesh_settings']['localRefinement']};\n" data[32] = "}\n" with open(f"{cfd_case_dir}/system/meshDict", "w") as f: f.writelines(data) f.close() # run the meshing process os.system(f"cd {cfd_case_dir} && cartesianMesh") self.printGDMStyle("[AutoGDM2] Completed CFD mesh creation.") def cfd_set_params(self): self.printGDMStyle("[AutoGDM2] Setting CFD parameters...") for cfd_case in self.env_lst: cfd_case_dir = f"{self.settings['cfd_dir']}{cfd_case}/" #### 0 folder #### # set U with open(f"{cfd_case_dir}0/U", "r") as f: data = f.readlines() data[25] = f" value uniform ({self.settings['inlet_vel'][0]} {self.settings['inlet_vel'][1]} {self.settings['inlet_vel'][2]});\n" with open(f"{cfd_case_dir}0/U", "w") as f: f.writelines(data) f.close() # set k (turbelent kinetic energy) with open(f"{cfd_case_dir}0/k", "r") as f: data = f.readlines() data[21] = f"internalField uniform {self.settings['cfd_settings']['k']};\n" for i in [28, 39, 45]: data[i] = f" value uniform {self.settings['cfd_settings']['k']};\n" with open(f"{cfd_case_dir}0/k", "w") as f: f.writelines(data) f.close() # set epsilon (dissipation rate) with open(f"{cfd_case_dir}0/epsilon", "r") as f: data = f.readlines() data[21] = f"internalField uniform {self.settings['cfd_settings']['epsilon']};\n" for i in [28, 39, 45]: data[i] = f" value uniform {self.settings['cfd_settings']['epsilon']};\n" with open(f"{cfd_case_dir}0/epsilon", "w") as f: f.writelines(data) f.close #### sytem folder #### # decomposeParDict (set the division of the mesh to the amount of threads) with open(f"{cfd_case_dir}system/decomposeParDict", "r") as f: data = f.readlines() data[17] = f"numberOfSubdomains {self.settings['cfd_settings']['threads']};\n" with open(f"{cfd_case_dir}system/decomposeParDict", "w") as f: f.writelines(data) f.close() # controlDict with open(f"{cfd_case_dir}system/controlDict", "r") as f: data = f.readlines() data[24] = f"endTime {self.settings['cfd_settings']['endTime']};\n" data[30] = f"writeInterval {self.settings['cfd_settings']['writeInterval']};\n" data[48] = f"maxCo {self.settings['cfd_settings']['maxCo']};\n" if self.settings['cfd_settings']['maxDeltaT'] != 0.0: data[50] = f"maxDeltaT {self.settings['cfd_settings']['maxDeltaT']};\n" with open(f"{cfd_case_dir}system/controlDict", "w") as f: f.writelines(data) f.close() # fvSolution with open(f"{cfd_case_dir}system/fvSolution", "r") as f: data = f.readlines() data[51] = f" nOuterCorrectors {self.settings['cfd_settings']['nOuterCorrectors']};\n" with open(f"{cfd_case_dir}system/fvSolution", "w") as f: f.writelines(data) f.close() self.printGDMStyle("[AutoGDM2] CFD parameters set.") def cfd_run(self): self.printGDMStyle("[AutoGDM2] Running CFD...") for cfd_case in self.env_lst: cfd_case_dir = f"{self.settings['cfd_dir']}{cfd_case}/" self.printGDMStyle(f"[AutoGDM2] Running CFD for case {cfd_case}...") runcmd = f"mpirun --use-hwthread-cpus -np {self.settings['cfd_settings']['threads']} pimpleFoam -parallel" if self.settings['cfd_settings']['latestTime']: processcmd = f"postProcess -func 'components(U)' -latestTime && postProcess -func 'writeCellCentres' -latestTime" else: processcmd = f"postProcess -func 'components(U)' -time {self.settings['cfd_settings']['timeRange']} && postProcess -func 'writeCellCentres' -time {self.settings['cfd_settings']['timeRange']}" # decompose -> run CFD -> reconstruct -> postprocess os.system(f"cd {cfd_case_dir} && decomposePar && {runcmd} && reconstructPar && {processcmd}") self.printGDMStyle("[AutoGDM2] Completed CFD.") return def make_ros_folder(self): # adapted from AUTOGDM TODO: improve self.printGDMStyle(f"[AutoGDM2] Creating ROS directories in {self.settings['gaden_env_dir']}...") for env in self.env_lst: self.ros_loc = f"{self.settings['gaden_env_dir']}{env}" if os.path.exists(self.ros_loc): os.system(f"rm -rf {self.ros_loc}") # TODO move to cleanup? os.system(f"mkdir -p {self.ros_loc}") # create env dir in gaden_env_dir os.system(f"cp -r {self.settings['empty_ros_dir']}* {self.ros_loc}") # copy the empty ROS dir to it self.printGDMStyle(f"[AutoGDM2] Created ROS directories in {self.settings['gaden_env_dir']}.") # prepare ROS directory with environment-specific configurations (adapted from AutoGDM) def prep_ros(self): self.printGDMStyle(f"[AutoGDM2] Preparing ROS...") sim_arg = f"{int(sum(self.settings['inlet_vel']))}ms" # simulation argument (required in GADEN.launch, gives possibility to use multiple wind simulations) invalid_idx = [] for env_idx,env in enumerate(self.env_lst): self.cfd_folder = f"{self.settings['cfd_dir']}{env}" self.ros_loc = f"{self.settings['gaden_env_dir']}{env}" os.system(f"mkdir -p {self.ros_loc}/wind_simulations/{sim_arg}/") # create dir for specific wind simulation time_dirs = [i for i in os.listdir(self.cfd_folder) if is_float(i)] time_dirs_float = [float(i) for i in time_dirs] # necessary for np.argmax if self.settings['cfd_settings']['latestTime']: steps = [time_dirs[np.argmax(time_dirs_float)]] else: # get start and stop value from settings start_stop = [float(i) for i in re.findall(r"[-+]?\d*\.?\d+",self.settings['cfd_settings']['timeRange'])] # get all timesteps that are within the range steps = np.sort([i for i in time_dirs_float if i >= start_stop[0] and i <= start_stop[1]]) steps = [str(i) for i in steps] # change float values to integer if possible for i,step in enumerate(steps): if float(steps[i]).is_integer(): steps[i] = str(int(float(step))) # ugly but it works! for step_idx,step in enumerate(steps): try: f = open(f"{self.cfd_folder}/{step}/C") except FileNotFoundError: print(f"CFD failed for this environment, skipping...") invalid_idx.append(env_idx) # save invalid env idx to remove later continue print(f"Preparing windfield {step_idx + 1}/{len(steps)}") self.points_file = f.readlines() self.points_x = [] self.points_y = [] self.points_z = [] for i,line in enumerate(self.points_file): if i >=23: if line.find(")") == 0: break line = line.replace("("," ").replace(")"," ").split() self.points_x.append(float(line[0])) self.points_y.append(float(line[1])) self.points_z.append(float(line[2])) timestep = flow_field(step) f = open(self.cfd_folder+"/"+str(step)+'/U') flow_data = f.readlines() Ux = [] Uy = [] Uz = [] for i,line in enumerate(flow_data): if i >=23: if line.find(")") == 0: break line = line.replace("("," ").replace(")"," ").split() Ux.append(float(line[0])) Uy.append(float(line[1])) Uz.append(float(line[2])) timestep.Ux, timestep.Uy, timestep.Uz = Ux, Uy, Uz data = {'U:0': timestep.Ux, 'U:1':timestep.Uy,'U:2': timestep.Uz,'Points:0':self.points_x,'Points:1':self.points_y,'Points:2':self.points_z} df = pd.DataFrame(data, columns= ['U:0','U:1','U:2','Points:0','Points:1','Points:2']) df.to_csv(f"{self.ros_loc}/wind_simulations/{sim_arg}/wind_at_cell_centers_{step_idx}.csv",index=False,header=True) # gather .stls in ./environments/geometry and copy them to the gaden/envs/envname folder self.ros_cad_loc = f"{self.ros_loc}/cad_models/" stls = glob.glob(f"{self.settings['geometry_dir']}{env}/gaden/*.stl") # gather all stls stls_str = ' '.join([str(item) for item in stls]) # put them in one string separated by spaces os.system(f"cp {stls_str} {self.ros_cad_loc}") # get new empty point for source # self.place_source() # TODO move out # edit launch files self.ros_launch_folder = self.ros_loc + '/launch/' # GADEN_preprocessing.launch # TODO make specification for outlet CAD models flexible by inserting more lines (multiple outlets possible) with open(f"{self.ros_launch_folder}GADEN_preprocessing.launch", "r") as f: data = f.readlines() data[5] = f' <arg name="scenario" default="{env}"/>\n' data[10] =f' <param name="cell_size" value="{self.settings["cfd_mesh_settings"]["minCellSize"]}"/>\n' # set gas sim cell size to the cfd mesh size data[33] =f' <param name="empty_point_x" value="{round(self.settings["src_placement"][0],2)}"/> ### (m)\n' data[34] =f' <param name="empty_point_y" value="{round(self.settings["src_placement"][1],2)}"/> ### (m)\n' data[35] =f' <param name="empty_point_z" value="{round(self.settings["src_placement"][2],2)}"/> ### (m)\n' data[40] =f' <param name="wind_files" value="$(find envs)/$(arg scenario)/wind_simulations/{sim_arg}/wind_at_cell_centers"/>\n' if self.settings["env_type"] == 'wh_empty': # delete interior cad model from launchfile data[13] = ' <param name="number_of_models" value="1"/>' data[15] = '' with open(f"{self.ros_launch_folder}GADEN_preprocessing.launch", "w") as f: f.writelines(data) f.close() # GADEN.launch # TODO add filament simulator settings and looping options with open(f"{self.ros_launch_folder}GADEN.launch", "r") as f: data = f.readlines() data[5] = f' <arg name="scenario" default="{env}"/>\n' data[6] = f' <arg name="simulation" default="{sim_arg}" />\n' data[7] = f' <arg name="source_location_x" value="{"%.2f" % self.settings["src_placement"][0]}"/> ### (m)\n' data[8] = f' <arg name="source_location_y" value="{"%.2f" % self.settings["src_placement"][1]}"/> ### (m)\n' data[9] = f' <arg name="source_location_z" value="{"%.2f" % self.settings["src_placement"][2]}"/> ### (m)\n' data[50] = f' <param name="sim_time" value="{self.settings["sim_time"]}" /> ### [sec] Total time of the gas dispersion simulation\n' data[51] = f' <param name="time_step" value="{self.settings["time_step"]}" /> ### [sec] Time increment between snapshots. Set aprox = cell_size/max_wind_speed.\n' data[58] = f' <param name="gas_type" value="{self.settings["gas_type"]}" /> ### 0=Ethanol, 1=Methane, 2=Hydrogen, 6=Acetone\n' data[68] = f' <param name="wind_time_step" value="{self.settings["cfd_settings"]["writeInterval"]}" /> ### (sec) time increment between Wind snapshots\n' data[70] = f' <param name="/allow_looping" value="{self.settings["wind_looping"]}" />\n' data[71] = f' <param name="/loop_from_step" value="{self.settings["wind_start_step"]}" />\n' data[72] = f' <param name="/loop_to_step" value="{self.settings["wind_stop_step"]}" />\n' with open(f"{self.ros_launch_folder}GADEN.launch", "w") as f: f.writelines(data) f.close() # GADEN_player.launch # TODO check for relevant CAD models and add/delete automatically with open(f"{self.ros_launch_folder}GADEN_player.launch", "r") as f: data = f.readlines() data[4] = f' <arg name="scenario" default="{env}"/>\n' data[5] = f' <arg name="simulation" default="{sim_arg}" />\n' data[6] = f' <arg name="source_location_x" value="{"%.2f" % self.settings["src_placement"][0]}"/> ### (m)\n' data[7] = f' <arg name="source_location_y" value="{"%.2f" % self.settings["src_placement"][1]}"/> ### (m)\n' data[8] = f' <arg name="source_location_z" value="{"%.2f" % self.settings["src_placement"][2]}"/> ### (m)\n' with open(f"{self.ros_launch_folder}GADEN_player.launch", "w") as f: f.writelines(data) f.close() self.remove_envs(invalid_idx) # remove the failed environments from the environment list self.printGDMStyle(f"[AutoGDM2] Prepared ROS.") # roslaunch GADEN preprocessing (adapted from AutoGDM) def run_preprocessing(self): self.printGDMStyle(f"[AutoGDM2] Preprocessing with GADEN...") for env in self.env_lst: self.printGDMStyle(f"[AutoGDM2] Preprocessing {env} with GADEN...") self.ros_loc = f"{self.settings['gaden_env_dir']}{env}" self.ros_launch_folder = self.ros_loc + '/launch/' os.system(f"cd {self.ros_launch_folder} && roslaunch GADEN_preprocessing.launch") self.printGDMStyle(f"[AutoGDM2] GADEN Preprocessing finished.") # roslaunch GADEN gas_simulator (adapted from AutoGDM) def run_ros(self): self.printGDMStyle(f"[AutoGDM2] Simulating gas dispersal with GADEN...") for env in self.env_lst: self.printGDMStyle(f"[AutoGDM2] Simulating gas dispersal for {env} with GADEN...") self.ros_loc = f"{self.settings['gaden_env_dir']}{env}" self.ros_launch_folder = self.ros_loc + '/launch/' os.system(f"cd {self.ros_launch_folder} && roslaunch GADEN.launch") self.printGDMStyle(f"[AutoGDM2] Finished gas dispersal simulation with GADEN...") # TODO - generate one array containing all gas iterations # compressed binary to numpy files for easy python use def gasdata_binary2npy(self, savetxt=False): for env_dir in self.env_lst: # create folder for the gas data output output_dir = f"{self.settings['gas_data_dir']}{env_dir}" if os.path.exists(output_dir): # if directory does already exist, delete os.system(f"rm -rf {output_dir}") # move to cleanup? os.mkdir(output_dir) gas_sim_dir = f"{self.settings['gaden_env_dir']}{env_dir}/gas_simulations/" current_dir = glob.glob(f"{gas_sim_dir}*/*/") # ! assuming there is only one sim case and one scenario files = os.listdir(current_dir[0]) iterations = [str(item) for item in [x for x in files if 'wind' not in x]] # exclude 'wind' directory for iteration in iterations: filename = f"{current_dir[0]}{iteration}" header, filaments = read_gas_data(filename) output_file = f"{output_dir}/{iteration}" np.save(f"{output_file}_head.npy", header) np.save(f"{output_file}_fil.npy", filaments) if savetxt: np.savetxt(f"{output_file}_head.txt", header, delimiter='\n') np.savetxt(f"{output_file}_fil.txt", filaments) self.printGDMStyle(f"[AutoGDM2] Converdted gas dispersal data to numpy...") def windfields_binary2npy(self): for env_dir in self.env_lst: wind_sim_dir = f"{self.settings['gaden_env_dir']}{env_dir}/gas_simulations/" files = glob.glob(f"{wind_sim_dir}*/*/wind/*") # ! assuming there is only one sim case and one scenario windfields = read_wind_data(files) output_file = f"{self.settings['wind_data_dir']}/{env_dir}.npy" np.save(output_file, windfields) self.printGDMStyle(f"[AutoGDM2] Converted wind data data to numpy...") def occupancy_csv2npy(self): for env_dir in self.env_lst: file = f"{self.settings['gaden_env_dir']}{env_dir}/OccupancyGrid3D.csv" header, occ_grid = read_occ_csv(file) output_file = f"{self.settings['occ_data_dir']}/{env_dir}_grid.npy" np.save(output_file, occ_grid) with open(f"{self.settings['occ_data_dir']}/{env_dir}_head.txt", 'w') as convert_file: convert_file.write(json.dumps(header)) self.printGDMStyle(f"[AutoGDM2] Converting occupancy data data to numpy...") if __name__ == "__main__": start_time = datetime.now() conf = GDMConfig() settings = conf.current_gdm_settings() gdm = AutoGDM2(conf.current_gdm_settings()) gdm.printGDMStyle(f"[AutoGDM2] --- CONFIG --- \n {conf.pretty(settings)}") gdm.cleanup() # clean AutoGDM directories and files gdm.layout_gen() # create recipes for the desired environments gdm.blender_asset_placer() # create .stl files of the mockup scenes used for cfd and GADEN gdm.isaac_asset_placer() # create .usd scenes for use in Isaac Sim gdm.cfd_mesh() # mesh the generated .stl files gdm.cfd_set_params() # set the necessary cfd parameters gdm.cfd_run() # run the cfd simulation gdm.make_ros_folder() # make ROS directories to run GADEN gdm.prep_ros() # prepare ROS directory with environment-specific configurations gdm.run_preprocessing() # roslaunch GADEN preprocessing gdm.run_ros() # roslaunch GADEN gas simulator gdm.gasdata_binary2npy() # convert the generated gasdata to .npy and save in ./environemnts/gas_data/ gdm.windfields_binary2npy() # convert the generated windata to .npy and save in ./environments/wind_data/ gdm.occupancy_csv2npy() # convert the generated occupancy grid .csv to .npy and a header, save in ./environments/occupancy/ gdm.printGDMStyle(f"[AutoGDM2] FINISEHD: Generated {settings['env_amount']} {settings['env_type']} environments in: \n {datetime.now() - start_time}") if gdm.env_lst_failed: gdm.printGDMStyle(f"[AUtoGDM2] Some environments failed and were not completed: \n {gdm.env_lst_failed}")
28,382
Python
49.683928
219
0.559968
tudelft/autoGDMplus/blender_asset_placer.py
### blender_asset_placer.py ### imports recipe dict and exports scene ### H. Erwich ### 23-05-2023 import sys # get recipe and mockup scene dir argv = sys.argv argv = argv[argv.index("--") + 1:] # get all the args after " -- " recipe_dir = argv[0] # recipe folder geometry_dir = argv[1] # blender export folder import bpy import os import glob import json import random import numpy as np class Utils: # Useful utilities and shortcuts def __init__(self): self.blend_file_path = bpy.data.filepath self.directory = os.path.dirname(self.blend_file_path) def get_asset_name(self, path_str): asset_name = path_str.rsplit('/', 1)[-1][:-4] #returns object name, [:-4] to remove .usd/.obj return asset_name def usd_import(self, filepath, scale=0.01): bpy.ops.wm.usd_import(filepath=filepath, scale=scale) #import .usd file, scale set for correct import def set_active_ob(self, asset_str): ob = bpy.context.scene.objects[asset_str] # Get the object bpy.ops.object.select_all(action='DESELECT') # Deselect all objects bpy.context.view_layer.objects.active = ob # Make the object the active object ob.select_set(True) # Select the object def delete_all(self): bpy.ops.object.select_all(action='SELECT') bpy.ops.object.delete(use_global=False) def get_ob_dimensions(self): return bpy.context.object.dimensions def obj_import(self, filepath): bpy.ops.wm.obj_import(filepath=filepath) def obj_export(self, filename): target_file = os.path.join(self.directory, str(filename)) bpy.ops.export_scene.obj(filepath=target_file, check_existing=False, axis_forward='Y', axis_up='Z') # orientation set to match the axis system in paraview def stl_export(self, filename, selection=False, text=True): target_file = os.path.join(self.directory, str(filename)) bpy.ops.export_mesh.stl(filepath=target_file, check_existing=False, use_selection=selection, ascii=text, # required to combine them with the cat command axis_forward='Y', axis_up='Z') def place_boundary_cube(self, scale): bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align='WORLD', location=(0.5*scale[0], 0.5*scale[1], 0.5*scale[2]), scale=(0.5*scale[0], 0.5*scale[1], 0.5*scale[2])) def translate(self, position): bpy.ops.transform.translate(value=(position[0], position[1], position[2]), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, True, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, snap=False, snap_elements={'INCREMENT'}, use_snap_project=False, snap_target='CLOSEST', use_snap_self=True, use_snap_edit=True, use_snap_nonedit=True, use_snap_selectable=False, release_confirm=True) def rotate(self, degrees): bpy.context.active_object.rotation_euler[0] = np.radians(degrees[0]) bpy.context.active_object.rotation_euler[1] = np.radians(degrees[1]) bpy.context.active_object.rotation_euler[2] = np.radians(degrees[2]) def rotate2(self, degrees): bpy.ops.transform.rotate(value=np.radians(degrees[0]), orient_axis='X') # TODO: check if other axis also need sign change bpy.ops.transform.rotate(value=np.radians(degrees[1]), orient_axis='Y') bpy.ops.transform.rotate(value=np.radians(-degrees[2]), orient_axis='Z') # minus to match transform function function in isaac sim def scale(self, scale): bpy.context.active_object.scale[0] = 0.5*scale[0] bpy.context.active_object.scale[1] = 0.5*scale[1] bpy.context.active_object.scale[2] = 0.5*scale[2] # def apply_modifiers(obj): # ctx = bpy.context.copy() # ctx['object'] = obj # for _, m in enumerate(obj.modifiers): # try: # ctx['modifier'] = m # bpy.ops.object.modifier_apply(ctx, modifier=m.name) # except RuntimeError: # print(f"Error applying {m.name} to {obj.name}, removing it instead.") # obj.modifiers.remove(m) # for m in obj.modifiers: # obj.modifiers.remove(m) ################################################################## ############################# MAIN ############################### ################################################################## u = Utils() u.delete_all() # deletes default objects in the scene recipes = glob.glob(f"{recipe_dir}*.txt") # gather all recipes # build each recipe for rec_loc in recipes: u.delete_all() # reading the recipe from the file with open(rec_loc) as f: data = f.read() recipe = json.loads(data) # reconstructing the data as a dictionary # create mesh geometry and gaden geometry directory if it does not exist already mesh_dir = f"{geometry_dir}{recipe['env_type']}_{recipe['env_id']}/mesh/" gaden_dir = f"{geometry_dir}{recipe['env_type']}_{recipe['env_id']}/gaden/" os.makedirs(mesh_dir, exist_ok=True) os.makedirs(gaden_dir, exist_ok=True) # place boundaries and export for plane in recipe["sides"]: bpy.ops.mesh.primitive_plane_add(enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1)) for obj in bpy.context.selected_objects: # rename object with asset id obj.name = plane["asset_id"] u.scale(plane["dimensions"]) u.rotate(plane["orientation"]) u.translate(plane["location"]) u.stl_export(f"{mesh_dir}/sides.stl") # place inlet and export u.delete_all() for plane in recipe["inlets"]: bpy.ops.mesh.primitive_plane_add(enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1)) for obj in bpy.context.selected_objects: # rename object with asset id obj.name = plane["asset_id"] u.scale(plane["dimensions"]) u.rotate(plane["orientation"]) u.translate(plane["location"]) u.stl_export(f"{mesh_dir}/inlet.stl") # place outlet and export u.delete_all() for plane in recipe["outlets"]: bpy.ops.mesh.primitive_plane_add(enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1)) for obj in bpy.context.selected_objects: # rename object with asset id obj.name = plane["asset_id"] u.scale(plane["dimensions"]) u.rotate(plane["orientation"]) u.translate(plane["location"]) u.stl_export(f"{mesh_dir}/outlet.stl") # place interior and export u.delete_all() for asset in recipe["interior"]: u.obj_import(asset["mockup_file"]) for obj in bpy.context.selected_objects: # rename object with asset id obj.name = asset["asset_id"] u.rotate2(asset["orientation"]) u.translate(asset["location"]) # translate object to specified location# u.stl_export(f"{mesh_dir}/interior.stl") u.stl_export(f"{gaden_dir}/interior_ascii.stl") u.stl_export(f"{gaden_dir}/interior_binary.stl",text=False) # gaden only geometry u.delete_all() for cube in recipe["gaden_geom"]: bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1)) for obj in bpy.context.selected_objects: # rename object with asset id obj.name = cube["asset_id"] u.scale(cube["dimensions"]) u.rotate(cube["orientation"]) u.translate(cube["location"]) if 'wall' not in cube["asset_id"]: u.stl_export(f"{gaden_dir}/{cube['asset_id']}_ascii.stl",selection=True) u.stl_export(f"{gaden_dir}/{cube['asset_id']}_binary.stl",selection=True, text=False) elif 'inside' not in cube["asset_id"]: #TODO inside is still being exported? u.stl_export(f"{gaden_dir}/{cube['asset_id']}_ascii.stl",selection=True) u.stl_export(f"{gaden_dir}/{cube['asset_id']}_binary.stl",selection=True, text=False) # gaden boolean operations objects = bpy.data.objects for i,booldict in enumerate(recipe["gaden_bools"]): #bool_op = objects['walls'].modifiers.new(type="BOOLEAN", name=f"bool_{i}") bool_op = objects[booldict[0]["asset_id"]].modifiers.new(type="BOOLEAN", name=f"bool_{i}") bool_op.object = objects[str(booldict[1]["asset_id"])] bool_op.operation = booldict[2] u.set_active_ob('walls') u.stl_export(f"{gaden_dir}/walls_ascii.stl",selection=True) u.stl_export(f"{gaden_dir}/walls_binary.stl",selection=True, text=False) u.delete_all()
9,840
Python
44.35023
138
0.560264
tudelft/autoGDMplus/utils.py
import yaml import json import os import math import csv import zlib from typing import Tuple import numpy as np from datetime import datetime from pathlib import Path HOME_DIR = Path.home() main_path = os.path.abspath(__file__) AutoGDM2_dir = os.path.dirname(main_path) class GDMConfig: def __init__(self): self.HOME_DIR = Path.home() self.main_path = os.path.abspath(__file__) self.AutoGDM2_dir = os.path.dirname(main_path) self.config_dir = f'{self.AutoGDM2_dir}/config/' self.gdm_settings = {} # dict with all the AutoGDM settings self.sim_settings = {} # dict with all the Isaac Sim/Pegasus settings def get_current_yaml(self): with open(f'{self.config_dir}current.yaml', 'r') as file: return yaml.safe_load(file) def get_default_yaml(self): with open(f'{self.config_dir}default.yaml', 'r') as file: return yaml.safe_load(file) def set_directory_params(self, yamldict:dict) -> None: # directory names self.gdm_settings["asset_dir"] = yamldict["directories"]["asset_dir"].format(HOME_DIR=self.HOME_DIR) self.gdm_settings["config_dir"] = yamldict["directories"]["config_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["asset_mockup_dir"] = yamldict["directories"]["asset_mockup_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["asset_custom_dir"] = yamldict["directories"]["asset_custom_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["recipe_dir"] = yamldict["directories"]["recipe_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["usd_scene_dir"] = yamldict["directories"]["usd_scene_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["geometry_dir"] = yamldict["directories"]["geometry_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["cfd_dir"] = yamldict["directories"]["cfd_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["gas_data_dir"] = yamldict["directories"]["gas_data_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["wind_data_dir"] = yamldict["directories"]["wind_data_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["occ_data_dir"] = yamldict["directories"]["occ_data_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["empty_ros_dir"] = yamldict["directories"]["empty_ros_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) self.gdm_settings["gaden_env_dir"] = yamldict["directories"]["gaden_env_dir"].format(AutoGDM2_dir=self.AutoGDM2_dir) def set_application_params(self, yamldict:dict) -> None: # applications self.gdm_settings["ISAAC_VERSION"] = yamldict["software"]["isaac_sim"]["version"] self.gdm_settings["isaac_dir"] = yamldict["software"]["isaac_sim"]["isaac_dir"].format(HOME_DIR=self.HOME_DIR, ISAAC_VERSION=self.gdm_settings["ISAAC_VERSION"]) self.gdm_settings["wh_gen_dir"] = yamldict["software"]["isaac_sim"]["wh_gen_dir"].format(isaac_dir=self.gdm_settings["isaac_dir"]) self.gdm_settings["BLENDER_VERSION"] = yamldict["software"]["blender"]["version"] self.gdm_settings["blender_dir"] = yamldict["software"]["blender"]["blender_dir"].format(HOME_DIR=self.HOME_DIR, BLENDER_VERSION=self.gdm_settings["BLENDER_VERSION"]) self.gdm_settings["OPENFOAM_VERSION"] = yamldict["software"]["openfoam"]["version"] self.gdm_settings["openfoam_dir"] = yamldict["software"]["openfoam"]["openfoam_dir"].format(HOME_DIR=self.HOME_DIR, OPENFOAM_VERSION=self.gdm_settings["OPENFOAM_VERSION"]) def set_environment_params(self, yamldict:dict) -> None: # environment(s) self.gdm_settings["env_types"] = yamldict["environment"]["env_types"] self.gdm_settings["env_type"] = self.gdm_settings["env_types"][yamldict["environment"]["env_type"]] self.gdm_settings["env_amount"] = yamldict["environment"]["env_amount"] self.gdm_settings["env_size"] = yamldict["environment"]["env_size"] self.gdm_settings["env_list"] = [f"{self.gdm_settings['env_type']}_{str(i).zfill(4)}" for i in range(self.gdm_settings['env_amount'])] # if self.gdm_settings["env_type"] == 'wh_empty' or self.gdm_settings["env_type"] == 'wh_simple': self.gdm_settings["inlet_size"] = yamldict["env_wh"]["inlet_size"] self.gdm_settings["inlet_vel"] = yamldict["env_wh"]["inlet_vel"] self.gdm_settings["outlet_size"] = yamldict["env_wh"]["outlet_size"] self.gdm_settings["emptyfullrackdiv"] = yamldict["env_wh"]["emptyfullrackdiv"] self.gdm_settings["white_walls"] = yamldict["env_wh"]["white_walls"] def set_cfd_params(self,yamldict:dict) -> None: # cfd mesh settings self.gdm_settings["cfd_mesh_settings"] = { "minCellSize": yamldict["cfd"]["mesh"]["minCellSize"], "maxCellSize": yamldict["cfd"]["mesh"]["maxCellSize"], "boundaryCellSize": yamldict["cfd"]["mesh"]["boundaryCellSize"], "localRefinement": yamldict["cfd"]["mesh"]["localRefinement"], } # threads used for solving if yamldict["cfd"]["solving"]["threads"] == 0: threads = len(os.sched_getaffinity(0)) - 2 else: threads = yamldict["cfd"]["solving"]["threads"] # relevant cfd solver settings cfd_k = round(1.5 * (0.05 * math.hypot(self.gdm_settings["inlet_vel"][0],self.gdm_settings["inlet_vel"][1],self.gdm_settings["inlet_vel"][2]))**2,6) # turbulent kinetic energy cfd_epsilon = round((0.09**0.75 * cfd_k**1.5)/(0.1*self.gdm_settings["inlet_size"][0]),6) # dissipation rate self.gdm_settings["cfd_settings"] = { "threads": threads, "endTime": yamldict["cfd"]["solving"]["endTime"], "writeInterval": yamldict["cfd"]["solving"]["writeInterval"], "maxCo": yamldict["cfd"]["solving"]["maxCo"], "maxDeltaT": yamldict["cfd"]["solving"]["maxDeltaT"], "nOuterCorrectors": yamldict["cfd"]["solving"]["nOuterCorrectors"], "k": cfd_k, "epsilon": cfd_epsilon, "latestTime": yamldict["cfd"]["solving"]["latestTime"], "timeRange": yamldict["cfd"]["solving"]["timeRange"] } def set_gas_dispersal_params(self, yamldict:dict) -> None: # gas dispersal settings self.gdm_settings["src_placement_types"] = yamldict["gas_dispersal"]["src_placement_types"] self.gdm_settings["src_placement_type"] = self.gdm_settings["src_placement_types"][yamldict["gas_dispersal"]["src_placement_type"]] self.gdm_settings["src_placement"] = yamldict["gas_dispersal"]["src_placement"] # TODO: add if statement for random settings self.gdm_settings["gas_type"] = yamldict["gas_dispersal"]["gas_type"] self.gdm_settings["sim_time"] = yamldict["gas_dispersal"]["sim_time"] self.gdm_settings["time_step"] = yamldict["gas_dispersal"]["time_step"] self.gdm_settings["wind_looping"] = yamldict["gas_dispersal"]["wind_looping"] self.gdm_settings["wind_start_step"] = yamldict["gas_dispersal"]["wind_start_step"] self.gdm_settings["wind_stop_step"] = yamldict["gas_dispersal"]["wind_stop_step"] def set_asset_params(self, yamldict: dict) -> None: # assets assets = yamldict["assets"] # 'repair' the 'f-strings' assets["empty_racks"] = assets["empty_racks"].format(asset_dir=self.gdm_settings["asset_dir"]) assets["filled_racks"] = assets["filled_racks"].format(asset_dir=self.gdm_settings["asset_dir"]) assets["piles"] = assets["piles"].format(asset_dir=self.gdm_settings["asset_dir"]) assets["railings"] = assets["railings"].format(asset_dir=self.gdm_settings["asset_dir"]) assets["isaac_wh_props"] = assets["isaac_wh_props"].format(HOME_DIR=self.HOME_DIR) assets["isaac_custom"] = assets["isaac_custom"].format(asset_custom_dir=self.gdm_settings["asset_custom_dir"]) assets["forklift"] = assets["forklift_asset"].format(HOME_DIR=self.HOME_DIR) assets["empty_racks_mockup"] = assets["empty_racks_mockup"].format(asset_mockup_dir=self.gdm_settings["asset_mockup_dir"]) assets["filled_racks_mockup"] = assets["filled_racks_mockup"].format(asset_mockup_dir=self.gdm_settings["asset_mockup_dir"]) assets["forklift_mockup"] = assets["forklift_mockup"].format(asset_mockup_dir=self.gdm_settings["asset_mockup_dir"]) assets["piles_mockup"] = assets["piles_mockup"].format(asset_mockup_dir=self.gdm_settings["asset_mockup_dir"]) self.gdm_settings["assets"] = assets # pairs of filelocations of assets and their corresponding mockups self.gdm_settings["file_loc_paired"] = { "filled_racks": [[assets["filled_racks"] + assets["filled_racks_long_asset"][0], assets["filled_racks_mockup"] + assets["filled_racks_long_asset_mockup"]], [assets["filled_racks"] + assets["filled_racks_long_asset"][1], assets["filled_racks_mockup"] + assets["filled_racks_long_asset_mockup"]], [assets["filled_racks"] + assets["filled_racks_long_asset"][2], assets["filled_racks_mockup"] + assets["filled_racks_long_asset_mockup"]], [assets["filled_racks"] + assets["filled_racks_long_asset"][3], assets["filled_racks_mockup"] + assets["filled_racks_long_asset_mockup"]], [assets["filled_racks"] + assets["filled_racks_long_asset"][4], assets["filled_racks_mockup"] + assets["filled_racks_long_asset_mockup"]], [assets["filled_racks"] + assets["filled_racks_long_asset"][5], assets["filled_racks_mockup"] + assets["filled_racks_long_asset_mockup"]], [assets["filled_racks"] + assets["filled_racks_long_asset"][6], assets["filled_racks_mockup"] + assets["filled_racks_long_asset_mockup"]]], "empty_racks": [[assets["empty_racks"] + assets["empty_racks_long_asset"][0], assets["empty_racks_mockup"] + assets["empty_racks_long_asset_mockup"][0]], [assets["empty_racks"] + assets["empty_racks_long_asset"][1], assets["empty_racks_mockup"] + assets["empty_racks_long_asset_mockup"][1]]], "piles": [[assets["piles"] + assets["piles_asset"][3], assets["piles_mockup"] + assets["piles_asset_mockup"][0]], # WarehousePile_A4 [assets["piles"] + assets["piles_asset"][4], assets["piles_mockup"] + assets["piles_asset_mockup"][1]], # WarehousePile_A5 [assets["piles"] + assets["piles_asset"][6], assets["piles_mockup"] + assets["piles_asset_mockup"][2]]], # WarehousePile_A7 "floors": [[assets["isaac_wh_props"] + assets["floor"], None]], "walls": [[assets["isaac_wh_props"] + assets["walls"][0], None], [assets["isaac_wh_props"] + assets["walls"][1], None], [assets["isaac_wh_props"] + assets["walls"][2], None], [assets["isaac_wh_props"] + assets["walls"][3], None],], "lights": [[assets["isaac_wh_props"] + assets["lights"][0], None], [assets["isaac_custom"] + assets["lights"][1], None]], "forklift": [[assets["forklift"], assets["forklift_mockup"] + assets["forklift_asset_mockup"]]], } def pretty(self, conf:dict) -> str: return json.dumps(conf, indent=2) def save_gdm_settings(self, comment:str='') -> None: if comment: filename = f'{datetime.now().strftime("%Y-%m-%d")}_{datetime.now().strftime("%H:%M:%S")}_{comment}' else: filename = f'{datetime.now().strftime("%Y-%m-%d")}_{datetime.now().strftime("%H:%M:%S")}' with open(f'{self.config_dir}{filename}.yaml', 'w') as file: yaml.dump(self.gdm_settings, file) file.close() def set_gdm_params(self, yamldict:dict) -> None: self.set_directory_params(yamldict) self.set_application_params(yamldict) self.set_environment_params(yamldict) self.set_cfd_params(yamldict) self.set_gas_dispersal_params(yamldict) self.set_asset_params(yamldict) def current_gdm_settings(self) -> dict: yamldict = self.get_current_yaml() self.set_gdm_params(yamldict) self.save_gdm_settings(yamldict["comment"]) return self.gdm_settings def default_gdm_settings(self) -> dict: yamldict = self.get_default_yaml() self.set_gdm_params(yamldict) self.save_gdm_settings(yamldict["comment"]) return self.gdm_settings # TODO improve this implementation # simple ( probably unnecessary ) class to store a timestep () class flow_field: def __init__(self,id): self.id = id def is_float(element:any) -> bool: #If you expect None to be passed: if element is None: return False try: float(element) return True except ValueError: return False # reads compressed gas data def read_gas_data(file_path) -> Tuple[np.ndarray,np.ndarray]: with open(file_path, 'rb') as file: compressed_data = file.read() # first decompress the file decompressed_data = zlib.decompress(compressed_data) # header datatype header_dtype = np.dtype([('h', np.uint32), ('env_min_x', np.float64), ('env_min_y', np.float64), ('env_min_z', np.float64), ('env_max_x', np.float64), ('env_max_y', np.float64), ('env_max_z', np.float64), ('env_cells_x', np.uint32), ('env_cells_y', np.uint32), ('env_cells_z', np.uint32), ('cell_size_x', np.float64), ('cell_size_y', np.float64), ('cell_size_z', np.float64), ('gas_source_pos_x', np.float64), ('gas_source_pos_y', np.float64), ('gas_source_pos_z', np.float64), ('gas_type', np.uint32), ('filament_num_moles_of_gas', np.float64), ('num_moles_all_gases_in_cm3', np.float64), ('binary_bool', np.uint32)]) # filament datatype filament_dtype = np.dtype([('id', np.uint32), ('pose_x', np.float64), ('pose_y', np.float64), ('pose_z', np.float64), ('sigma', np.float64)]) # TODO - combine all gas iterations into one array for a potential speed increase # read data from buffer filament_header = np.frombuffer(decompressed_data, dtype=header_dtype, count=1) filament_data = np.frombuffer(decompressed_data, dtype=filament_dtype, offset=header_dtype.itemsize) # return the extracted data return filament_header, filament_data def read_wind_data(file_paths) -> np.ndarray: windfields_lst = [] # read files and put into list for file_path in file_paths: with open(file_path, 'rb') as file: data = file.read() UVW = np.split(np.frombuffer(data, dtype=np.float64), 3) wind_vectors = np.zeros((np.shape(UVW)[1],3)) wind_vectors[:,0] = UVW[0] wind_vectors[:,1] = UVW[1] wind_vectors[:,2] = UVW[2] windfields_lst.append(wind_vectors) windfields_arr = np.zeros((len(file_paths), np.shape(windfields_lst[0])[0], 3)) # puts lists into one array for i, windfield in enumerate(windfields_lst): windfields_arr[i] = windfield # return the extracted data return windfields_arr def read_occ_csv(filepath) -> Tuple[dict,np.ndarray]: header = {} with open(filepath, 'r') as csv_file: csv_lst = list(csv.reader(csv_file)) # extract header info header['env_min'] = [float(j) for j in csv_lst[0][0].split(" ")[1:]] header['env_max'] = [float(j) for j in csv_lst[1][0].split(" ")[1:]] header['num_cells'] = [int(j) for j in csv_lst[2][0].split(" ")[1:]] header['cell_size'] = float(csv_lst[3][0].split(" ")[1:][0]) occ_arr = np.zeros((header['num_cells'][2], header['num_cells'][0], header['num_cells'][1]), dtype=int) for z_it in range(header['num_cells'][2]): x_it = 0 while True: row = csv_lst[(4 + z_it*(header['num_cells'][0]+1)) + x_it][0] if row == ';': break occ_arr[z_it,x_it,:] = [int(j) for j in row.split(" ")[:-1]] x_it += 1 return header, occ_arr
17,448
Python
51.875757
185
0.579207
tudelft/autoGDMplus/layout_gen.py
# Top level layout generator following the Isaac Sim Warehouse generator format import json import random import numpy as np from typing import Tuple # TODO: remove member functions such as dx(), dy(), etc. and change them to attributes class Asset: def __init__(self, assetname:str = "Asset", fname:list = [None, None], # [isaac_sim_asset, mockup_file] dims:np.ndarray = np.zeros(3), loc:np.ndarray = np.zeros(3), ori:np.ndarray = np.zeros(3), scale:np.ndarray = np.ones(3) ) -> None: self.id = assetname self.fname = fname # [isaac_sim_asset, mockup_file] self.dims = dims self.ctr = 0.5*dims self.loc = loc self.ori = ori self.scale = scale def assetname(self) -> str: return self.id def set_assetname(self, assetname:str) -> None: self.id = assetname return def set_fname(self, fname:list) -> None: self.fname = fname return def dimensions(self) -> np.ndarray: return self.dims def set_dimensions(self, dims:np.ndarray=np.zeros(3)) -> None: self.dims = dims return def dx(self) -> float: return self.dims[0] def dy(self) -> float: return self.dims[1] def dz(self) -> float: return self.dims[2] def center(self) -> np.ndarray: return self.ctr def cx(self) -> float: return self.ctr[0] def cy(self) -> float: return self.ctr[1] def cz(self) -> float: return self.ctr[2] def location(self) -> np.ndarray: return self.loc def lx(self) -> float: return self.loc[0] def ly(self) -> float: return self.loc[1] def lz(self) -> float: return self.loc[2] def set_location(self, loc:np.ndarray) -> None: self.loc = loc return def translate(self, axis:str, amount:float) -> None: if axis == 'X': self.loc[0] = amount if axis == 'Y': self.loc[1] = amount if axis == 'Z': self.loc[2] = amount def set_orientation(self, ori:np.ndarray) -> None: self.ori = ori return def set_scale(self, scale:np.ndarray) -> None: self.scale = scale return def get_dict(self) -> dict: assetdict = { "asset_id": self.id, "filename": self.fname[0], "mockup_file": self.fname[1], "dimensions": self.dims.tolist(), "location": self.loc.tolist(), "orientation": self.ori.tolist(), "scale": self.scale.tolist() } return assetdict class Warehouse: def __init__(self, settings:dict, wh_dims:np.ndarray = np.array([10.0, 15.0, 9.0]), inlet_dims:np.ndarray = np.array([0.0,4.0,4.0]), outlet_dims:np.ndarray = np.array([0.0,4.0,4.0])): self.settings = settings self.warehouse = Asset("warehouse_shell", dims=wh_dims) self.floor = Asset("floor", fname=self.settings['file_loc_paired']["floors"][0], dims=np.array([6.0, 6.0, 0.0])) self.cornerwall = Asset("cornerwall", dims=np.array([3.0,3.0,3.0])) self.wall = Asset("wall", dims=np.array([0.0,6.0,3.0])) self.prop_light = Asset("prop_light", dims=np.array([2.0, 0.3, 3.0])) self.rect_light = Asset("rect_light", dims=np.array([self.warehouse.dx(), self.warehouse.dy(), 0.0])) self.rack = Asset("rack", dims=np.array([1.0, 4.0, 3.0])) # default size of rack models self.rack_aisle = Asset("rack_aisle", dims=np.array([3.0, 0.0, 0.0])) self.end_aisle = Asset("end_aisle", dims=np.array([0.0, (max(inlet_dims[1], outlet_dims[1]) + 2), 0.0])) self.forklift = Asset("forklift", fname=self.settings['file_loc_paired']['forklift'][0], dims=np.array([0.8,1.0,2.0])) self.pile = Asset("pile") self.inlet = Asset("inlet", dims=inlet_dims) self.outlet = Asset("outlet", dims=outlet_dims) # returns arrays of rack positions (centered for each rack) def rack_positions(self) -> np.ndarray: rack_orig = np.array([self.rack.cx(), self.rack.cy() + self.end_aisle.dy(), 0.0]) # origin of rack array rack_rows = int(1 + (self.warehouse.dx()-self.rack.dx()) // (self.rack.dx() + self.rack_aisle.dx())) rack_segs = int((self.warehouse.dy() - (2 * self.end_aisle.dy())) // self.rack.dy()) rack_stack= int((self.warehouse.dz()) // self.rack.dz()) # height nx, ny, nz = rack_rows, rack_segs, rack_stack x = np.linspace(rack_orig[0], self.warehouse.dx() - 0.5 * self.rack.dx(), nx) y = np.linspace(rack_orig[1], rack_orig[1] + (self.rack.dy() * (ny-1)), ny) z = np.arange(rack_orig[2], self.rack.dz() * nz, self.rack.dz()) xv, yv, zv = np.meshgrid(x,y,z) # generate grid and reshape array for ease of use stack = np.stack([xv, yv, zv], -1) positions = stack.reshape(np.prod(stack.shape[0:-1]),3) return positions # divides positions, affects empty/filled rack ratio def position_division(self, divisor:float ,positions:np.ndarray=np.zeros(3)) -> np.ndarray: totalSample = positions.shape[0] minSample = int((totalSample//(divisor**-1))) sampleSize = np.random.randint(minSample,totalSample) idx = random.sample(range(totalSample),sampleSize) filledRackPos, emptyRackPos = positions[idx,:], np.delete(positions, idx, 0) return filledRackPos, emptyRackPos # TODO - hardcoded for now, make scalable def complex_positions(self) -> np.ndarray: edge_dist = 2.0 x = np.linspace(edge_dist, (15-edge_dist), 4) y = np.linspace(1.5, (15-1.5), 4) positions = np.array([[x[0], y[0], 0.0], [x[0], y[1], 0.0], [x[0], y[2], 0.0], [x[0], y[3], 0.0], [x[1], y[3], 0.0], [x[2], y[3], 0.0], [x[3], y[3], 0.0], [x[3], y[2], 0.0], [x[3], y[1], 0.0], [x[3], y[0], 0.0], [x[2], y[0], 0.0], [x[1], y[0], 0.0]]) return positions # interior dict generation def interior_gen(self, filled:np.ndarray, empty:np.ndarray, comp_loc:np.ndarray=None) -> list: interior_dicts = [] scale_factor = np.array([0.01, 0.01, 0.01]) # custom scaling factor # filled racks for i,loc in enumerate(filled): self.rack.set_assetname(f"filled_rack_{str(i).zfill(3)}") self.rack.set_fname(random.choice(self.settings['file_loc_paired']["filled_racks"])) # choose random type of rack and corresponding mockup self.rack.set_orientation(np.zeros(3,)) self.rack.set_location(loc) self.rack.set_scale(scale_factor) if comp_loc is not None and loc[0] > 1.0 and loc[0] < 14.0: # TODO : remove hardcoded orientation self.rack.set_orientation(np.array([0,0,90])) interior_dicts.append(self.rack.get_dict()) # empty racks for i,loc in enumerate(empty): self.rack.set_assetname(f"empty_rack_{str(i).zfill(3)}") self.rack.set_fname(random.choice(self.settings['file_loc_paired']["empty_racks"])) # choose random type of rack and corresponding mockup self.rack.set_orientation(np.zeros(3,)) self.rack.set_location(loc) self.rack.set_scale(scale_factor) if comp_loc is not None and loc[0] > 1.0 and loc[0] < 14.0: # TODO : remove hardcoded orientation self.rack.set_orientation(np.array([0,0,90])) interior_dicts.append(self.rack.get_dict()) if comp_loc is not None: # get 4 random indices idx = np.random.choice(11, 6, replace=False) forklift_idx = idx[0] piles_idx = idx[1:] # add forklift to dict self.forklift.set_location(comp_loc[forklift_idx]) self.forklift.set_orientation(np.array([0.0,0.0,np.random.randint(0,359)])) self.forklift.set_scale(scale_factor) interior_dicts.append(self.forklift.get_dict()) # add piles to dict for i,loc in enumerate(comp_loc[piles_idx]): self.pile.set_assetname(f"pile_{str(i).zfill(3)}") self.pile.set_fname(random.choice(self.settings['file_loc_paired']["piles"])) # choose random type of pile and corresponding mockup self.pile.set_location(loc) self.pile.set_orientation(np.array([0.0,0.0,np.random.randint(0,359)])) self.pile.set_scale(scale_factor) interior_dicts.append(self.pile.get_dict()) return interior_dicts ################ ### CFD MESH ### ################ # The CFD mesh is generated using assets that blender can place and save to .stl # sides dict generation, these are all planes def sides_blender(self) -> list: side_dicts = [] # bottom bottom = Asset("bottom",dims=np.array([self.warehouse.dx(), self.warehouse.dy(), 0.0]), loc=0.5*np.array([self.warehouse.dx(), self.warehouse.dy(), 0])) side_dicts.append(bottom.get_dict()) # top top = Asset("top",dims=np.array([self.warehouse.dx(), self.warehouse.dy(), 0.0]), loc=np.array([0.5*self.warehouse.dx(),0.5*self.warehouse.dy(), self.warehouse.dz()]), ori=np.array([180,0,0])) # important for the face normals to point inside side_dicts.append(top.get_dict()) # front front = Asset("front",dims=np.array([self.warehouse.dx(), self.warehouse.dz(), 0.0]), loc=np.array([0.5*self.warehouse.dx(),0,0.5*self.warehouse.dz()]), ori=np.array([-90,0,0])) side_dicts.append(front.get_dict()) # back back = Asset("back",dims=np.array([self.warehouse.dx(), self.warehouse.dz(), 0.0]), loc=np.array([0.5*self.warehouse.dx(),self.warehouse.dy(),0.5*self.warehouse.dz()]), ori=np.array([90,0,0])) side_dicts.append(back.get_dict()) # inlet side side1 = Asset("side_001",dims=np.array([self.warehouse.dz(), self.warehouse.dy()-self.inlet.dy(), 0.0]), loc=np.array([0.0, 0.5*(self.warehouse.dy()+self.inlet.dy()), 0.5*self.warehouse.dz()]), ori=np.array([0,90,0])) side_dicts.append(side1.get_dict()) side2 = Asset("side_002",dims=np.array([self.warehouse.dz()-self.inlet.dz(), self.inlet.dy(), 0.0]), loc=np.array([0.0, 0.5*self.inlet.dy(), 0.5*(self.warehouse.dz()+self.inlet.dz())]), ori=np.array([0,90,0])) side_dicts.append(side2.get_dict()) # oulet side side3 = Asset("side_003",dims=np.array([self.warehouse.dz(), self.warehouse.dy()-self.outlet.dy(), 0.0]), loc=np.array([self.warehouse.dx(), 0.5*(self.warehouse.dy()-self.outlet.dy()), 0.5*self.warehouse.dz()]), ori=np.array([0,-90,0])) side_dicts.append(side3.get_dict()) side4 = Asset("side_004",dims=np.array([self.warehouse.dz()-self.outlet.dz(), self.outlet.dy(), 0.0]), loc=np.array([self.warehouse.dx(), self.warehouse.dy()-0.5*self.outlet.dy(), 0.5*(self.warehouse.dz()+self.outlet.dz())]), ori=np.array([0,-90,0])) side_dicts.append(side4.get_dict()) return side_dicts def inlets_blender(self) -> list: inlet_dicts = [] inlet = Asset("inlet001",dims=np.array([self.inlet.dz(), self.inlet.dy(), 0.0]), loc=np.array([0.0, 0.5*self.inlet.dy(), 0.5*self.inlet.dz()]), ori=np.array([0,90,0])) inlet_dicts.append(inlet.get_dict()) return inlet_dicts def outlets_blender(self) -> list: outlet_dicts = [] outlet = Asset("outlet001",dims=np.array([self.outlet.dz(), self.outlet.dy(), 0.0]), loc=np.array([self.warehouse.dx(), self.warehouse.dy()-0.5*self.outlet.dy(), 0.5*self.outlet.dz()]), ori=np.array([0,-90,0])) outlet_dicts.append(outlet.get_dict()) return outlet_dicts ################ ### GADEN ### ################ # gaden requires additional geometry with thickness such as the walls, inlet and outlets # for this, blender will need to perform boolean operations # first all geometry is given. lastly, a separate dict entry is used for the boolean operations def gaden_geom(self) -> Tuple[list,list]: gaden_geom_dicts = [] gaden_bools = [] wallthickness = 0.2 walls = Asset("walls", dims=np.array([self.warehouse.dx()+2*wallthickness, self.warehouse.dy()+2*wallthickness, self.warehouse.dz()]), loc=self.warehouse.center()) gaden_geom_dicts.append(walls.get_dict()) inside = Asset("inside", dims=np.array([self.warehouse.dx(),self.warehouse.dy(),self.warehouse.dz()+1.0]), loc=self.warehouse.center()) gaden_geom_dicts.append(inside.get_dict()) inlet = Asset("inlet", dims=np.array([wallthickness+0.2, self.inlet.dy(), self.inlet.dz()]), loc=np.array([-0.5*wallthickness, 0.5*self.inlet.dy(), 0.5*self.inlet.dz()])) gaden_geom_dicts.append(inlet.get_dict()) outlet = Asset("outlet", dims=np.array([wallthickness+0.2, self.outlet.dy(), self.outlet.dz()]), loc=np.array([self.warehouse.dx()+ 0.5*wallthickness, self.warehouse.dy()-0.5*self.outlet.dy(), 0.5*self.outlet.dz()])) gaden_geom_dicts.append(outlet.get_dict()) for asset in [inside, inlet, outlet]: gaden_bools.append([walls.get_dict(), asset.get_dict(), 'DIFFERENCE']) return gaden_geom_dicts, gaden_bools ################ ### ISAAC ### ################ def isaac_floor_dicts(self) -> list: floor_orig = np.array([self.floor.cx(), self.floor.cy(), 0.0]) # origin of floor array floor_rows = int(np.ceil(self.warehouse.dx()/self.floor.dx())) # floor tile rows (round up) floor_cols = int(np.ceil(self.warehouse.dy()/self.floor.dy())) # floor tile columns (round up) nx, ny = floor_rows, floor_cols x = np.linspace(floor_orig[0], floor_orig[0] + self.floor.dx()*(nx-1), nx) y = np.linspace(floor_orig[1], floor_orig[1] + self.floor.dy()*(ny-1), ny) xv, yv = np.meshgrid(x,y) # generate grid and reshape array for ease of use zv = np.zeros_like(xv) stack = np.stack([xv, yv, zv], -1) positions = stack.reshape(np.prod(stack.shape[0:-1]),3) floor_tile_dicts = [] for i,loc in enumerate(positions): self.floor.set_assetname(f"floor_tile_{str(i).zfill(3)}") self.floor.set_location(loc) floor_tile_dicts.append(self.floor.get_dict()) return floor_tile_dicts def isaac_walls_dicts(self) -> list: walls_dicts = [] # walls are made higher than env size to accomodate the lighting ceiling_height = self.warehouse.dz() + self.prop_light.dz() # corners nz = int(np.ceil(ceiling_height/self.cornerwall.dz())) z = np.linspace(0.0, self.wall.dz() * (nz-1), nz) z[-1] = ceiling_height - self.cornerwall.dz() if self.settings["white_walls"]: walltypes = np.zeros(nz, dtype=int) # white walls only else: walltypes = np.ones(nz, dtype=int) # default white and yellow walls walltypes[0] = 0 x = np.linspace(0.0, self.warehouse.dx(), 2) y = np.linspace(0.0, self.warehouse.dy(), 2) ori = np.array([[90., 180., 0., 270.]]) xv, yv = np.meshgrid(x,y) stack = np.stack([xv, yv], -1) positions = stack.reshape((4,2)) transforms = np.hstack((positions, ori.T)) # [X Y Z-rotation] for i, (z_pos, walltype) in enumerate(zip(z, walltypes)): for j,transform in enumerate(transforms): self.cornerwall.set_assetname(f"wall_corner_{i}_{j}") self.cornerwall.set_fname(self.settings['file_loc_paired']["walls"][walltype]) self.cornerwall.set_location(np.array([transform[0], transform[1], z_pos])) self.cornerwall.set_orientation(np.array([0.0,0.0,transform[2]])) walls_dicts.append(self.cornerwall.get_dict()) # flat walls nz = int(np.ceil(ceiling_height/self.wall.dz())) z = np.linspace(0.0, self.wall.dz() * (nz-1), nz) z[-1] = ceiling_height - self.wall.dz() if self.settings["white_walls"]: walltypes = np.zeros(nz, dtype=int) # white walls only else: walltypes = np.ones(nz, dtype=int) # default white and yellow walls walltypes[0] = 0 # check if additional walls are needed for x direction if self.warehouse.dx() > (2 * self.cornerwall.dx()): # walls in x-dir nx = int(np.ceil((self.warehouse.dx()-(2*self.cornerwall.dx()))/self.wall.dy())) x = np.linspace(self.cornerwall.dx() + self.wall.cy(), self.warehouse.dx() - (self.cornerwall.dx() + self.wall.cy()), nx) y = np.linspace(0.0, self.warehouse.dy(), 2) ori = np.linspace(90.0, -90.0, 2) for i, (z_pos, walltype) in enumerate(zip(z, walltypes)): for j, (y_pos, orientation) in enumerate(zip(y, ori)): for k, x_pos in enumerate(x): self.wall.set_assetname(f"wallX_{i}_{k}_{j}") self.wall.set_fname(self.settings['file_loc_paired']["walls"][2+walltype]) self.wall.set_location(np.array([x_pos, y_pos, z_pos])) self.wall.set_orientation(np.array([0.0, 0.0, orientation])) walls_dicts.append(self.wall.get_dict()) # check if additional walls are needed for y direction if self.warehouse.dy() > (2 * self.cornerwall.dy()): # walls in y-dir ny = int(np.ceil((self.warehouse.dy()-(2*self.cornerwall.dy()))/self.wall.dy())) y = np.linspace(self.cornerwall.dy() + self.wall.cy(), self.warehouse.dy() - (self.cornerwall.dy() + self.wall.cy()), ny) x = np.linspace(0.0, self.warehouse.dx(), 2) ori = np.linspace(0.0, 180, 2) for i, (z_pos, walltype) in enumerate(zip(z, walltypes)): for j, (x_pos, orientation) in enumerate(zip(x, ori)): for k, y_pos in enumerate(y): self.wall.set_assetname(f"wallY_{i}_{k}_{j}") self.wall.set_fname(self.settings['file_loc_paired']["walls"][2+walltype]) self.wall.set_location(np.array([x_pos, y_pos, z_pos])) self.wall.set_orientation(np.array([0.0, 0.0, orientation])) walls_dicts.append(self.wall.get_dict()) return walls_dicts def isaac_lights_dicts(self) -> list: prop_lights_dicts = [] # rect_lights_dicts = [] z_rect_light = self.warehouse.dz() z_lights = z_rect_light + self.prop_light.dz() spacing_xy = [2.5, 4.0] # decorative (prop) lights nx = int(np.ceil(((self.warehouse.dx()-(2*spacing_xy[0]))/spacing_xy[0]))) ny = int(np.ceil(((self.warehouse.dy()-(2*spacing_xy[1]))/spacing_xy[1]))) x = np.linspace(spacing_xy[0], self.warehouse.dx()-spacing_xy[0], nx) y = np.linspace(spacing_xy[1], self.warehouse.dy()-spacing_xy[1], ny) xv, yv = np.meshgrid(x,y) # generate grid and reshape array for ease of use zv = z_lights * np.ones_like(xv) stack = np.stack([xv, yv, zv], -1) positions = stack.reshape(np.prod(stack.shape[0:-1]),3) for i, pos in enumerate(positions): self.prop_light.set_assetname(f"light_{str(i).zfill(3)}") self.prop_light.set_fname(self.settings['file_loc_paired']["lights"][1]) self.prop_light.set_location(np.array([pos[0], pos[1], pos[2]])) self.prop_light.set_orientation(np.array([0.0,0.0,90.0])) prop_lights_dicts.append(self.prop_light.get_dict()) # rectangular light over the whole scene TODO: Add temperature and intensity? # self.rect_light.set_location(np.array([self.warehouse.cx(), self.warehouse.cy(), z_rect_light])) # self.rect_light.set_scale(self.rect_light.dimensions()) # rect_lights_dicts.append(self.rect_light.get_dict()) return prop_lights_dicts #, rect_lights_dicts def generate_recipes(settings:dict) -> None: recipe_dict = {} if 'wh' in settings["env_type"]: recipe_dict["env_type"] = settings["env_type"] recipe_dict["env_size"] = settings["env_size"] recipe_dict["inlet_size"] = settings["inlet_size"] recipe_dict["oulet_size"] = settings["outlet_size"] for i in range(settings["env_amount"]): env_id = str(i).zfill(4) recipe_dict["env_id"] = env_id wh = Warehouse(settings, wh_dims=np.array([recipe_dict["env_size"][0], recipe_dict["env_size"][1], recipe_dict["env_size"][2]]), inlet_dims=np.array([0.0,recipe_dict["inlet_size"][0],recipe_dict["inlet_size"][1]]), outlet_dims=np.array([0.0,recipe_dict["inlet_size"][0],recipe_dict["inlet_size"][1]])) # CFD mesh geometry recipe_dict["sides"] = wh.sides_blender() recipe_dict["inlets"] = wh.inlets_blender() recipe_dict["outlets"] = wh.outlets_blender() # CFD mesh and Isaac Sim interior geometry if 'empty' in settings["env_type"]: recipe_dict["interior"] = {} else: positions = wh.rack_positions() filled_locs, empty_locs = wh.position_division(settings["emptyfullrackdiv"],positions) if 'complex' in settings["env_type"]: complex_pos = wh.complex_positions() else: complex_pos = None recipe_dict["interior"] = wh.interior_gen(filled_locs, empty_locs, comp_loc=complex_pos) # GADEN geometry recipe_dict["gaden_geom"], recipe_dict["gaden_bools"] = wh.gaden_geom() # Isaac Sim geometry recipe_dict["isaac_floor"] = wh.isaac_floor_dicts() recipe_dict["isaac_walls"] = wh.isaac_walls_dicts() recipe_dict["isaac_lights"] = wh.isaac_lights_dicts() # write dictionary with open(f'{settings["recipe_dir"]}{settings["env_type"]}_{env_id}.txt', 'w') as convert_file: convert_file.write(json.dumps(recipe_dict)) # TODO: create more environments
23,600
Python
43.530189
150
0.54822
tudelft/autoGDMplus/settings.py
import os from pathlib import Path import math HOME_DIR = Path.home() settings_path = os.path.abspath(__file__) AutoGDM2_dir = os.path.dirname(settings_path) # directory locations asset_dir = f"{HOME_DIR}/Omniverse_content/ov-industrial3dpack-01-100.1.1/" # omniverse content folder asset_mockup_dir = f"{AutoGDM2_dir}/assets/mockup/" # mockup folder with simple versions of assets recipe_dir = f"{AutoGDM2_dir}/environments/recipes/" # recipe folder usd_scene_dir = f"{AutoGDM2_dir}/environments/isaac_sim/" # isaac sim scenes location geometry_dir = f"{AutoGDM2_dir}/environments/geometry/"# geometry folder cfd_dir = f"{AutoGDM2_dir}/environments/cfd/" # cfd folder gas_data_dir = f"{AutoGDM2_dir}/environments/gas_data/"# gas data folder empty_ros_dir = f"{AutoGDM2_dir}/environments/ROS/empty_project/" gaden_env_dir = f"{AutoGDM2_dir}/gaden_ws/src/gaden/envs/" # ROS GADEN workspace # software locations # omniverse assets and Isaac Sim ISAAC_VERSION = '2022.2.0' isaac_dir = f"{HOME_DIR}/.local/share/ov/pkg/isaac_sim-{ISAAC_VERSION}" wh_gen_dir = f"{isaac_dir}/exts/omni.isaac.examples/omni/isaac/examples/warehouse_gen" # blender BLENDER_VERSION = '3.5.0' blender_dir = f"{HOME_DIR}/Downloads/blender-{BLENDER_VERSION}-linux-x64" # openfoam OPENFOAM_VERSION = 'v2212' openfoam_dir = f"{HOME_DIR}/OpenFOAM/OpenFOAM-{OPENFOAM_VERSION}" # environment related settings env_types = ['wh_simple', 'wh_complex'] env_type = env_types[0] env_amount = 2 env_size = [10.0, 16.0, 8.0] # [X Y Z] if env_type == 'wh_simple': inlet_size = [1.2,2.4] # [Y,Z], [m] inlet_vel = [1.0, 0.0, 0.0] # [X, Y,Z], [m/s] outlet_size = [1.5,2.4] # [Y,Z], [m] emptyfullrackdiv = 0.5 # least percentage of filled racks # relevant CDF meshing settings cfd_mesh_settings = { "minCellSize": 0.10, # it is recommended to keep these values uniform "maxCellSize": 0.10, # for easy of meshing, cfd calculation and mesh quality "boundaryCellSize": 0.10, "localRefinement": 0.0, # set to 0.0 to leave inactive } # relevant CFD settings cfd_k = round(1.5 * (0.05 * math.hypot(inlet_vel[0],inlet_vel[1],inlet_vel[2]))**2,6) # turbulent kinetic energy cfd_epsilon = round((0.09**0.75 * cfd_k**1.5)/(0.1*inlet_size[0]),6) # dissipation rate cfd_settings = { "threads": len(os.sched_getaffinity(0)) - 2, # available threads for CFD is total-2 for best performance "endTime": 1.0, "writeInterval": 1.0, "maxCo": 2.0, "maxDeltaT": 0.0, # set to 0.0 to leave inactive "k": cfd_k, "epsilon": cfd_epsilon, } # gas dispersal settings src_placement_types = ['random', 'specific'] # TODO implement types src_placement = src_placement_types[0] src_height = 2.0 # [m] # TODO improve this implementation # simple ( probably unnecessary ) class to store a timestep () class flow_field: def __init__(self,id): self.id = id # max_num_tries = 3 # z_min = 0 #z_max = env_size_x # asset file-locations filenames = { ############################# OMNIVERSE ASSETS ############################# # Then, we point to asset paths, to pick one at random and spawn at specific positions "empty_racks": f"{asset_dir}Shelves/", "filled_racks": f"{asset_dir}Racks/", "piles": f"{asset_dir}Piles/", "railings": f"{asset_dir}Railing/", # warehouse shell-specific assets (floor, walls, ceiling etc.) "isaac_wh_props":f"{HOME_DIR}/Omniverse_content/isaac-simple-warehouse/Props/", "floor": "SM_floor02.usd", "walls": [ "SM_WallA_InnerCorner.usd", "SM_WallB_InnerCorner.usd", "SM_WallA_6M.usd", "SM_WallB_6M.usd", ], "lights":[ "SM_LampCeilingA_04.usd", # off "SM_LampCeilingA_05.usd", # on ], # we can also have stand-alone assets, that are directly spawned in specific positions "forklift_asset": ["Forklift_A01_PR_V_NVD_01.usd"], "robot_asset": ["transporter.usd"], # We are also adding other assets from the paths above to choose from "empty_racks_large_asset": ["RackLargeEmpty_A1.usd", "RackLargeEmpty_A2.usd"], "empty_racks_long_asset": ["RackLongEmpty_A1.usd", "RackLongEmpty_A2.usd"], "filled_racks_large_asset": [ "RackLarge_A1.usd", "RackLarge_A2.usd", "RackLarge_A3.usd", "RackLarge_A4.usd", "RackLarge_A5.usd", "RackLarge_A6.usd", "RackLarge_A7.usd", "RackLarge_A8.usd", "RackLarge_A9.usd", ], "filled_racks_small_asset": [ "RackSmall_A1.usd", "RackSmall_A2.usd", "RackSmall_A3.usd", "RackSmall_A4.usd", "RackSmall_A5.usd", "RackSmall_A6.usd", "RackSmall_A7.usd", "RackSmall_A8.usd", "RackSmall_A9.usd", ], "filled_racks_long_asset": [ "RackLong_A1.usd", "RackLong_A2.usd", "RackLong_A3.usd", "RackLong_A4.usd", "RackLong_A5.usd", "RackLong_A6.usd", "RackLong_A7.usd", ], "filled_racks_long_high_asset": ["RackLong_A8.usd", "RackLong_A9.usd"], "piles_asset": [ "WarehousePile_A1.usd", "WarehousePile_A2.usd", "WarehousePile_A3.usd", "WarehousePile_A4.usd", "WarehousePile_A5.usd", "WarehousePile_A6.usd", "WarehousePile_A7.usd", ], "railings_asset": ["MetalFencing_A1.usd", "MetalFencing_A2.usd", "MetalFencing_A3.usd"], ############################# MOCKUP ASSETS ############################# "empty_racks_mockup": f"{asset_mockup_dir}Shelves/", "filled_racks_mockup": f"{asset_mockup_dir}Racks/", "empty_racks_long_asset_mockup": ["RackLongEmpty_A1.obj", "RackLongEmpty_A2.obj"], "filled_racks_long_asset_mockup": "RackLong.obj", } # pairs of filelocations of assets and their corresponding mockups file_loc_paired = { "filled_racks": [[filenames["filled_racks"] + filenames["filled_racks_long_asset"][0], filenames["filled_racks_mockup"] + filenames["filled_racks_long_asset_mockup"]], [filenames["filled_racks"] + filenames["filled_racks_long_asset"][1], filenames["filled_racks_mockup"] + filenames["filled_racks_long_asset_mockup"]], [filenames["filled_racks"] + filenames["filled_racks_long_asset"][2], filenames["filled_racks_mockup"] + filenames["filled_racks_long_asset_mockup"]], [filenames["filled_racks"] + filenames["filled_racks_long_asset"][3], filenames["filled_racks_mockup"] + filenames["filled_racks_long_asset_mockup"]], [filenames["filled_racks"] + filenames["filled_racks_long_asset"][4], filenames["filled_racks_mockup"] + filenames["filled_racks_long_asset_mockup"]], [filenames["filled_racks"] + filenames["filled_racks_long_asset"][5], filenames["filled_racks_mockup"] + filenames["filled_racks_long_asset_mockup"]], [filenames["filled_racks"] + filenames["filled_racks_long_asset"][6], filenames["filled_racks_mockup"] + filenames["filled_racks_long_asset_mockup"]]], "empty_racks": [[filenames["empty_racks"] + filenames["empty_racks_long_asset"][0], filenames["empty_racks_mockup"] + filenames["empty_racks_long_asset_mockup"][0]], [filenames["empty_racks"] + filenames["empty_racks_long_asset"][1], filenames["empty_racks_mockup"] + filenames["empty_racks_long_asset_mockup"][1]]], "floors": [[filenames["isaac_wh_props"] + filenames["floor"], None]], "walls": [[filenames["isaac_wh_props"] + filenames["walls"][0], None], [filenames["isaac_wh_props"] + filenames["walls"][1], None], [filenames["isaac_wh_props"] + filenames["walls"][2], None], [filenames["isaac_wh_props"] + filenames["walls"][3], None],], "lights": [[filenames["isaac_wh_props"] + filenames["lights"][0], None], [filenames["isaac_wh_props"] + filenames["lights"][1], None]], }
7,939
Python
43.606741
172
0.625772
tudelft/autoGDMplus/README.md
# AutoGDM+ ### Automated Pipeline for 3D Gas Dispersal Modelling and Environment Generation This repository contains the code of AutoGDM+ based on the same concepts as [AutoGDM](https://github.com/tudelft/AutoGDM/). Please fully read this before proceeding. ## Required - Tested on `Ubuntu 20.04 LTS` - [`Isaac Sim`](https://developer.nvidia.com/isaac-sim) (Install with the Omniverse Launcher) - [`Blender`](https://www.blender.org/) - [`OpenFOAM`]() - [`ROS`](http://wiki.ros.org/noetic/Installation/Ubuntu) (noetic) ## Installation ### Omniverse Launcher & Isaac Sim Follow [these instructions:](https://docs.omniverse.nvidia.com/install-guide/latest/standard-install.html) 1) Download, install and run the [`Omniverse Launcher`](https://www.nvidia.com/en-us/omniverse/). It is strongly recommended you install with the cache enabled. In case of problems see the troubleshooting section. 2) Create a local Nucleus server by going to the 'Nucleus' tab and enabling it. You will have to create an associated local Nucleus account (this is not associated with any other account). 3) Install Isaac Sim version `2022.2.0`. Go to the 'exchange' tab and select Isaac Sim. Note, the default install location of Isaac Sim is `~/.local/share/ov/pkg/isaac_sim-<version>` 4) Download the necessery content: - From the the exchange tab in the launcher, download both the 'Industrial 3D Models Pack' and the 'USD Physics Sample Pack' by clicking 'Save as...' (right part of the green download button). - From the Nucleus tab in the launcher, go to `localhost/NVIDIA/Assets/Isaac/<version>/Isaac/Environments/Simple_Warehouse` and download these contents by clicking the download button in the details pane on the right. - Extract these folders to `~/Omniverse_content` so that AutoGDM+ can find them. Another location can be specified with in the settings of AutoGDM+ if placed somewhere else. ### Blender - Download and extract the blender.zip to a location of your preference, in this case `~/Downloads/blender-<version>-linux-x64` ### Paraview (optional) - For visualizing and verify the meshing and CFD results ``` sudo apt-get update && sudo apt-get install paraview ``` ### OpenFOAM 1) Check the [system requirements](https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Requirements.md) 2) Download the [OpenFoam](https://develop.openfoam.com/Development/openfoam) v2212 and its [Thirdparty software](https://develop.openfoam.com/Development/ThirdParty-common/) and extract in `~/OpenFOAM` such that the directories are called `OpenFOAM-<version>` and `Thirdparty-<version>` 3) Download and extract the source code of [scotch (v6.1.0)](https://gitlab.inria.fr/scotch/scotch/-/releases/v6.1.0) into the Thirdparty dicectory 4) Open a commandline in the home directory and check the system ``` source OpenFOAM/Openfoam-v2212/etc/bashrc && foamSystemCheck ``` 5) `cd` into `~/OpenFOAM/OpenFOAM-v2212` and build: ``` ./Allwmake -j -s -q -l ``` 6) Add the following lines to your `.bashrc` to add an alias to source your OpenFOAM installation: ``` # >>> OpenFOAM >>> alias of2212='source $HOME/OpenFOAM/OpenFOAM-v2212/etc/bashrc' # <<< OpenFOAM <<< ``` ### ROS & Catkin Tools 1) Install [ROS noetic](http://wiki.ros.org/noetic/Installation/Ubuntu) 2) Install [catkin tools](https://catkin-tools.readthedocs.io/en/latest/installing.html) ### AutoGDM+ - Clone this repository, preferably in your home directory. - Install the isaac_asset_placer: Copy and paste the `warehouse_gen` folder into the Isaac Sim examples folder located at `~/.local/share/ov/pkg/isaac_sim-<version>/exts/omni.isaac.examples/omni/isaac/examples/` - Build the GADEN workspace: ``` source /opt/ros/noetic/setup.bash cd autoGDMplus/gaden_ws catkin init catkin build ``` ## Before Running AutoGDM+ 1) Check the asset file locations and software versions in `~/autoGDMplus/config/current.yaml`, especially: - `asset_dir` (line 8) - `isaac_wh_props` (line 80) - `forlift_asset` (line 93) 2) Define desired settings in `~/autoGDMplus/config/current.yaml` 3) Source your openfoam installation (with the previously created alias) ``` of2212 ``` 4) source the GADEN workspace ``` cd autoGDMplus/gaden_ws source devel/setup.bash ``` ## Run AutoGDM+ ``` cd autoGDMplus python3 main.py ``` ## Troubleshooting ### Running AutoGDM+ - `could not find .../combined.fms` - Solution: source your OpenFOAM installation before running ### Omniverse launcher - [Stuck at login](https://forums.developer.nvidia.com/t/failed-to-login-stuck-after-logging-in-web-browser/260298/6) - Solution: Search for the `nvidia-omniverse-launcher.desktop` file and copy it to `.config/autostart` ## Contact Please reach out to us if you encounter any problems or suggestions. AutoGDM+ is a work in progress, we are excited to see it beeing used! Reach out to Hajo for all technical questions. ### Contributors Hajo Erwich - Student & Maintainer - [email protected] <br /> Bart Duisterhof - Supervisor & PhD Student <br /> Prof. Dr. Guido de Croon
5,041
Markdown
46.566037
287
0.748661
tudelft/autoGDMplus/warehouse_gen/isaac_asset_placer.py
""" isaac_asset_placer.py Just like blender_asset_placer.py this script takes in the available recipies and generates .usd files accordingly. """ import sys # get recipe and mockup scene dir argv = sys.argv argv = argv[argv.index("--") + 1:] # get all the args after " -- " recipe_dir = argv[0] # recipe folder usd_dir = argv[1] # isaac sim export folder # Launch Isaac Sim before any other imports # Default first two lines in any standalone application from omni.isaac.kit import SimulationApp simulation_app = SimulationApp({"headless": True}) import os, platform import glob import json import random import numpy as np import carb import omni.ext import omni.ui as ui from omni.ui.workspace_utils import RIGHT from pxr import Usd, UsdGeom, UsdLux, Gf # from wh_recipes import warehouse_recipe_custom as wh_rec # from wh_recipes import warehouse_recipe_simple as wh_simp class wh_helpers(): def __init__(self): # NUCLEUS_SERVER_CUSTOM = "~/Omniverse_content/ov-industrial3dpack-01-100.1.1/" # SIMPLE_WAREHOUSE = "~/Omniverse_content/isaac-simple-warehouse/" self._system = platform.system() self.usd_save_dir = usd_dir def config_environment(self): for prim in self._stage.Traverse(): if '/Environment/' in str(prim): prim.SetActive(False) # self.create_rectangular_light(translate, scale) def create_distant_light(self): environmentPath = '/Environment' lightPath = environmentPath + '/distantLight' prim = self._stage.DefinePrim(environmentPath, 'Xform') distLight = UsdLux.DistantLight.Define(self._stage, lightPath) distLight.AddRotateXYZOp().Set(Gf.Vec3f(315,0,0)) distLight.CreateColorTemperatureAttr(6500.0) if self._system == "Linux": distLight.CreateIntensityAttr(6500.0) else: distLight.CreateIntensityAttr(3000.0) distLight.CreateAngleAttr(1.0) lightApi = UsdLux.ShapingAPI.Apply(distLight.GetPrim()) lightApi.CreateShapingConeAngleAttr(180) # TODO: optional, implement this func correctly def create_rectangular_light(self, translate, scale): environmentPath = '/Environment' lightPath = environmentPath + '/rectLight' prim = self._stage.DefinePrim(environmentPath, 'Xform') rectLight = UsdLux.RectLight.Define(self._stage, lightPath) # rectLight = UsdLux.RectLight.Define(prim, lightPath) # rectLight.AddScaleOp().Set(Gf.Vec3f(scale[0],scale[1],scale[2])) # rectLight.translateOp().Set(Gf.Vec3f(translate[0],translate[1],translate[2])) # distLight.AddRotateXYZOp().Set(Gf.Vec3f(315,0,0)) # UsdGeom.XformCommonAPI(rectLight).SetTranslate(translate) # UsdGeom.XformCommonAPI(rectLight).SetScale(scale) print("rectlight!!!") rectLight.CreateColorTemperatureAttr(6500.0) if self._system == "Linux": rectLight.CreateIntensityAttr(6500.0) else: rectLight.CreateIntensityAttr(3000.0) #distLight.CreateAngleAttr(1.0) lightApi = UsdLux.ShapingAPI.Apply(rectLight.GetPrim()) #lightApi.CreateShapingConeAngleAttr(180) # spawn_prim function takes in a path, XYZ position, orientation, a name and spawns the USD asset in path with # the input name in the given position and orientation inside the world prim as an XForm def spawn_prim(self, path, translate, rotate, name, scale=Gf.Vec3f(1.0, 1.0, 1.0)): world = self._stage.GetDefaultPrim() # Creating an XForm as a child to the world prim asset = UsdGeom.Xform.Define(self._stage, f"{str(world.GetPath())}/{name}") # Checking if asset already has a reference and clearing it asset.GetPrim().GetReferences().ClearReferences() # Adding USD in the path as reference to this XForm asset.GetPrim().GetReferences().AddReference(f"{path}") # Setting the Translate and Rotate UsdGeom.XformCommonAPI(asset).SetTranslate(translate) UsdGeom.XformCommonAPI(asset).SetRotate(rotate) UsdGeom.XformCommonAPI(asset).SetScale(scale) # Returning the Xform if needed return asset # Clear stage function def clear_stage_old(self): #Removing all children of world except distant light self.get_root() world = self._stage.GetDefaultPrim() doesLightExist = self._stage.GetPrimAtPath('/Environment/distantLight').IsValid() # config environment if doesLightExist == False: self.config_environment() # clear scene for i in world.GetChildren(): if i.GetPath() == '/Environment/distantLight' or i.GetPath() == '/World': continue else: self._stage.RemovePrim(i.GetPath()) def clear_stage(self): self.get_root() # Removing all children of world world = self._stage.GetDefaultPrim() for i in world.GetChildren(): if i.GetPath() == '/World': continue else: self._stage.RemovePrim(i.GetPath()) # gets stage def get_root(self): self._stage = omni.usd.get_context().get_stage() #UsdGeom.Tokens.upAxis(self._stage, UsdGeom.Tokens.y) # Set stage upAxis to Y world_prim = self._stage.DefinePrim('/World', 'Xform') # Create top-level World Xform primitive self._stage.SetDefaultPrim(world_prim) # Set as default primitive # save stage to .usd def save_stage(self, fname): save_loc = f"{self.usd_save_dir}{fname}.usd" omni.usd.get_context().save_as_stage(save_loc, None) if os.path.isfile(save_loc): print(f"[omni.warehouse] saved .usd file to: {self.usd_save_dir}{fname}.usd") else: print(f"[omni.warehouse] .usd export FAILED: {self.usd_save_dir}{fname}.usd") ################################################################## ############################# MAIN ############################### ################################################################## if __name__ == "__main__": _wh_helpers = wh_helpers() recipes = glob.glob(f"{recipe_dir}*.txt") # gather all recipes for rec_loc in recipes: with open(rec_loc) as f: # reading the recipe from the file data = f.read() recipe = json.loads(data) # reconstructing the data as a dictionary _wh_helpers.clear_stage() # place lighting # for light in recipe["isaac_rect_lights"]: # _wh_helpers.create_rectangular_light(light["location"], light["scale"]) # place interior props for recipe_dict in [recipe["isaac_floor"], recipe["isaac_walls"], recipe["interior"], recipe["isaac_lights"]]: for asset in recipe_dict: _wh_helpers.spawn_prim(asset["filename"], asset["location"], asset["orientation"], asset["asset_id"], scale=asset["scale"]) _wh_helpers.save_stage(f"{recipe['env_type']}_{recipe['env_id']}") simulation_app.close() # close Isaac Sim
7,415
Python
42.116279
114
0.604855
tudelft/autoGDMplus/warehouse_gen/wh_gen.py
#launch Isaac Sim before any other imports #default first two lines in any standalone application from omni.isaac.kit import SimulationApp simulation_app = SimulationApp({"headless": True}) # we can also run as headless. import numpy as np import os, platform import random import carb import omni.ext import omni.ui as ui from omni.ui.workspace_utils import RIGHT from pxr import Usd, UsdGeom, UsdLux, Gf from wh_recipes import warehouse_recipe_custom as wh_rec from wh_recipes import warehouse_recipe_simple as wh_simp class wh_helpers(): def __init__(self): USD_SAVE_DIR = "~/AutoGDM2/USD_scenes/" #USD_SAVE_DIR = "~/Omniverse_content/isaac-simple-warehouse/" NUCLEUS_SERVER_CUSTOM = "~/Omniverse_content/ov-industrial3dpack-01-100.1.1/" SIMPLE_WAREHOUSE = "~/Omniverse_content/isaac-simple-warehouse/" isTest = False self._system = platform.system() self.mode = "procedural" self.objects = ["empty_racks", "filled_racks", "piles", "railings", "forklift", "robot"] self.objectDict = self.initAssetPositions() self.objDictList = list(self.objectDict) self.isaacSimScale = Gf.Vec3f(100,100,100) self.usd_save_dir = USD_SAVE_DIR # Shell info is hard-coded for now # self.shell_path = f"{NUCLEUS_SERVER}Buildings/Warehouse/Warehouse01.usd" self.shell_path = f"{NUCLEUS_SERVER_CUSTOM}Buildings/Warehouse/Warehouse01.usd" self.shell_translate = (0, 0, 55.60183) self.shell_rotate = (-90.0, 0.0, 0.0) self.shell_name = "WarehouseShell" self.shell_simple_path = f"{SIMPLE_WAREHOUSE}warehouse.usd" self.shell_simple_translate = (0, 0, 0) self.shell_simple_rotate = (0.0, 0.0, 0.0) self.shell_simple_name = "WarehouseShell" def config_environment(self): for prim in self._stage.Traverse(): if '/Environment/' in str(prim): prim.SetActive(False) self.create_distant_light() def create_distant_light(self): environmentPath = '/Environment' lightPath = environmentPath + '/distantLight' prim = self._stage.DefinePrim(environmentPath, 'Xform') distLight = UsdLux.DistantLight.Define(self._stage, lightPath) distLight.AddRotateXYZOp().Set(Gf.Vec3f(315,0,0)) distLight.CreateColorTemperatureAttr(6500.0) if self._system == "Linux": distLight.CreateIntensityAttr(6500.0) else: distLight.CreateIntensityAttr(3000.0) distLight.CreateAngleAttr(1.0) lightApi = UsdLux.ShapingAPI.Apply(distLight.GetPrim()) lightApi.CreateShapingConeAngleAttr(180) def genShell(self): self.clear_stage() self.mode = "procedural" self.spawn_prim(self.shell_path, self.shell_translate, self.shell_rotate, self.shell_name) print(str("[omni.warehouse] generating shell from: " + self.shell_path)) def gen_shell_simple(self): self.clear_stage() self.mode = "procedural" self.spawn_prim(self.shell_simple_path, self.shell_simple_translate, self.shell_simple_rotate, self.shell_simple_name) print(str("[omni.warehouse] generating shell from: " + self.shell_simple_path)) # Generate Warehouse w/ user-selected assets def gen_custom(self, isProcedural, mode, objectButtons): self.mode = mode # Clear stage self.clear_stage() # Create shell self.spawn_prim(self.shell_path, self.shell_translate, self.shell_rotate, self.shell_name) selected_obj = [] # Spawn all objects (procedural) or user-selected objects if isProcedural: selected_obj = self.objects else: for i in range(len(objectButtons)): if objectButtons[i].checked == True: identifier = { 0: "empty_racks", 1: "filled_racks", 2: "piles", 3: "railings", 4: "forklift", 5: "robot", } selected_obj.append(identifier.get(i)) objectUsdPathDict = {"empty_racks": [], "filled_racks":[], "piles":[], "railings":[], "forklift":[], "robot":[] } # Reserved spots are dependent on self.mode (i.e. layout) numForkLifts = len(wh_rec[self.objects[4] + "_" + self.mode]) spots2RsrvFL = numForkLifts - 1 numRobots = len(wh_rec[self.objects[5] + "_" + self.mode]) spots2RsrvRob = numRobots - 1 self.objParams = {"empty_racks": [(-90,-180,0), (1,1,1), 5], "filled_racks":[(-90,-180,0), (1,1,1), 5], "piles":[(-90,-90,0), (1,1,1), 5], "railings":[(-90,0,0), (1,1,1), 5], "forklift":[(-90, random.uniform(0, 90), 0), Gf.Vec3f(1,1,1), spots2RsrvFL], "robot":[(-90, random.uniform(0, 90), 0), self.isaacSimScale, spots2RsrvRob] } # Reserve spots for Smart Import feature for h in range(0,len(selected_obj)): for i in range(0, len(self.objDictList)): if selected_obj[h] == self.objDictList[i]: for j in wh_rec[selected_obj[h] + "_asset"]: objectUsdPathDict[self.objDictList[i]].append(wh_rec[selected_obj[h]] + j) rotation = self.objParams[self.objDictList[i]][0] scale = self.objParams[self.objDictList[i]][1] spots2Rsrv = self.objParams[self.objDictList[i]][2] self.objectDict[self.objDictList[i]] = self.reservePositions(objectUsdPathDict[self.objDictList[i]], selected_obj[h], rotation, scale, spots2Rsrv) # Function to reserve spots/positions for Smart Import feature (after initial generation of assets) def reservePositions(self, assets, asset_prefix, rotation = (0,0,0), scale = (1,1,1), spots2reserve = 5): if len(assets) > 0: rotate = rotation scale = scale all_translates = wh_rec[asset_prefix + "_" + self.mode] #Select all but 5 positions from available positions (reserved for Smart Import functionality) if spots2reserve >= len(all_translates) and len(all_translates) > 0: spots2reserve = len(all_translates) - 1 elif len(all_translates) == 0: spots2reserve = 0 reserved_positions = random.sample(all_translates, spots2reserve) translates = [t for t in all_translates if t not in reserved_positions] positions = reserved_positions for i in range(len(translates)): name = asset_prefix + str(i) path = random.choice(assets) translate = translates[i] self.spawn_prim(path, translate, rotate, name, scale) return positions # spawn_prim function takes in a path, XYZ position, orientation, a name and spawns the USD asset in path with # the input name in the given position and orientation inside the world prim as an XForm def spawn_prim(self, path, translate, rotate, name, scale=Gf.Vec3f(1.0, 1.0, 1.0)): world = self._stage.GetDefaultPrim() # Creating an XForm as a child to the world prim asset = UsdGeom.Xform.Define(self._stage, f"{str(world.GetPath())}/{name}") # Checking if asset already has a reference and clearing it asset.GetPrim().GetReferences().ClearReferences() # Adding USD in the path as reference to this XForm asset.GetPrim().GetReferences().AddReference(f"{path}") # Setting the Translate and Rotate UsdGeom.XformCommonAPI(asset).SetTranslate(translate) UsdGeom.XformCommonAPI(asset).SetRotate(rotate) UsdGeom.XformCommonAPI(asset).SetScale(scale) # Returning the Xform if needed return asset def initAssetPositions(self): dictAssetPositions = { "empty_racks": wh_rec["empty_racks" + "_" + self.mode], "filled_racks": wh_rec["filled_racks" + "_" + self.mode], "piles": wh_rec["piles" + "_" + self.mode], "railings": wh_rec["railings" + "_" + self.mode], "forklift": wh_rec["forklift" + "_" + self.mode], "robot": wh_rec["robot" + "_" + self.mode] } return dictAssetPositions # Clear stage function def clear_stage(self): #Removing all children of world except distant light self.get_root() world = self._stage.GetDefaultPrim() doesLightExist = self._stage.GetPrimAtPath('/Environment/distantLight').IsValid() # config environment if doesLightExist == False: self.config_environment() # clear scene for i in world.GetChildren(): if i.GetPath() == '/Environment/distantLight' or i.GetPath() == '/World': continue else: self._stage.RemovePrim(i.GetPath()) # gets stage def get_root(self): self._stage = omni.usd.get_context().get_stage() #UsdGeom.Tokens.upAxis(self._stage, UsdGeom.Tokens.y) # Set stage upAxis to Y world_prim = self._stage.DefinePrim('/World', 'Xform') # Create top-level World Xform primitive self._stage.SetDefaultPrim(world_prim) # Set as default primitive # save stage to .usd def save_stage(self, fname): save_loc = f"{self.usd_save_dir}{fname}.usd" omni.usd.get_context().save_as_stage(save_loc, None) if os.path.isfile(save_loc): print(f"[omni.warehouse] saved .usd file to: {self.usd_save_dir}{fname}.usd") else: print(f"[omni.warehouse] .usd export FAILED: {self.usd_save_dir}{fname}.usd") ### M A I N ### _wh_helper = wh_helpers() # Arguments for gen_custom isProcedural = True genCustomMode = "procedural" genCustomButtons = ["empty_racks", "filled_racks", "piles", "railings", "forklift", "robot"] _wh_helper.gen_shell_simple() # _wh_helper.gen_custom(isProcedural, genCustomMode, genCustomButtons) _wh_helper.save_stage("test002") simulation_app.close() # close Isaac Sim
10,448
Python
44.628821
166
0.595521
tudelft/autoGDMplus/environments/ROS/empty_project/launch/ros/simbot_costmap_global_params.yaml
######################################################################## # Global parameters for the COSTMAP_2D pkg (navigation stack) ######################################################################## global_costmap: plugins: - {name: static_map, type: "costmap_2d::StaticLayer" } - {name: obstacles, type: "costmap_2d::VoxelLayer"} - {name: inflation, type: "costmap_2d::InflationLayer" } #- {name: proxemic, type: "social_navigation_layers::ProxemicLayer" } global_frame: map robot_base_frame: base_link update_frequency: 1.0 publish_frequency: 0.5 static_map: true rolling_window: false always_send_full_costmap: true visualize_potential: true obstacles: track_unknown_space: true inflation: inflation_radius: 0.75 cost_scaling_factor: 5.0 # proxemic: # amplitude: 150.0 # covariance: 0.1 # cutoff: 20 # factor: 1.0
901
YAML
27.187499
75
0.562708
tudelft/autoGDMplus/environments/ROS/empty_project/launch/ros/simbot_costmap_local_params.yaml
######################################################################## # Local parameters for the COSTMAP_2D pkg (navigation stack) ######################################################################## local_costmap: plugins: # - {name: static_map, type: "costmap_2d::StaticLayer" } - {name: obstacles, type: "costmap_2d::VoxelLayer"} - {name: inflation, type: "costmap_2d::InflationLayer" } # - {name: proxemic, type: "social_navigation_layers::ProxemicLayer" } global_frame: odom robot_base_frame: base_link update_frequency: 5.0 publish_frequency: 5.0 static_map: false rolling_window: true width: 6.0 height: 6.0 resolution: 0.05 min_obstacle_height: -10 always_send_full_costmap: true obstacles: track_unknown_space: true inflation: inflation_radius: 0.75 cost_scaling_factor: 5.0 # proxemic: # amplitude: 150.0 # covariance: 0.1 # cutoff: 20.0 # factor: 1.0
940
YAML
25.885714
72
0.565957
tudelft/autoGDMplus/environments/ROS/empty_project/launch/ros/simbot_global_planner_params.yaml
NavfnROS: allow_unknown: false default_tolerance: 0.0 visualize_potential: true use_dijkstra: true use_quadratic: true use_grid_path: true old_navfn_behavior: false # Defaults: # allow_unknown: true # default_tolerance: 0.0 # visualize_potential: false # use_dijkstra: true # use_quadratic: true # use_grid_path: false # old_navfn_behavior: false
372
YAML
18.631578
30
0.712366
tudelft/autoGDMplus/environments/ROS/empty_project/launch/ros/simbot_local_planner_params.yaml
############################################################################################### # Base_local_planner parameters - Trajectory generator based on costmaps # # The base_local_planner package provides a controller that drives a mobile base in the plane. ############################################################################################### # IF use DWA Planner #----------------------------------- DWAPlannerROS: max_trans_vel: 0.8 min_trans_vel: 0.06 max_vel_x: 0.8 min_vel_x: 0.0 max_vel_y: 0.0 min_vel_y: 0.0 max_rot_vel: 1.5 #rad 0.8rad = 45deg (aprox) min_rot_vel: 0.2 acc_lim_x: 5.0 acc_lim_y: 0.0 acc_lim_theta: 5.0 acc_lim_trans: 0.45 prune_plan: true xy_goal_tolerance: 0.2 #m yaw_goal_tolerance: 0.4 #rad trans_stopped_vel: 0.0 rot_stopped_vel: 0.8 sim_time: 1.0 sim_granularity: 0.05 angular_sim_granularity: 0.05 path_distance_bias: 32 goal_distance_bias: 20 occdist_scale: 0.02 stop_time_buffer: 0.5 oscillation_reset_dist: 0.10 oscillation_reset_angle: 0.1 forward_point_distanvce: 0.325 scalling_speed: 0.1 max_scaling_factor: 0.2 vx_samples: 10 vy_samples: 10 vth_samples: 15 use_dwa: true # IF use Trajectory Rollout Planner #----------------------------------- TrajectoryPlannerROS: max_vel_x: 0.6 #0.4 min_vel_x: 0.1 #0.0 max_vel_theta: 0.6 #rad 0.8rad = 45deg (aprox) min_vel_theta: -0.6 min_in_place_vel_theta: 0.1 acc_lim_x: 5.0 #must be high acc_lim_y: 0.0 acc_lim_theta: 5.0 acc_limit_trans: 0.4 holonomic_robot: false #Goal Tolerance Parameters yaw_goal_tolerance: 0.4 #rad xy_goal_tolerance: 0.3 #m #Forward Simulation Parameters sim_time: 5.0 # sim_granularity: 0.05 # angular_sim_granularity: 0.05 # vx_samples: 3 # vtheta_samples: 20 # controller_frequency: 20 #Trajectory Scoring Parameters # pdist_scale: 0.6 #The weighting for how much the controller should stay close to the path it was given (default 0.6) # gdist_scale: 0.8 #The weighting for how much the controller should attempt to reach its local goal, also controls speed (default 0.8#)
2,209
YAML
25.626506
150
0.578542
tudelft/autoGDMplus/environments/ROS/empty_project/launch/ros/simbot_costmap_common_params.yaml
######################################################################## # Common parameters for the COSTMAP_2D pkg (navigation stack) ######################################################################## obstacle_range: 2.5 #Update costmap with information about obstacles that are within 2.5 meters of the base raytrace_range: 3.0 #Clear out space (remove obstacles) up to 3.0 meters away given a sensor reading # FOOTPRINT #----------- #footprint: [[0.35,0.25],[0.35,-0.25],[-0.35,-0.25],[-0.35,0.25]] #A circular footprint of 0.45 diameter #footprint: [[ 0.225,0.000 ], [ 0.208, 0.086 ],[ 0.159, 0.159 ],[ 0.086, 0.208 ], [ 0.000, 0.225 ], [ -0.086, 0.208 ], [ -0.159, 0.159 ], [ -0.208, 0.086 ], [ -0.225, 0.000 ],[ -0.208, -0.086 ], [ -0.159, -0.159 ], [ -0.086, -0.208 ], [ -0.000, -0.225 ], [ 0.086, -0.208 ], [ 0.159, -0.159 ], [ 0.208, -0.086 ]] robot_radius: 0.26 #[m] radius of the robot shape for Giraff Robots (instead of the footprint) #inflation_radius: 0.6 # List of sensors that are going to be passing information to the costmap observation_sources: laser_scan laser2_scan laser_stage #sensor_id: {sensor_frame: [], data_type: [LaserScan/PointCloud], topic: [], marking: true, clearing: true} laser_scan: {sensor_frame: laser_link, data_type: LaserScan, topic: /laser_scan, marking: true, clearing: true} laser2_scan: {sensor_frame: laser2_link, data_type: LaserScan, topic: /laser2_scan, marking: true, clearing: true} laser_stage: {sensor_frame: laser_stage, data_type: LaserScan, topic: /laser_scan, marking: true, clearing: true} #Planners #--------- base_global_planner: navfn/NavfnROS base_local_planner: dwa_local_planner/DWAPlannerROS #base_local_planner: base_local_planner/TrajectoryPlannerROS planner_frequency: 1.0 controller_frequency: 20.0 planner_patience: 5.0 controller_patience: 5.0
1,845
YAML
50.277776
315
0.627642
tudelft/autoGDMplus/gaden_ws/src/gaden/simulated_anemometer/package.xml
<package> <name>simulated_anemometer</name> <version>1.0.0</version> <description> This package simulates the response of a digital anemometer deployed within the gas_dispersion_simulation pkg.</description> <maintainer email="[email protected]">Javier Monroy</maintainer> <license>GPLv3</license> <author>Javier Monroy</author> <!-- Dependencies which this package needs to build itself. --> <buildtool_depend>catkin</buildtool_depend> <!-- Dependencies needed to compile this package. --> <build_depend>roscpp</build_depend> <build_depend>visualization_msgs</build_depend> <build_depend>std_msgs</build_depend> <build_depend>nav_msgs</build_depend> <build_depend>olfaction_msgs</build_depend> <build_depend>tf</build_depend> <build_depend>gaden_player</build_depend> <!-- Dependencies needed after this package is compiled. --> <run_depend>roscpp</run_depend> <run_depend>visualization_msgs</run_depend> <run_depend>std_msgs</run_depend> <run_depend>nav_msgs</run_depend> <run_depend>olfaction_msgs</run_depend> <run_depend>tf</run_depend> <run_depend>gaden_player</run_depend> </package>
1,142
XML
34.718749
140
0.732925
tudelft/autoGDMplus/gaden_ws/src/gaden/simulated_anemometer/src/fake_anemometer.h
#include <ros/ros.h> //#include <nav_msgs/Odometry.h> //#include <geometry_msgs/PoseWithCovarianceStamped.h> #include <tf/transform_listener.h> //#include <std_msgs/Float32.h> //#include <std_msgs/Float32MultiArray.h> #include <visualization_msgs/Marker.h> #include <olfaction_msgs/anemometer.h> #include <gaden_player/WindPosition.h> #include <angles/angles.h> #include <cstdlib> #include <math.h> #include <vector> #include <fstream> #include <iostream> // Sensor Parameters std::string input_sensor_frame; std::string input_fixed_frame; double noise_std; bool use_map_ref_system; // Vars bool first_reading = true; bool notified = false; //functions: void loadNodeParameters(ros::NodeHandle private_nh);
739
C
20.764705
54
0.725304
tudelft/autoGDMplus/gaden_ws/src/gaden/simulated_anemometer/src/fake_anemometer.cpp
#include "fake_anemometer.h" #include <stdlib.h> /* srand, rand */ #include <time.h> #include <boost/random.hpp> #include <boost/random/normal_distribution.hpp> typedef boost::normal_distribution<double> NormalDistribution; typedef boost::mt19937 RandomGenerator; typedef boost::variate_generator<RandomGenerator&, \ NormalDistribution> GaussianGenerator; int main( int argc, char** argv ) { ros::init(argc, argv, "simulated_anemometer"); ros::NodeHandle n; ros::NodeHandle pn("~"); srand (time(NULL)); //Read parameters loadNodeParameters(pn); //Publishers //ros::Publisher sensor_read_pub = n.advertise<std_msgs::Float32MultiArray>("WindSensor_reading", 500); ros::Publisher sensor_read_pub = n.advertise<olfaction_msgs::anemometer>("WindSensor_reading", 500); ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("WindSensor_display", 100); //Service to request wind values to simulator ros::ServiceClient client = n.serviceClient<gaden_player::WindPosition>("/wind_value"); tf::TransformListener tf_; // Init Visualization data (marker) //---------------------------------------------------------------- // sensor = sphere // conector = stick from the floor to the sensor visualization_msgs::Marker sensor; visualization_msgs::Marker connector; visualization_msgs::Marker connector_inv; visualization_msgs::Marker wind_point; visualization_msgs::Marker wind_point_inv; sensor.header.frame_id = input_fixed_frame.c_str(); sensor.ns = "sensor_visualization"; sensor.action = visualization_msgs::Marker::ADD; sensor.type = visualization_msgs::Marker::SPHERE; sensor.id = 0; sensor.scale.x = 0.1; sensor.scale.y = 0.1; sensor.scale.z = 0.1; sensor.color.r = 0.0f; sensor.color.g = 0.0f; sensor.color.b = 1.0f; sensor.color.a = 1.0; connector.header.frame_id = input_fixed_frame.c_str(); connector.ns = "sensor_visualization"; connector.action = visualization_msgs::Marker::ADD; connector.type = visualization_msgs::Marker::CYLINDER; connector.id = 1; connector.scale.x = 0.1; connector.scale.y = 0.1; connector.color.a = 1.0; connector.color.r = 1.0f; connector.color.b = 1.0f; connector.color.g = 1.0f; // Init Marker: arrow to display the wind direction measured. wind_point.header.frame_id = input_sensor_frame.c_str(); wind_point.action = visualization_msgs::Marker::ADD; wind_point.ns = "measured_wind"; wind_point.type = visualization_msgs::Marker::ARROW; // Init Marker: arrow to display the inverted wind direction measured. wind_point_inv.header.frame_id = input_sensor_frame.c_str(); wind_point_inv.action = visualization_msgs::Marker::ADD; wind_point_inv.ns = "measured_wind_inverted"; wind_point_inv.type = visualization_msgs::Marker::ARROW; // LOOP //---------------------------------------------------------------- tf::TransformListener listener; ros::Rate r(2); while (ros::ok()) { //Vars tf::StampedTransform transform; bool know_sensor_pose = true; //Get pose of the sensor in the /map reference try { listener.lookupTransform(input_fixed_frame.c_str(), input_sensor_frame.c_str(), ros::Time(0), transform); } catch (tf::TransformException ex) { ROS_ERROR("%s",ex.what()); know_sensor_pose = false; ros::Duration(1.0).sleep(); } if (know_sensor_pose) { //Current sensor pose float x_pos = transform.getOrigin().x(); float y_pos = transform.getOrigin().y(); float z_pos = transform.getOrigin().z(); //ROS_INFO("[fake anemometer]: loc x y z: %f, %f, %f", x_pos, y_pos, z_pos); // Get Wind vectors (u,v,w) at current position // Service request to the simulator gaden_player::WindPosition srv; srv.request.x.push_back(x_pos); srv.request.y.push_back(y_pos); srv.request.z.push_back(z_pos); float u,v,w; olfaction_msgs::anemometer anemo_msg; if (client.call(srv)) { double wind_speed; double wind_direction; //GT Wind vector Value (u,v,w)[m/s] //From OpenFoam this is the DownWind direction in the map u = (float)srv.response.u[0]; v = (float)srv.response.v[0]; w = (float)srv.response.w[0]; wind_speed = sqrt(pow(u,2)+pow(v,2)); //ROS_INFO("[fake anemometer]: U V W: [%f, %f, %f]", u, v, w); float downWind_direction_map; if (u !=0 || v!=0) downWind_direction_map = atan2(v,u); else downWind_direction_map = 0.0; if (!use_map_ref_system) { // (IMPORTANT) Follow standards on wind measurement (real anemometers): //return the upwind direction in the anemometer reference system //range [-pi,pi] //positive to the right, negative to the left (opposed to ROS poses :s) float upWind_direction_map = angles::normalize_angle(downWind_direction_map + 3.14159); //Transform from map ref_system to the anemometer ref_system using TF geometry_msgs::PoseStamped anemometer_upWind_pose, map_upWind_pose; try { map_upWind_pose.header.frame_id = input_fixed_frame.c_str(); map_upWind_pose.pose.position.x = 0.0; map_upWind_pose.pose.position.y = 0.0; map_upWind_pose.pose.position.z = 0.0; map_upWind_pose.pose.orientation = tf::createQuaternionMsgFromYaw(upWind_direction_map); tf_.transformPose(input_sensor_frame.c_str(), map_upWind_pose, anemometer_upWind_pose); } catch(tf::TransformException &ex) { ROS_ERROR("FakeAnemometer - %s - Error: %s", __FUNCTION__, ex.what()); } double upwind_direction_anemo = tf::getYaw(anemometer_upWind_pose.pose.orientation); wind_direction = upwind_direction_anemo; } else { // for simulations wind_direction = angles::normalize_angle(downWind_direction_map); } // Adding Noise static RandomGenerator rng(static_cast<unsigned> (time(0))); NormalDistribution gaussian_dist(0.0,noise_std); GaussianGenerator generator(rng, gaussian_dist); wind_direction = wind_direction + generator(); wind_speed = wind_speed + generator(); //Publish 2D Anemometer readings //------------------------------ anemo_msg.header.stamp = ros::Time::now(); if (use_map_ref_system) anemo_msg.header.frame_id = input_fixed_frame.c_str(); else anemo_msg.header.frame_id = input_sensor_frame.c_str(); anemo_msg.sensor_label = "Fake_Anemo"; anemo_msg.wind_direction = wind_direction; //rad anemo_msg.wind_speed = wind_speed; //m/s //Publish fake_anemometer reading (m/s) sensor_read_pub.publish(anemo_msg); //Add wind marker ARROW for Rviz (2D) --> Upwind /* wind_point.header.stamp = ros::Time::now(); wind_point.points.clear(); wind_point.id = 1; //unique identifier for each arrow wind_point.pose.position.x = 0.0; wind_point.pose.position.y = 0.0; wind_point.pose.position.z = 0.0; wind_point.pose.orientation = tf::createQuaternionMsgFromYaw(wind_direction_with_noise); wind_point.scale.x = 2*sqrt(pow(u,2)+pow(v,2)); //arrow lenght wind_point.scale.y = 0.1; //arrow width wind_point.scale.z = 0.1; //arrow height wind_point.color.r = 0.0; wind_point.color.g = 1.0; wind_point.color.b = 0.0; wind_point.color.a = 1.0; marker_pub.publish(wind_point); */ //Add inverted wind marker --> DownWind wind_point_inv.header.stamp = ros::Time::now(); wind_point_inv.header.frame_id=anemo_msg.header.frame_id; wind_point_inv.points.clear(); wind_point_inv.id = 1; //unique identifier for each arrow if(use_map_ref_system){ wind_point_inv.pose.position.x = x_pos; wind_point_inv.pose.position.y = y_pos; wind_point_inv.pose.position.z = z_pos; }else{ wind_point_inv.pose.position.x = 0.0; wind_point_inv.pose.position.y = 0.0; wind_point_inv.pose.position.z = 0.0; } wind_point_inv.pose.orientation = tf::createQuaternionMsgFromYaw(wind_direction+3.1416); // ROS_INFO("[fake anemometer]: wind readings u v: %f, %f", u, v); wind_point_inv.scale.x = 2*sqrt(pow(u,2)+pow(v,2)); //arrow lenght wind_point_inv.scale.y = 0.1; //arrow width wind_point_inv.scale.z = 0.1; //arrow height wind_point_inv.color.r = 0.0; wind_point_inv.color.g = 1.0; wind_point_inv.color.b = 0.0; wind_point_inv.color.a = 1.0; marker_pub.publish(wind_point_inv); notified = false; } else { if (!notified) { ROS_WARN("[fake_anemometer] Cannot read Wind Vector from simulated data."); notified = true; } } //Publish RVIZ sensor pose (a sphere) /* sensor.header.stamp = ros::Time::now(); sensor.pose.position.x = x_pos; sensor.pose.position.y = y_pos; sensor.pose.position.z = z_pos; marker_pub.publish(sensor); */ // PUBLISH ANEMOMETER Stick /* connector.header.stamp = ros::Time::now(); connector.scale.z = z_pos; connector.pose.position.x = x_pos; connector.pose.position.y = y_pos; connector.pose.position.z = float(z_pos)/2; marker_pub.publish(connector); */ } ros::spinOnce(); r.sleep(); } } //Load Sensor parameters void loadNodeParameters(ros::NodeHandle private_nh) { //sensor_frame private_nh.param<std::string>("sensor_frame", input_sensor_frame, "anemometer_link"); //fixed frame private_nh.param<std::string>("fixed_frame", input_fixed_frame, "map"); //Noise private_nh.param<double>("noise_std", noise_std, 0.1); //What ref system to use for publishing measurements private_nh.param<bool>("use_map_ref_system", use_map_ref_system, false); ROS_INFO("[fake anemometer]: wind noise: %f", noise_std); }
10,648
C++
32.487421
112
0.590627
tudelft/autoGDMplus/gaden_ws/src/gaden/gaden_environment/package.xml
<package> <name>gaden_environment</name> <version>1.0.0</version> <description>Package for visualizing on RVIZ the simulation environment (walls, obstacles and gas source).</description> <maintainer email="[email protected]">Javier Monroy</maintainer> <license>GPLv3</license> <!-- Dependencies which this package needs to build itself. --> <buildtool_depend>catkin</buildtool_depend> <!-- Dependencies needed to compile this package. --> <build_depend>visualization_msgs</build_depend> <build_depend>tf</build_depend> <build_depend>roscpp</build_depend> <build_depend>std_msgs</build_depend> <build_depend>geometry_msgs</build_depend> <!-- Dependencies needed after this package is compiled. --> <run_depend>visualization_msgs</run_depend> <run_depend>tf</run_depend> <run_depend>roscpp</run_depend> <run_depend>std_msgs</run_depend> <run_depend>geometry_msgs</run_depend> </package>
928
XML
33.407406
122
0.727371
tudelft/autoGDMplus/gaden_ws/src/gaden/gaden_environment/src/environment.cpp
/* * The only goal of this Node is to display the simulation environment and gas source location in RVIZ. * * 1. Loads the simulation environment (usually from CFD in the file format .env), and displays it as RVIZ markers. * 2. Displays the Gas-Source Location as two cylinders. */ #include "environment/environment.h" // ===============================// // MAIN // // ===============================// int main( int argc, char** argv ) { //Init ros::init(argc, argv, "environment"); Environment environment; //Load Parameters environment.run(); } void Environment::run() { ros::NodeHandle n; ros::NodeHandle pnh("~"); loadNodeParameters(pnh); // Publishers ros::Publisher gas_source_pub = n.advertise<visualization_msgs::MarkerArray>("source_visualization", 10); ros::Publisher environmnet_pub = n.advertise<visualization_msgs::MarkerArray>("environment_visualization", 100); ros::Publisher environmnet_cad_pub = n.advertise<visualization_msgs::MarkerArray>("environment_cad_visualization", 100); ros::ServiceServer occupancyMapService = n.advertiseService("gaden_environment/occupancyMap3D", &Environment::occupancyMapServiceCB, this); // Subscribers preprocessing_done =false; ros::Subscriber sub = n.subscribe("preprocessing_done", 1, &Environment::PreprocessingCB, this); // 1. ENVIRONMNET AS CAD MODELS //------------------------------- visualization_msgs::MarkerArray CAD_model_markers; for (int i=0;i<number_of_CAD;i++) { // CAD model in Collada (.dae) format visualization_msgs::Marker cad; cad.header.frame_id = fixed_frame; cad.header.stamp = ros::Time::now(); cad.ns = "part_" + std::to_string(i); cad.id = i; cad.type = visualization_msgs::Marker::MESH_RESOURCE; cad.action = visualization_msgs::Marker::ADD; cad.mesh_resource = CAD_models[i]; cad.scale.x = 1.0; cad.scale.y = 1.0; cad.scale.z = 1.0; cad.pose.position.x = 0.0; //CAD models have the object pose within the file! cad.pose.position.y = 0.0; cad.pose.position.z = 0.0; cad.pose.orientation.x = 0.0; cad.pose.orientation.y = 0.0; cad.pose.orientation.z = 0.0; cad.pose.orientation.w = 1.0; //Color (Collada has no color) cad.color.r = CAD_color[i][0]; cad.color.g = CAD_color[i][1]; cad.color.b = CAD_color[i][2]; cad.color.a = 1.0; //Add Marker to array CAD_model_markers.markers.push_back(cad); } // 2. ENVIRONMNET AS Occupancy3D file //------------------------------------ //Display Environment as an array of Cube markers (Rviz) visualization_msgs::MarkerArray environment; if (occupancy3D_data != "") loadEnvironment(environment); if (verbose) ROS_INFO("[env]loadEnvironment completed, line 85"); // 3. GAS SOURCES //---------------- //Generate Gas Source Markers //The shape are cylinders from the floor to the given z_size. visualization_msgs::MarkerArray gas_source_markers; for (int i=0;i<number_of_sources;i++) { visualization_msgs::Marker source; source.header.frame_id = fixed_frame; source.header.stamp = ros::Time::now(); source.id = i; source.ns = "gas_source_visualization"; source.action = visualization_msgs::Marker::ADD; //source.type = visualization_msgs::Marker::CYLINDER; source.type = visualization_msgs::Marker::CUBE; source.scale.x = gas_source_scale[i]; source.scale.y = gas_source_scale[i]; source.scale.z = gas_source_pos_z[i]; source.color.r = gas_source_color[i][0]; source.color.g = gas_source_color[i][1]; source.color.b = gas_source_color[i][2]; source.color.a = 1.0; source.pose.position.x = gas_source_pos_x[i]; source.pose.position.y = gas_source_pos_y[i]; source.pose.position.z = gas_source_pos_z[i]/2; source.pose.orientation.x = 0.0; source.pose.orientation.y = 0.0; source.pose.orientation.z = 1.0; source.pose.orientation.w = 1.0; //Add Marker to array gas_source_markers.markers.push_back(source); } // Small sleep to allow RVIZ to startup ros::Duration(1.0).sleep(); //--------------- // LOOP //--------------- ros::Rate r(0.3); //Just to refresh from time to time while (ros::ok()) { //Publish CAD Markers environmnet_cad_pub.publish(CAD_model_markers); // Publish 3D Occupancy if (occupancy3D_data != "") environmnet_pub.publish(environment); //Publish Gas Sources gas_source_pub.publish(gas_source_markers); ros::spinOnce(); r.sleep(); } } // ===============================// // Load Node parameters // // ===============================// void Environment::loadNodeParameters(ros::NodeHandle private_nh) { private_nh.param<bool>("verbose", verbose, false); if (verbose) ROS_INFO("[env] The data provided in the roslaunch file is:"); private_nh.param<bool>("wait_preprocessing", wait_preprocessing, false); if (verbose) ROS_INFO("[env] wait_preprocessing: %u",wait_preprocessing); private_nh.param<std::string>("fixed_frame", fixed_frame, "map"); if (verbose) ROS_INFO("[env] Fixed Frame: %s",fixed_frame.c_str()); private_nh.param<int>("number_of_sources", number_of_sources, 0); if (verbose) ROS_INFO("[env] number_of_sources: %i",number_of_sources); gas_source_pos_x.resize(number_of_sources); gas_source_pos_y.resize(number_of_sources); gas_source_pos_z.resize(number_of_sources); gas_source_scale.resize(number_of_sources); gas_source_color.resize(number_of_sources); for(int i=0;i<number_of_sources;i++) { //Get location of soruce for instance (i) std::string paramNameX = boost::str( boost::format("source_%i_position_x") % i); std::string paramNameY = boost::str( boost::format("source_%i_position_y") % i); std::string paramNameZ = boost::str( boost::format("source_%i_position_z") % i); std::string scale = boost::str( boost::format("source_%i_scale") % i); std::string color = boost::str( boost::format("source_%i_color") % i); private_nh.param<double>(paramNameX.c_str(), gas_source_pos_x[i], 0.0); private_nh.param<double>(paramNameY.c_str(), gas_source_pos_y[i], 0.0); private_nh.param<double>(paramNameZ.c_str(), gas_source_pos_z[i], 0.0); private_nh.param<double>(scale.c_str(), gas_source_scale[i], 0.1); gas_source_color[i].resize(3); private_nh.getParam(color.c_str(),gas_source_color[i]); if (verbose) ROS_INFO("[env] Gas_source(%i): pos=[%0.2f %0.2f %0.2f] scale=%.2f color=[%0.2f %0.2f %0.2f]", i, gas_source_pos_x[i], gas_source_pos_y[i], gas_source_pos_z[i], gas_source_scale[i], gas_source_color[i][0],gas_source_color[i][1],gas_source_color[i][2]); } // CAD MODELS //------------- //CAD model files private_nh.param<int>("number_of_CAD", number_of_CAD, 0); if (verbose) ROS_INFO("[env] number_of_CAD: %i",number_of_CAD); CAD_models.resize(number_of_CAD); CAD_color.resize(number_of_CAD); for(int i=0;i<number_of_CAD;i++) { //Get location of CAD file for instance (i) std::string paramName = boost::str( boost::format("CAD_%i") % i); std::string paramColor = boost::str( boost::format("CAD_%i_color") % i); private_nh.param<std::string>(paramName.c_str(), CAD_models[i], ""); CAD_color[i].resize(3); private_nh.getParam(paramColor.c_str(),CAD_color[i]); if (verbose) ROS_INFO("[env] CAD_models(%i): %s",i, CAD_models[i].c_str()); } //Occupancy 3D gridmap //--------------------- private_nh.param<std::string>("occupancy3D_data", occupancy3D_data, ""); if (verbose) ROS_INFO("[env] Occupancy3D file location: %s",occupancy3D_data.c_str()); } //=========================// // PreProcessing CallBack // //=========================// void Environment::PreprocessingCB(const std_msgs::Bool& b) { preprocessing_done = true; } void Environment::readEnvFile() { if(occupancy3D_data==""){ ROS_ERROR(" [GADEN_PLAYER] No occupancy file specified. Use the parameter \"occupancyFile\" to input the path to the OccupancyGrid3D.csv file.\n"); return; } //open file std::ifstream infile(occupancy3D_data.c_str()); std::string line; //read the header { //Line 1 (min values of environment) std::getline(infile, line); size_t pos = line.find(" "); line.erase(0, pos+1); pos = line.find(" "); env_min_x = atof(line.substr(0, pos).c_str()); line.erase(0, pos+1); pos = line.find(" "); env_min_y = atof(line.substr(0, pos).c_str()); env_min_z = atof(line.substr(pos+1).c_str()); //Line 2 (max values of environment) std::getline(infile, line); pos = line.find(" "); line.erase(0, pos+1); pos = line.find(" "); env_max_x = atof(line.substr(0, pos).c_str()); line.erase(0, pos+1); pos = line.find(" "); env_max_y = atof(line.substr(0, pos).c_str()); env_max_z = atof(line.substr(pos+1).c_str()); //Line 3 (Num cells on eahc dimension) std::getline(infile, line); pos = line.find(" "); line.erase(0, pos+1); pos = line.find(" "); env_cells_x = atoi(line.substr(0, pos).c_str()); line.erase(0, pos+1); pos = line.find(" "); env_cells_y = atof(line.substr(0, pos).c_str()); env_cells_z = atof(line.substr(pos+1).c_str()); //Line 4 cell_size (m) std::getline(infile, line); pos = line.find(" "); cell_size = atof(line.substr(pos+1).c_str()); if (verbose) ROS_INFO("[env]Env dimensions (%.2f,%.2f,%.2f)-(%.2f,%.2f,%.2f)",env_min_x, env_min_y, env_min_z, env_max_x, env_max_y, env_max_z ); if (verbose) ROS_INFO("[env]Env size in cells (%d,%d,%d) - with cell size %f [m]",env_cells_x,env_cells_y,env_cells_z, cell_size); } Env.resize(env_cells_x * env_cells_y * env_cells_z); if (verbose) ROS_INFO("[env]Env.resize command, line 283"); int x_idx = 0; int y_idx = 0; int z_idx = 0; while ( std::getline(infile, line) ) { std::stringstream ss(line); if (z_idx >=env_cells_z) { ROS_ERROR("Trying to read:[%s]",line.c_str()); } if (line == ";") { if (verbose) ROS_INFO("[env] z_idx: %d", z_idx); //New Z-layer z_idx++; x_idx = 0; y_idx = 0; } else { //New line with constant x_idx and all the y_idx values while (ss) { int f; ss >> std::skipws >> f; Env[indexFrom3D(x_idx,y_idx,z_idx)] = f; y_idx++; } //Line has ended x_idx++; if (verbose) ROS_INFO("[env] x_idx: %d", x_idx); y_idx = 0; } } if (verbose) ROS_INFO("[env]before infile.close line 327"); infile.close(); if (verbose) ROS_INFO("[env]after infile.close line 329"); } /* Load environment from 3DOccupancy.csv GridMap * Loads the environment file containing a description of the simulated environment in the CFD (for the estimation of the wind flows), and displays it. * As a general rule, environment files set a value of "0" for a free cell, "1" for a ocuppiedd cell and "2" for outlet. * This function creates a cube marker for every occupied cell, with the corresponding dimensions */ void Environment::loadEnvironment(visualization_msgs::MarkerArray &env_marker) { // Wait for the GADEN_preprocessin node to finish? if( wait_preprocessing ) { while(ros::ok() && !preprocessing_done) { ros::Duration(0.5).sleep(); ros::spinOnce(); if (verbose) ROS_INFO("[environment] Waiting for node GADEN_preprocessing to end."); } } readEnvFile(); if (verbose) ROS_INFO("[env]readEnvFile completed, line 342"); for ( int i = 0; i<env_cells_x; i++) { for ( int j = 0; j<env_cells_y; j++) { for ( int k = 0; k<env_cells_z; k++) { //Color if (!Env[indexFrom3D(i,j,k)]) { //Add a new cube marker for this occupied cell visualization_msgs::Marker new_marker; new_marker.header.frame_id = fixed_frame; new_marker.header.stamp = ros::Time::now(); new_marker.ns = "environment_visualization"; new_marker.id = indexFrom3D(i,j,k); //unique identifier new_marker.type = visualization_msgs::Marker::CUBE; new_marker.action = visualization_msgs::Marker::ADD; //Center of the cell new_marker.pose.position.x = env_min_x + ( (i + 0.5) * cell_size); new_marker.pose.position.y = env_min_y + ( (j + 0.5) * cell_size); new_marker.pose.position.z = env_min_z + ( (k + 0.5) * cell_size); new_marker.pose.orientation.x = 0.0; new_marker.pose.orientation.y = 0.0; new_marker.pose.orientation.z = 0.0; new_marker.pose.orientation.w = 1.0; //Size of the cell new_marker.scale.x = cell_size; new_marker.scale.y = cell_size; new_marker.scale.z = cell_size; new_marker.color.r = 0.9f; new_marker.color.g = 0.1f; new_marker.color.b = 0.1f; new_marker.color.a = 1.0; env_marker.markers.push_back(new_marker); } } } } } bool Environment::occupancyMapServiceCB(gaden_environment::OccupancyRequest& request, gaden_environment::OccupancyResponse& response) { response.origin.x = env_min_x; response.origin.y = env_min_y; response.origin.z = env_min_z; response.numCellsX = env_cells_x; response.numCellsY = env_cells_y; response.numCellsZ = env_cells_z; response.resolution = cell_size; response.occupancy = Env; return true; } int Environment::indexFrom3D(int x, int y, int z){ return x + y*env_cells_x + z*env_cells_x*env_cells_y; }
14,700
C++
34.509662
155
0.566599
tudelft/autoGDMplus/gaden_ws/src/gaden/gaden_environment/include/environment/environment.h
#pragma once #include <ros/ros.h> #include <std_msgs/Bool.h> #include <visualization_msgs/Marker.h> #include <visualization_msgs/MarkerArray.h> #include <resource_retriever/retriever.h> #include <cmath> #include <vector> #include <fstream> #include <boost/format.hpp> #include <gaden_environment/Occupancy.h> class Environment { public: void run(); private: //Gas Sources int number_of_sources; std::vector<double> gas_source_pos_x; std::vector<double> gas_source_pos_y; std::vector<double> gas_source_pos_z; std::vector<double> gas_source_scale; std::vector< std::vector<double> > gas_source_color; //CAD models int number_of_CAD; std::vector<std::string> CAD_models; std::vector< std::vector<double> > CAD_color; //Environment 3D std::vector<uint8_t> Env; std::string occupancy3D_data; //Location of the 3D Occupancy GridMap of the environment std::string fixed_frame; //Frame where to publish the markers int env_cells_x; //cells int env_cells_y; //cells int env_cells_z; //cells double env_min_x; //[m] double env_max_x; //[m] double env_min_y; //[m] double env_max_y; //[m] double env_min_z; //[m] double env_max_z; //[m] double cell_size; //[m] bool verbose; bool wait_preprocessing; bool preprocessing_done; //Methods void loadNodeParameters(ros::NodeHandle); void loadEnvironment(visualization_msgs::MarkerArray &env_marker); void readEnvFile(); bool occupancyMapServiceCB(gaden_environment::OccupancyRequest& request, gaden_environment::OccupancyResponse& response); int indexFrom3D(int x, int y, int z); void PreprocessingCB(const std_msgs::Bool& b); };
2,074
C
31.936507
125
0.562681
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/CHANGELOG.rst
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package map_server ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.17.3 (2023-01-10) ------------------- * [ROS-O] various patches (`#1225 <https://github.com/ros-planning/navigation/issues/1225>`_) * do not specify obsolete c++11 standard this breaks with current versions of log4cxx. * update pluginlib include paths the non-hpp headers have been deprecated since kinetic * use lambdas in favor of boost::bind Using boost's _1 as a global system is deprecated since C++11. The ROS packages in Debian removed the implicit support for the global symbols, so this code fails to compile there without the patch. * Contributors: Michael Görner 1.17.2 (2022-06-20) ------------------- * Change_map service to map_server [Rebase/Noetic] (`#1029 <https://github.com/ros-planning/navigation/issues/1029>`_) * Refactored map loading from constructor to three methods * Added change_map service using LoadMap.srv * map_server: Initialise a NodeHandle in main. (`#1122 <https://github.com/ros-planning/navigation/issues/1122>`_) * Add debug output regarding waiting for time (`#1078 <https://github.com/ros-planning/navigation/issues/1078>`_) Added debug messages suggested in https://github.com/ros-planning/navigation/issues/1074#issuecomment-751557177. Makes it easier to discover if use_sim_time is true but no clock server is running * crop_map: Fix extra pixel origin shift up every cropping (`#1064 <https://github.com/ros-planning/navigation/issues/1064>`_) (`#1067 <https://github.com/ros-planning/navigation/issues/1067>`_) Co-authored-by: Pavlo Kolomiiets <[email protected]> * (map_server) add rtest dependency to tests (`#1061 <https://github.com/ros-planning/navigation/issues/1061>`_) * [noetic] MapServer variable cleanup: Precursor for `#1029 <https://github.com/ros-planning/navigation/issues/1029>`_ (`#1043 <https://github.com/ros-planning/navigation/issues/1043>`_) * Contributors: Christian Fritz, David V. Lu!!, Matthijs van der Burgh, Nikos Koukis, Pavlo Kolomiiets 1.17.1 (2020-08-27) ------------------- * Initial map_server map_mode tests (`#1006 <https://github.com/ros-planning/navigation/issues/1006>`_) * [noetic] Adding CMake way to find yaml-cpp (`#998 <https://github.com/ros-planning/navigation/issues/998>`_) * Contributors: David V. Lu!!, Sean Yen 1.17.0 (2020-04-02) ------------------- * Merge pull request `#982 <https://github.com/ros-planning/navigation/issues/982>`_ from ros-planning/noetic_prep Noetic Migration * increase required cmake version * Contributors: Michael Ferguson 1.16.6 (2020-03-18) ------------------- 1.16.5 (2020-03-15) ------------------- * [melodic] updated install for better portability. (`#973 <https://github.com/ros-planning/navigation/issues/973>`_) * Contributors: Sean Yen 1.16.4 (2020-03-04) ------------------- 1.16.3 (2019-11-15) ------------------- * Merge branch 'melodic-devel' into layer_clear_area-melodic * Merge pull request `#850 <https://github.com/ros-planning/navigation/issues/850>`_ from seanyen/map_server_windows_fix [Windows][melodic] map_server Windows build bring up * map_server Windows build bring up * Fix install location for Windows build. (On Windows build, shared library uses RUNTIME location, but not LIBRARY) * Use boost::filesystem::path to handle path logic and remove the libgen.h dependency for better cross platform. * Fix gtest hard-coded and add YAML library dir in CMakeList.txt. * Contributors: Michael Ferguson, Sean Yen, Steven Macenski 1.16.2 (2018-07-31) ------------------- 1.16.1 (2018-07-28) ------------------- 1.16.0 (2018-07-25) ------------------- * Merge pull request `#735 <https://github.com/ros-planning/navigation/issues/735>`_ from ros-planning/melodic_708 Allow specification of free/occupied thresholds for map_saver (`#708 <https://github.com/ros-planning/navigation/issues/708>`_) * Allow specification of free/occupied thresholds for map_saver (`#708 <https://github.com/ros-planning/navigation/issues/708>`_) * add occupied threshold command line parameter to map_saver (--occ) * add free threshold command line parameter to map_saver (--free) * Merge pull request `#704 <https://github.com/ros-planning/navigation/issues/704>`_ from DLu/fix573_lunar Map server wait for a valid time fix [lunar] * Map server wait for a valid time, fix `#573 <https://github.com/ros-planning/navigation/issues/573>`_ (`#700 <https://github.com/ros-planning/navigation/issues/700>`_) When launching the map_server with Gazebo, the current time is picked before the simulation is started and then has a value of 0. Later when querying the stamp of the map, a value of has a special signification on tf transform for example. * Contributors: Michael Ferguson, Romain Reignier, ipa-fez 1.15.2 (2018-03-22) ------------------- * Merge pull request `#673 <https://github.com/ros-planning/navigation/issues/673>`_ from ros-planning/email_update_lunar update maintainer email (lunar) * Merge pull request `#649 <https://github.com/ros-planning/navigation/issues/649>`_ from aaronhoy/lunar_add_ahoy Add myself as a maintainer. * Rebase PRs from Indigo/Kinetic (`#637 <https://github.com/ros-planning/navigation/issues/637>`_) * Respect planner_frequency intended behavior (`#622 <https://github.com/ros-planning/navigation/issues/622>`_) * Only do a getRobotPose when no start pose is given (`#628 <https://github.com/ros-planning/navigation/issues/628>`_) Omit the unnecessary call to getRobotPose when the start pose was already given, so that move_base can also generate a path in situations where getRobotPose would fail. This is actually to work around an issue of getRobotPose randomly failing. * Update gradient_path.cpp (`#576 <https://github.com/ros-planning/navigation/issues/576>`_) * Update gradient_path.cpp * Update navfn.cpp * update to use non deprecated pluginlib macro (`#630 <https://github.com/ros-planning/navigation/issues/630>`_) * update to use non deprecated pluginlib macro * multiline version as well * Print SDL error on IMG_Load failure in server_map (`#631 <https://github.com/ros-planning/navigation/issues/631>`_) * Use occupancy values when saving a map (`#613 <https://github.com/ros-planning/navigation/issues/613>`_) * Closes `#625 <https://github.com/ros-planning/navigation/issues/625>`_ (`#627 <https://github.com/ros-planning/navigation/issues/627>`_) * Contributors: Aaron Hoy, David V. Lu!!, Hunter Allen, Michael Ferguson 1.15.1 (2017-08-14) ------------------- * remove offending library export (fixes `#612 <https://github.com/ros-planning/navigation/issues/612>`_) * Contributors: Michael Ferguson 1.15.0 (2017-08-07) ------------------- * Fix compiler warning for GCC 8. * convert packages to format2 * Merge pull request `#596 <https://github.com/ros-planning/navigation/issues/596>`_ from ros-planning/lunar_548 * refactor to not use tf version 1 (`#561 <https://github.com/ros-planning/navigation/issues/561>`_) * Fix CMakeLists + package.xmls (`#548 <https://github.com/ros-planning/navigation/issues/548>`_) * Merge pull request `#560 <https://github.com/ros-planning/navigation/issues/560>`_ from wjwwood/map_server_fixup_cmake * update to support Python 2 and 3 (`#559 <https://github.com/ros-planning/navigation/issues/559>`_) * remove duplicate and unreferenced file (`#558 <https://github.com/ros-planning/navigation/issues/558>`_) * remove trailing whitespace from map_server package (`#557 <https://github.com/ros-planning/navigation/issues/557>`_) * fix cmake use of yaml-cpp and sdl / sdl-image * Fix CMake warnings * Contributors: Hunter L. Allen, Martin Günther, Michael Ferguson, Mikael Arguedas, Vincent Rabaud, William Woodall 1.14.0 (2016-05-20) ------------------- * Corrections to alpha channel detection and usage. Changing to actually detect whether the image has an alpha channel instead of inferring based on the number of channels. Also reverting to legacy behavior of trinary mode overriding alpha removal. This will cause the alpha channel to be averaged in with the others in trinary mode, which is the current behavior before this PR. * Removing some trailing whitespace. * Use enum to control map interpretation * Contributors: Aaron Hoy, David Lu 1.13.1 (2015-10-29) ------------------- 1.13.0 (2015-03-17) ------------------- * rename image_loader library, fixes `#208 <https://github.com/ros-planning/navigation/issues/208>`_ * Contributors: Michael Ferguson 1.12.0 (2015-02-04) ------------------- * update maintainer email * Contributors: Michael Ferguson 1.11.15 (2015-02-03) -------------------- 1.11.14 (2014-12-05) -------------------- * prevent inf loop * Contributors: Jeremie Deray 1.11.13 (2014-10-02) -------------------- 1.11.12 (2014-10-01) -------------------- * map_server: [style] alphabetize dependencies * map_server: remove vestigial export line the removed line does not do anything in catkin * Contributors: William Woodall 1.11.11 (2014-07-23) -------------------- 1.11.10 (2014-06-25) -------------------- 1.11.9 (2014-06-10) ------------------- 1.11.8 (2014-05-21) ------------------- * fix build, was broken by `#175 <https://github.com/ros-planning/navigation/issues/175>`_ * Contributors: Michael Ferguson 1.11.7 (2014-05-21) ------------------- * make rostest in CMakeLists optional * Contributors: Lukas Bulwahn 1.11.5 (2014-01-30) ------------------- * install crop map * removing .py from executable script * Map Server can serve maps with non-lethal values * Added support for YAML-CPP 0.5+. The new yaml-cpp API removes the "node >> outputvar;" operator, and it has a new way of loading documents. There's no version hint in the library's headers, so I'm getting the version number from pkg-config. * check for CATKIN_ENABLE_TESTING * Change maintainer from Hersh to Lu 1.11.4 (2013-09-27) ------------------- * prefix utest target to not collide with other targets * Package URL Updates * unique target names to avoid conflicts (e.g. with map-store)
10,034
reStructuredText
46.112676
197
0.70012
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/rtest.cpp
/* * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* Author: Brian Gerkey */ #include <gtest/gtest.h> #include <ros/service.h> #include <ros/ros.h> #include <ros/package.h> #include <nav_msgs/GetMap.h> #include <nav_msgs/OccupancyGrid.h> #include <nav_msgs/MapMetaData.h> #include <nav_msgs/LoadMap.h> #include "test_constants.h" int g_argc; char** g_argv; class MapClientTest : public testing::Test { public: // A node is needed to make a service call ros::NodeHandle* n_; MapClientTest() { ros::init(g_argc, g_argv, "map_client_test"); n_ = new ros::NodeHandle(); got_map_ = false; got_map_metadata_ = false; } ~MapClientTest() { delete n_; } bool got_map_; boost::shared_ptr<nav_msgs::OccupancyGrid const> map_; void mapCallback(const boost::shared_ptr<nav_msgs::OccupancyGrid const>& map) { map_ = map; got_map_ = true; } bool got_map_metadata_; boost::shared_ptr<nav_msgs::MapMetaData const> map_metadata_; void mapMetaDataCallback(const boost::shared_ptr<nav_msgs::MapMetaData const>& map_metadata) { map_metadata_ = map_metadata; got_map_metadata_ = true; } }; /* Try to retrieve the map via service, and compare to ground truth */ TEST_F(MapClientTest, call_service) { nav_msgs::GetMap::Request req; nav_msgs::GetMap::Response resp; ASSERT_TRUE(ros::service::waitForService("static_map", 5000)); ASSERT_TRUE(ros::service::call("static_map", req, resp)); ASSERT_FLOAT_EQ(resp.map.info.resolution, g_valid_image_res); ASSERT_EQ(resp.map.info.width, g_valid_image_width); ASSERT_EQ(resp.map.info.height, g_valid_image_height); ASSERT_STREQ(resp.map.header.frame_id.c_str(), "map"); for(unsigned int i=0; i < resp.map.info.width * resp.map.info.height; i++) ASSERT_EQ(g_valid_image_content[i], resp.map.data[i]); } /* Try to retrieve the map via topic, and compare to ground truth */ TEST_F(MapClientTest, subscribe_topic) { ros::Subscriber sub = n_->subscribe<nav_msgs::OccupancyGrid>("map", 1, [this](auto& map){ mapCallback(map); }); // Try a few times, because the server may not be up yet. int i=20; while(!got_map_ && i > 0) { ros::spinOnce(); ros::Duration d = ros::Duration().fromSec(0.25); d.sleep(); i--; } ASSERT_TRUE(got_map_); ASSERT_FLOAT_EQ(map_->info.resolution, g_valid_image_res); ASSERT_EQ(map_->info.width, g_valid_image_width); ASSERT_EQ(map_->info.height, g_valid_image_height); ASSERT_STREQ(map_->header.frame_id.c_str(), "map"); for(unsigned int i=0; i < map_->info.width * map_->info.height; i++) ASSERT_EQ(g_valid_image_content[i], map_->data[i]); } /* Try to retrieve the metadata via topic, and compare to ground truth */ TEST_F(MapClientTest, subscribe_topic_metadata) { ros::Subscriber sub = n_->subscribe<nav_msgs::MapMetaData>("map_metadata", 1, [this](auto& map_metadata){ mapMetaDataCallback(map_metadata); }); // Try a few times, because the server may not be up yet. int i=20; while(!got_map_metadata_ && i > 0) { ros::spinOnce(); ros::Duration d = ros::Duration().fromSec(0.25); d.sleep(); i--; } ASSERT_TRUE(got_map_metadata_); ASSERT_FLOAT_EQ(map_metadata_->resolution, g_valid_image_res); ASSERT_EQ(map_metadata_->width, g_valid_image_width); ASSERT_EQ(map_metadata_->height, g_valid_image_height); } /* Change the map, retrieve the map via topic, and compare to ground truth */ TEST_F(MapClientTest, change_map) { ros::Subscriber sub = n_->subscribe<nav_msgs::OccupancyGrid>("map", 1, [this](auto& map){ mapCallback(map); }); // Try a few times, because the server may not be up yet. for (int i = 20; i > 0 && !got_map_; i--) { ros::spinOnce(); ros::Duration d = ros::Duration().fromSec(0.25); d.sleep(); } ASSERT_TRUE(got_map_); // Now change the map got_map_ = false; nav_msgs::LoadMap::Request req; nav_msgs::LoadMap::Response resp; req.map_url = ros::package::getPath("map_server") + "/test/testmap2.yaml"; ASSERT_TRUE(ros::service::waitForService("change_map", 5000)); ASSERT_TRUE(ros::service::call("change_map", req, resp)); ASSERT_EQ(0u, resp.result); for (int i = 20; i > 0 && !got_map_; i--) { ros::spinOnce(); ros::Duration d = ros::Duration().fromSec(0.25); d.sleep(); } ASSERT_FLOAT_EQ(tmap2::g_valid_image_res, map_->info.resolution); ASSERT_EQ(tmap2::g_valid_image_width, map_->info.width); ASSERT_EQ(tmap2::g_valid_image_height, map_->info.height); ASSERT_STREQ("map", map_->header.frame_id.c_str()); for(unsigned int i=0; i < map_->info.width * map_->info.height; i++) ASSERT_EQ(tmap2::g_valid_image_content[i], map_->data[i]) << "idx:" << i; //Put the old map back so the next test isn't broken got_map_ = false; req.map_url = ros::package::getPath("map_server") + "/test/testmap.yaml"; ASSERT_TRUE(ros::service::call("change_map", req, resp)); ASSERT_EQ(0u, resp.result); for (int i = 20; i > 0 && !got_map_; i--) { ros::spinOnce(); ros::Duration d = ros::Duration().fromSec(0.25); d.sleep(); } ASSERT_TRUE(got_map_); } int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); g_argc = argc; g_argv = argv; return RUN_ALL_TESTS(); }
6,837
C++
33.361809
146
0.668568
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/testmap2.yaml
image: testmap2.png resolution: 0.1 origin: [-2.0, -3.0, -1.0] negate: 1 occupied_thresh: 0.5 free_thresh: 0.2
111
YAML
14.999998
26
0.675676
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/testmap.yaml
image: testmap.png resolution: 0.1 origin: [2.0, 3.0, 1.0] negate: 0 occupied_thresh: 0.65 free_thresh: 0.196
110
YAML
14.857141
23
0.7
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/utest.cpp
/* * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* Author: Brian Gerkey */ #include <stdexcept> // for std::runtime_error #include <gtest/gtest.h> #include "map_server/image_loader.h" #include "test_constants.h" /* Try to load a valid PNG file. Succeeds if no exception is thrown, and if * the loaded image matches the known dimensions and content of the file. * * This test can fail on OS X, due to an apparent limitation of the * underlying SDL_Image library. */ TEST(MapServer, loadValidPNG) { try { nav_msgs::GetMap::Response map_resp; double origin[3] = { 0.0, 0.0, 0.0 }; map_server::loadMapFromFile(&map_resp, g_valid_png_file, g_valid_image_res, false, 0.65, 0.1, origin); EXPECT_FLOAT_EQ(map_resp.map.info.resolution, g_valid_image_res); EXPECT_EQ(map_resp.map.info.width, g_valid_image_width); EXPECT_EQ(map_resp.map.info.height, g_valid_image_height); for(unsigned int i=0; i < map_resp.map.info.width * map_resp.map.info.height; i++) EXPECT_EQ(g_valid_image_content[i], map_resp.map.data[i]); } catch(...) { ADD_FAILURE() << "Uncaught exception : " << "This is OK on OS X"; } } /* Try to load a valid BMP file. Succeeds if no exception is thrown, and if * the loaded image matches the known dimensions and content of the file. */ TEST(MapServer, loadValidBMP) { try { nav_msgs::GetMap::Response map_resp; double origin[3] = { 0.0, 0.0, 0.0 }; map_server::loadMapFromFile(&map_resp, g_valid_bmp_file, g_valid_image_res, false, 0.65, 0.1, origin); EXPECT_FLOAT_EQ(map_resp.map.info.resolution, g_valid_image_res); EXPECT_EQ(map_resp.map.info.width, g_valid_image_width); EXPECT_EQ(map_resp.map.info.height, g_valid_image_height); for(unsigned int i=0; i < map_resp.map.info.width * map_resp.map.info.height; i++) EXPECT_EQ(g_valid_image_content[i], map_resp.map.data[i]); } catch(...) { ADD_FAILURE() << "Uncaught exception"; } } /* Try to load an invalid file. Succeeds if a std::runtime_error exception * is thrown. */ TEST(MapServer, loadInvalidFile) { try { nav_msgs::GetMap::Response map_resp; double origin[3] = { 0.0, 0.0, 0.0 }; map_server::loadMapFromFile(&map_resp, "foo", 0.1, false, 0.65, 0.1, origin); } catch(std::runtime_error &e) { SUCCEED(); return; } catch(...) { FAIL() << "Uncaught exception"; } ADD_FAILURE() << "Didn't throw exception as expected"; } std::vector<unsigned int> countValues(const nav_msgs::GetMap::Response& map_resp) { std::vector<unsigned int> counts(256, 0); for (unsigned int i = 0; i < map_resp.map.data.size(); i++) { unsigned char value = static_cast<unsigned char>(map_resp.map.data[i]); counts[value]++; } return counts; } TEST(MapServer, testMapMode) { nav_msgs::GetMap::Response map_resp; double origin[3] = { 0.0, 0.0, 0.0 }; map_server::loadMapFromFile(&map_resp, g_spectrum_png_file, 0.1, false, 0.65, 0.1, origin, TRINARY); std::vector<unsigned int> trinary_counts = countValues(map_resp); EXPECT_EQ(90u, trinary_counts[100]); EXPECT_EQ(26u, trinary_counts[0]); EXPECT_EQ(140u, trinary_counts[255]); map_server::loadMapFromFile(&map_resp, g_spectrum_png_file, 0.1, false, 0.65, 0.1, origin, SCALE); std::vector<unsigned int> scale_counts = countValues(map_resp); EXPECT_EQ(90u, scale_counts[100]); EXPECT_EQ(26u, scale_counts[0]); unsigned int scaled_values = 0; for (unsigned int i = 1; i < 100; i++) { scaled_values += scale_counts[i]; } EXPECT_EQ(140u, scaled_values); map_server::loadMapFromFile(&map_resp, g_spectrum_png_file, 0.1, false, 0.65, 0.1, origin, RAW); std::vector<unsigned int> raw_counts = countValues(map_resp); for (unsigned int i = 0; i < raw_counts.size(); i++) { EXPECT_EQ(1u, raw_counts[i]) << i; } } int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
5,484
C++
35.566666
106
0.684537
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/test_constants.cpp
/* * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* Author: Brian Gerkey */ /* This file contains global constants shared among tests */ /* Note that these must be changed if the test image changes */ #include "test_constants.h" const unsigned int g_valid_image_width = 10; const unsigned int g_valid_image_height = 10; // Note that the image content is given in row-major order, with the // lower-left pixel first. This is different from a graphics coordinate // system, which starts with the upper-left pixel. The loadMapFromFile // call converts from the latter to the former when it loads the image, and // we want to compare against the result of that conversion. const char g_valid_image_content[] = { 0,0,0,0,0,0,0,0,0,0, 100,100,100,100,0,0,100,100,100,0, 100,100,100,100,0,0,100,100,100,0, 100,0,0,0,0,0,0,0,0,0, 100,0,0,0,0,0,0,0,0,0, 100,0,0,0,0,0,100,100,0,0, 100,0,0,0,0,0,100,100,0,0, 100,0,0,0,0,0,100,100,0,0, 100,0,0,0,0,0,100,100,0,0, 100,0,0,0,0,0,0,0,0,0, }; const char* g_valid_png_file = "test/testmap.png"; const char* g_valid_bmp_file = "test/testmap.bmp"; const char* g_spectrum_png_file = "test/spectrum.png"; const float g_valid_image_res = 0.1; // Constants for testmap2 namespace tmap2 { const char g_valid_image_content[] = { 100,100,100,100,100,100,100,100,100,100,100,100, 100,0,0,0,0,0,0,0,0,0,0,100, 100,0,100,100,100,100,100,100,100,100,0,100, 100,0,100,0,0,0,0,0,0,100,0,100, 100,0,0,0,0,0,0,0,0,0,0,100, 100,0,0,0,0,0,0,0,0,0,0,100, 100,0,0,0,0,0,0,0,0,0,0,100, 100,0,0,0,0,0,0,0,0,0,0,100, 100,0,0,0,0,0,0,0,0,0,0,100, 100,0,100,0,0,0,0,0,0,100,0,100, 100,0,0,0,0,0,0,0,0,0,0,100, 100,100,100,100,100,100,100,100,100,100,100,100, }; const float g_valid_image_res = 0.1; const unsigned int g_valid_image_width = 12; const unsigned int g_valid_image_height = 12; }
3,407
C++
39.094117
78
0.709715
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/rtest.xml
<launch> <node name="map_server" pkg="map_server" type="map_server" args="$(find map_server)/test/testmap.yaml"/> <test test-name="map_server_test" pkg="map_server" type="rtest"/> </launch>
197
XML
23.749997
106
0.670051
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/test_constants.h
/* * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the Willow Garage, Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef MAP_SERVER_TEST_CONSTANTS_H #define MAP_SERVER_TEST_CONSTANTS_H /* Author: Brian Gerkey */ /* This file externs global constants shared among tests */ extern const unsigned int g_valid_image_width; extern const unsigned int g_valid_image_height; extern const char g_valid_image_content[]; extern const char* g_valid_png_file; extern const char* g_valid_bmp_file; extern const float g_valid_image_res; extern const char* g_spectrum_png_file; namespace tmap2 { extern const char g_valid_image_content[]; extern const float g_valid_image_res; extern const unsigned int g_valid_image_width; extern const unsigned int g_valid_image_height; } #endif
2,276
C
42.788461
78
0.755272
tudelft/autoGDMplus/gaden_ws/src/gaden/map_server/test/consumer.py
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the Willow Garage nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # from __future__ import print_function PKG = 'static_map_server' NAME = 'consumer' import sys import unittest import time import rospy import rostest from nav_msgs.srv import GetMap class TestConsumer(unittest.TestCase): def __init__(self, *args): super(TestConsumer, self).__init__(*args) self.success = False def callback(self, data): print(rospy.get_caller_id(), "I heard %s" % data.data) self.success = data.data and data.data.startswith('hello world') rospy.signal_shutdown('test done') def test_consumer(self): rospy.wait_for_service('static_map') mapsrv = rospy.ServiceProxy('static_map', GetMap) resp = mapsrv() self.success = True print(resp) while not rospy.is_shutdown() and not self.success: # and time.time() < timeout_t: <== timeout_t doesn't exists?? time.sleep(0.1) self.assert_(self.success) rospy.signal_shutdown('test done') if __name__ == '__main__': rostest.rosrun(PKG, NAME, TestConsumer, sys.argv)
2,688
Python
36.347222
122
0.718378