Skip to content

Commit

Permalink
precommits
Browse files Browse the repository at this point in the history
  • Loading branch information
stepjam committed Jan 31, 2024
1 parent bcfa4c3 commit ea982b5
Show file tree
Hide file tree
Showing 98 changed files with 1,988 additions and 1,528 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,3 @@ ENV/
.mypy_cache/

pyrep/backend/_sim_cffi*

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PyRep has undergone a __MAJOR__ update, and is now compatible with the most rece

## Install

PyRep requires version **4.6.0** of CoppeliaSim. Download:
PyRep requires version **4.6.0** of CoppeliaSim. Download:
- [Ubuntu 20.04](https://downloads.coppeliarobotics.com/V4_6_0_rev16/CoppeliaSim_Edu_V4_6_0_rev16_Ubuntu20_04.tar.xz)
- [Ubuntu 22.04](https://downloads.coppeliarobotics.com/V4_6_0_rev16/CoppeliaSim_Edu_V4_6_0_rev16_Ubuntu22_04.tar.xz)

Expand Down Expand Up @@ -97,7 +97,7 @@ from pyrep import PyRep

pr = PyRep()
# Launch the application with a scene file in headless mode
pr.launch('scene.ttt', headless=True)
pr.launch('scene.ttt', headless=True)
pr.start() # Start the simulation

# Do some stuff
Expand All @@ -113,7 +113,7 @@ pr.shutdown() # Close the application
from pyrep.objects.shape import Shape
from pyrep.const import PrimitiveShape

object = Shape.create(type=PrimitiveShape.CYLINDER,
object = Shape.create(type=PrimitiveShape.CYLINDER,
color=[r,g,b], size=[w, h, d],
position=[x, y, z])
object.set_color([r, g, b])
Expand All @@ -124,7 +124,7 @@ object.set_position([x, y, z])

Robots are designed to be modular; arms are treated separately to grippers.

Use the robot ttm files defined in robots/ttms. These have been altered slightly from the original ones shipped with CoppeliaSim to allow them to be used with motional planning out of the box.
Use the robot ttm files defined in robots/ttms. These have been altered slightly from the original ones shipped with CoppeliaSim to allow them to be used with motional planning out of the box.
The 'tip' of the robot may not be where you want it, so feel free to play around with this.

```python
Expand All @@ -134,7 +134,7 @@ from pyrep.robots.end_effectors.panda_gripper import PandaGripper

pr = PyRep()
# Launch the application with a scene file that contains a robot
pr.launch('scene_with_panda.ttt')
pr.launch('scene_with_panda.ttt')
pr.start() # Start the simulation

arm = Panda() # Get the panda from the scene
Expand All @@ -149,7 +149,7 @@ done = False
while not done:
done = gripper.actuate(0.5, velocity=0.04)
pr.step()

pr.stop() # Stop the simulation
pr.shutdown() # Close the application
```
Expand Down
23 changes: 10 additions & 13 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))

sys.path.insert(0, os.path.abspath("../../"))


# -- Project information -----------------------------------------------------

project = 'PyRep'
copyright = '2019, Stephen James'
author = 'Stephen James'
project = "PyRep"
copyright = "2019, Stephen James"
author = "Stephen James"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.napoleon'
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.coverage", "sphinx.ext.napoleon"]

autodoc_mock_imports = ["pyrep.backend._sim_cffi"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -49,14 +46,14 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

master_doc = 'index'
master_doc = "index"


# -- Extension configuration -------------------------------------------------
80 changes: 44 additions & 36 deletions examples/example_baxter_pick_and_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pyrep.objects.dummy import Dummy
from pyrep.objects.shape import Shape

SCENE_FILE = join(dirname(abspath(__file__)), 'scene_baxter_pick_and_pass.ttt')
SCENE_FILE = join(dirname(abspath(__file__)), "scene_baxter_pick_and_pass.ttt")
pr = PyRep()

pr.launch(SCENE_FILE, headless=False)
Expand All @@ -23,67 +23,73 @@
baxter_gripper_left = BaxterGripper(0)
baxter_gripper_right = BaxterGripper(1)

cup = Shape('Cup')
waypoints = [Dummy('waypoint%d' % i) for i in range(7)]
cup = Shape("Cup")
waypoints = [Dummy("waypoint%d" % i) for i in range(7)]

print('Planning path for left arm to cup ...')
path = baxter_left.get_path(position=waypoints[0].get_position(),
quaternion=waypoints[0].get_quaternion())
print("Planning path for left arm to cup ...")
path = baxter_left.get_path(
position=waypoints[0].get_position(), quaternion=waypoints[0].get_quaternion()
)
path.visualize() # Let's see what the path looks like
print('Executing plan ...')
print("Executing plan ...")
done = False
while not done:
done = path.step()
pr.step()
path.clear_visualization()

print('Planning path closer to cup ...')
path = baxter_left.get_path(position=waypoints[1].get_position(),
quaternion=waypoints[1].get_quaternion())
print('Executing plan ...')
print("Planning path closer to cup ...")
path = baxter_left.get_path(
position=waypoints[1].get_position(), quaternion=waypoints[1].get_quaternion()
)
print("Executing plan ...")
done = False
while not done:
done = path.step()
pr.step()

print('Closing left gripper ...')
print("Closing left gripper ...")
while not baxter_gripper_left.actuate(0.0, 0.4):
pr.step()
baxter_gripper_left.grasp(cup)

print('Planning path to lift cup ...')
path = baxter_left.get_path(position=waypoints[2].get_position(),
quaternion=waypoints[2].get_quaternion(),
ignore_collisions=True)
print('Executing plan ...')
print("Planning path to lift cup ...")
path = baxter_left.get_path(
position=waypoints[2].get_position(),
quaternion=waypoints[2].get_quaternion(),
ignore_collisions=True,
)
print("Executing plan ...")
done = False
while not done:
done = path.step()
pr.step()

print('Planning path for right arm to cup ...')
path = baxter_right.get_path(position=waypoints[3].get_position(),
quaternion=waypoints[3].get_quaternion())
print('Executing Plan ...')
print("Planning path for right arm to cup ...")
path = baxter_right.get_path(
position=waypoints[3].get_position(), quaternion=waypoints[3].get_quaternion()
)
print("Executing Plan ...")
done = False
while not done:
done = path.step()
pr.step()

print('Planning path closer to cup ...')
path = baxter_right.get_path(position=waypoints[4].get_position(),
quaternion=waypoints[4].get_quaternion())
print('Executing plan ...')
print("Planning path closer to cup ...")
path = baxter_right.get_path(
position=waypoints[4].get_position(), quaternion=waypoints[4].get_quaternion()
)
print("Executing plan ...")
done = False
while not done:
done = path.step()
pr.step()

print('Closing right gripper ...')
print("Closing right gripper ...")
while not baxter_gripper_right.actuate(0.0, 0.4):
pr.step()

print('Opening left gripper ...')
print("Opening left gripper ...")
while not baxter_gripper_left.actuate(1.0, 0.4):
pr.step()

Expand All @@ -92,15 +98,17 @@
baxter_gripper_right.grasp(cup)
pr.step()

print('Planning path for left arm to home position ...')
path_l = baxter_left.get_path(position=waypoints[5].get_position(),
quaternion=waypoints[5].get_quaternion())
print("Planning path for left arm to home position ...")
path_l = baxter_left.get_path(
position=waypoints[5].get_position(), quaternion=waypoints[5].get_quaternion()
)

print('Planning path for right arm to home position ...')
path_r = baxter_right.get_path(position=waypoints[6].get_position(),
quaternion=waypoints[6].get_quaternion())
print("Planning path for right arm to home position ...")
path_r = baxter_right.get_path(
position=waypoints[6].get_position(), quaternion=waypoints[6].get_quaternion()
)

print('Executing plan on both arms ...')
print("Executing plan on both arms ...")
done_l = done_r = False
while not done_l or not done_r:
if not done_l:
Expand All @@ -109,7 +117,7 @@
done_r = path_r.step()
pr.step()

print('Done ...')
input('Press enter to finish ...')
print("Done ...")
input("Press enter to finish ...")
pr.stop()
pr.shutdown()
32 changes: 16 additions & 16 deletions examples/example_locobot_stack_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pyrep.objects.shape import Shape
from pyrep.objects.dummy import Dummy

SCENE_FILE = join(dirname(abspath(__file__)), 'scene_locobot_stack_cube.ttt')
SCENE_FILE = join(dirname(abspath(__file__)), "scene_locobot_stack_cube.ttt")
pr = PyRep()
pr.launch(SCENE_FILE, headless=False)
pr.start()
Expand All @@ -35,9 +35,9 @@ def drive_to_position(position, orientation):


def move_arm(position, quaternion, ignore_collisions=False):
arm_path = arm.get_path(position,
quaternion=quaternion,
ignore_collisions=ignore_collisions)
arm_path = arm.get_path(
position, quaternion=quaternion, ignore_collisions=ignore_collisions
)
arm_path.visualize()
done = False
while not done:
Expand All @@ -46,51 +46,51 @@ def move_arm(position, quaternion, ignore_collisions=False):
arm_path.clear_visualization()


cuboid = Shape('cuboid')
goal = Shape('goal')
grasp_point = Dummy('grasp_point')
cuboid = Shape("cuboid")
goal = Shape("goal")
grasp_point = Dummy("grasp_point")

drive_pos = cuboid.get_position()
drive_pos[1] -= 0.3

print('Driving to cube ...')
print("Driving to cube ...")
drive_to_position(drive_pos, 0)

grasp_point_raised = grasp_point.get_position()
grasp_point_raised[2] += 0.075

print('Move arm above cube ...')
print("Move arm above cube ...")
move_arm(grasp_point_raised, grasp_point.get_quaternion())

print('Arm approach cube ...')
print("Arm approach cube ...")
move_arm(grasp_point.get_position(), grasp_point.get_quaternion(), True)

print('Closing gripper ...')
print("Closing gripper ...")
while not gripper.actuate(0.0, 0.4):
pr.step()
gripper.grasp(cuboid)

print('Lift cube ...')
print("Lift cube ...")
move_arm(grasp_point_raised, grasp_point.get_quaternion(), True)

drive_pos = goal.get_position()
drive_pos[1] -= 0.35

print('Driving to goal ...')
print("Driving to goal ...")
drive_to_position(drive_pos, 0)

goal_point_raised = goal.get_position()
goal_point_raised[2] += 0.05

print('Move arm above goal ...')
print("Move arm above goal ...")
move_arm(goal_point_raised, grasp_point.get_quaternion())

print('Drop cube ...')
print("Drop cube ...")
gripper.release()
while not gripper.actuate(1.0, 0.4):
pr.step()

print('Done!')
print("Done!")

pr.stop()
pr.shutdown()
2 changes: 1 addition & 1 deletion examples/example_panda_end_effector_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyrep import PyRep
from pyrep.robots.arms.panda import Panda

SCENE_FILE = join(dirname(abspath(__file__)), 'scene_panda_reach_target.ttt')
SCENE_FILE = join(dirname(abspath(__file__)), "scene_panda_reach_target.ttt")
DELTA = 0.01
pr = PyRep()
pr.launch(SCENE_FILE, headless=False)
Expand Down
10 changes: 6 additions & 4 deletions examples/example_panda_ik.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyrep.errors import IKError
from pyrep.robots.arms.panda import Panda

SCENE_FILE = join(dirname(abspath(__file__)), 'scene_panda_reach_target.ttt')
SCENE_FILE = join(dirname(abspath(__file__)), "scene_panda_reach_target.ttt")
pr = PyRep()
pr.launch(SCENE_FILE, headless=False, responsive_ui=True)
pr.start()
Expand All @@ -26,13 +26,15 @@
except IKError:
# So let's swap to an alternative IK method...
# This returns 'max_configs' number of joint positions
input('Press key to run solve_ik_via_sampling...')
new_joint_pos = agent.solve_ik_via_sampling([x, y, z - 0.4], quaternion=q, max_time_ms=2000)[0]
input("Press key to run solve_ik_via_sampling...")
new_joint_pos = agent.solve_ik_via_sampling(
[x, y, z - 0.4], quaternion=q, max_time_ms=2000
)[0]

# Because the arm is in Forxe/Torque mode, we need to temporarily disable
# dynamics in order to instantaneously move joints.
agent.set_joint_positions(new_joint_pos, disable_dynamics=True)
input('Press any key to finish...')
input("Press any key to finish...")

pr.stop()
pr.shutdown()
Loading

0 comments on commit ea982b5

Please sign in to comment.