Skip to content

Commit

Permalink
Remaining todo: fast planning and opengl3 vision sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
stepjam committed Feb 18, 2024
1 parent f5acb69 commit 23dbbdf
Show file tree
Hide file tree
Showing 54 changed files with 78 additions and 496 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ ENV/
.mypy_cache/

pyrep/backend/_sim_cffi*
system/
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __PyRep is a toolkit for robot learning research, built on top of [CoppeliaSim](

__Announcement!__
PyRep has undergone a __MAJOR__ update, and is now compatible with the most recent version of CoppeliaSim. Most importantly, it now has Mac and Windows support!
Note: Support for mobile bases has temporality been removed as part of the update.


- [Install](#install)
Expand Down Expand Up @@ -46,15 +47,6 @@ Try running one of the examples in the *examples/* folder.

_Although you can use CoppeliaSim on any platform, communication via PyRep is currently only supported on Linux._

#### Troubleshooting

Below are some problems you may encounter during installation. If none of these solve your problem, please raise an issue.

- ModuleNotFoundError: No module named 'pyrep.backend._v_rep_cffi'
- If you are getting this error, then please check that you are not running the interpreter from the project root. If you are, then your Python interpreter will try to import those files rather the installed files.
- error: command 'x86_64-linux-gnu-gcc' failed
- You may be missing packages needed for building python extensions. Try: `sudo apt-get install python3-dev`, and then re-run the installation.

## Running Headless

You can run PyRep/CoppeliaSim headlessly with VirtualGL. VirtualGL is an open source toolkit that gives any Unix or Linux remote display software the ability to run OpenGL applications **with full 3D hardware acceleration**.
Expand Down
4 changes: 2 additions & 2 deletions examples/example_baxter_pick_and_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

baxter_left = BaxterLeft()
baxter_right = BaxterRight()
baxter_gripper_left = BaxterGripper(0)
baxter_gripper_right = BaxterGripper(1)
baxter_gripper_left = BaxterGripper(proxy=baxter_left.joints[0])
baxter_gripper_right = BaxterGripper(proxy=baxter_right.joints[0])

cup = Shape("Cup")
waypoints = [Dummy("waypoint%d" % i) for i in range(7)]
Expand Down
96 changes: 0 additions & 96 deletions examples/example_locobot_stack_cube.py

This file was deleted.

56 changes: 0 additions & 56 deletions examples/example_turtlebot_navigation.py

This file was deleted.

54 changes: 0 additions & 54 deletions examples/example_youbot_navigation.py

This file was deleted.

Binary file modified examples/scene_baxter_pick_and_pass.ttt
Binary file not shown.
Binary file modified examples/scene_locobot_stack_cube.ttt
Binary file not shown.
Binary file modified examples/scene_panda_reach_target.ttt
Binary file not shown.
Binary file modified examples/scene_reinforcement_learning_env.ttt
Binary file not shown.
Binary file modified examples/scene_turtlebot_navigation.ttt
Binary file not shown.
Binary file modified examples/scene_youbot_navigation.ttt
Binary file not shown.
5 changes: 1 addition & 4 deletions pyrep/objects/joint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Tuple, List, Union
from typing import Tuple, List
from pyrep.backend import sim_const as simc
from pyrep.backend import utils
from pyrep.backend.sim import SimBackend
Expand All @@ -14,9 +14,6 @@ class Joint(Object):
screws and spherical joints.
"""

def __init__(self, name_or_handle: Union[str, int]):
super().__init__(name_or_handle)

def _get_requested_type(self) -> ObjectType:
return ObjectType.JOINT

Expand Down
31 changes: 22 additions & 9 deletions pyrep/objects/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pyrep.const import ObjectType
from pyrep.errors import (
WrongObjectTypeError,
CoppeliaSimError,
ObjectIsNotModelError,
ObjectAlreadyRemovedError,
)
Expand All @@ -22,15 +21,29 @@ class Object(object):
Objects are visible in the scene hierarchy and in the scene view.
"""

def __init__(self, name_or_handle: Union[str, int]):
def __init__(
self, name_or_handle: Union[str, int], index: int = 0, proxy: "Object" = None
):
self._sim_api = SimBackend().sim_api
if isinstance(name_or_handle, int):
self._handle = name_or_handle
else:
extra = {}
prefix = "/"
if index > 0:
extra["index"] = 0
if proxy is not None:
prefix = "./"
extra["proxy"] = proxy.get_handle()
try:
self._handle = self._sim_api.getObjectHandle(name_or_handle)
except CoppeliaSimError:
raise ValueError(f"Object with name '{name_or_handle}' not found!")
self._handle = self._sim_api.getObject(name_or_handle, extra)
except Exception:
try:
self._handle = self._sim_api.getObject(
prefix + name_or_handle, extra
)
except Exception:
raise ValueError(f"Object with name '{name_or_handle}' not found!")
assert_type = self._get_requested_type()
actual = ObjectType(self._sim_api.getObjectType(self._handle))
if actual != assert_type:
Expand All @@ -56,7 +69,7 @@ def exists(name: str) -> bool:
sim_api = SimBackend().sim_api
handle = -1
try:
handle = sim_api.getObjectHandle(name)
handle = sim_api.getObject("/" + name)
except Exception:
pass
return handle >= 0
Expand All @@ -70,7 +83,7 @@ def get_object_type(name_or_handle: Union[int, str]) -> ObjectType:
sim_api = SimBackend().sim_api
handle = name_or_handle
if not isinstance(name_or_handle, int):
handle = sim_api.getObjectHandle(name_or_handle)
handle = sim_api.getObject("/" + name_or_handle)
return ObjectType(sim_api.getObjectType(handle))

@staticmethod
Expand Down Expand Up @@ -129,11 +142,11 @@ def get_name(self) -> str:
:return: The objects name.
"""
return self._sim_api.getObjectName(self._handle)
return self._sim_api.getObjectAlias(self._handle, -1)

def set_name(self, name: str) -> None:
"""Sets the objects name in the scene."""
self._sim_api.setObjectName(self._handle, name)
self._sim_api.setObjectAlias(self._handle, name)

def scale_object(self, scale_x: float, scale_y: float, scale_z: float) -> None:
"""Scales the object by the given amounts in the x, y, z axes
Expand Down
6 changes: 3 additions & 3 deletions pyrep/objects/vision_sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import math
from typing import List, Union, Sequence
from typing import List, Sequence
from pyrep.backend.sim import SimBackend
from pyrep.backend import sim_const as simc
from pyrep.objects.object import Object, object_type_to_class
Expand All @@ -10,8 +10,8 @@
class VisionSensor(Object):
"""A camera-type sensor, reacting to light, colors and images."""

def __init__(self, name_or_handle: Union[str, int]):
super().__init__(name_or_handle)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.resolution = self._sim_api.getVisionSensorRes(self._handle)

@staticmethod
Expand Down
8 changes: 0 additions & 8 deletions pyrep/pyrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,6 @@ def get_objects_in_tree(self, root_object=None, *args, **kwargs) -> List[Object]
"""
return Object._get_objects_in_tree(root_object, *args, **kwargs)

def get_collection_handle_by_name(self, collection_name: str) -> int:
"""Retrieves the integer handle for a given collection.
:param collection_name: Name of the collection to retrieve the integer handle.
:return: An integer handle for the collection.
"""
return self._sim_api.getCollectionHandle(collection_name)

def set_configuration_tree(self, config_tree: bytes) -> None:
"""Restores configuration information previously retrieved.
Expand Down
Loading

0 comments on commit 23dbbdf

Please sign in to comment.