mirror of
https://github.com/wassname/pyrobolearn.git
synced 2026-09-10 12:21:16 +08:00
update interfaces, manipulability, robots, world (+add/update corresponding examples)
This commit is contained in:
+14
-2
@@ -2,8 +2,20 @@
|
||||
|
||||
In this folder, you will find different examples on how to use the framework.
|
||||
|
||||
Warning: this folder is currently being updated; few files might still have some bugs or not
|
||||
implemented completely. Some other folders will be added in the upcoming days.
|
||||
|
||||
You can check the following folders:
|
||||
- `worlds`: how to create a world in the simulator, load various objects inside and interact with
|
||||
them, use the camera, and load or generate terrains.
|
||||
- `robots`: check how to load a specific robot (biped, quadruped, wheeled, etc) into the world.
|
||||
- `interfaces`: the various interfaces (game controllers, webcam, etc) and bridges that you can use.
|
||||
- `kinematics`: check how to use forward and inverse kinematics as well as position and velocity control.
|
||||
- `manipulability`: check how to use the velocity and dynamic manipulability ellipsoids.
|
||||
|
||||
- `states`: how to query the states / observations.
|
||||
- `models`: the different learning models that you can use.
|
||||
|
||||
- `imitation`: how to use imitation learning with the framework.
|
||||
- `gym/cartpole`: policies are trained with different algorithms on the gym Cartpole environment.
|
||||
- `robots`: check how to load a specific robot into the world.
|
||||
- `states`: how to query the states / observations.
|
||||
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
## Interfaces
|
||||
## Interfaces and Bridges
|
||||
|
||||
In this folder, you will find examples on what interfaces you can use and on how you can collect the data from them.
|
||||
You will also be able to connect an interface with an element of the world (in this case, a robot) using bridges, and see that different bridges can lead to different behaviors while getting the data from the same interface.
|
||||
You will also be able to connect an interface with an element of the world (in this case, a robot) using bridges,
|
||||
and see that different bridges can lead to different behaviors while getting the data from the same interface.
|
||||
|
||||
Here are few examples that depict the various interfaces:
|
||||
1. `mouse_keyboard.py`: use the mouse keyboard interface
|
||||
2. `webcam.py`: use the webcam interface
|
||||
3. `playstation.py`: use the Playstation joystick controller interface
|
||||
4. `xbox.py`: use the Xbox joystick controller interface
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
"""Load the mouse keyboard interface.
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
|
||||
import pyrobolearn as prl
|
||||
from pyrobolearn.tools.interfaces.mouse_keyboard import MouseKeyboardInterface
|
||||
|
||||
|
||||
# create simulator
|
||||
sim = prl.simulators.Bullet()
|
||||
|
||||
# create mouse keyboard interface
|
||||
interface = MouseKeyboardInterface(sim)
|
||||
|
||||
# run interface
|
||||
for _ in count():
|
||||
# perform a step with the interface
|
||||
interface.step()
|
||||
|
||||
# print pressed keys
|
||||
if len(interface.key_down) > 0:
|
||||
print("Keys that are pressed: {}".format(interface.key_down))
|
||||
|
||||
# perform a step with the simulator
|
||||
sim.step(sleep_time=sim.dt)
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
"""Load the Playstation game controller interface
|
||||
"""
|
||||
|
||||
import time
|
||||
from itertools import count
|
||||
import argparse
|
||||
|
||||
from pyrobolearn.tools.interfaces.controllers.playstation import PS3ControllerInterface, PS4ControllerInterface
|
||||
|
||||
# create parser to select the game controller
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--controller', help='The Playstation game controller to use (ps3 or ps4)', type=str,
|
||||
choices=['ps3', 'ps4'], default='ps4')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# load corresponding Playstation controller interface
|
||||
if args.controller == 'ps3':
|
||||
controller = PS3ControllerInterface(verbose=True)
|
||||
elif args.controller == 'ps4':
|
||||
controller = PS4ControllerInterface(verbose=False)
|
||||
else:
|
||||
raise NotImplementedError("Unknown game controller")
|
||||
|
||||
|
||||
# run controller
|
||||
print('Running controller...')
|
||||
for _ in count():
|
||||
|
||||
# run one step with the interface
|
||||
controller.run() # same as `step()` if we are not using threads
|
||||
|
||||
# get the last update and print it
|
||||
b = controller.X
|
||||
print("X: {}".format(b)) # , controller[b]))
|
||||
|
||||
# sleep a bit
|
||||
time.sleep(0.01)
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
"""Load the Xbox game controller interface
|
||||
"""
|
||||
|
||||
import time
|
||||
from itertools import count
|
||||
import argparse
|
||||
|
||||
from pyrobolearn.tools.interfaces.controllers.xbox import Xbox360ControllerInterface, XboxOneControllerInterface
|
||||
|
||||
# create parser to select the game controller
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--controller', help='The Xbox game controller to use (xbox one or xbox 360)', type=str,
|
||||
choices=['360', 'one'], default='one')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# load corresponding Xbox controller interface
|
||||
if args.controller == '360':
|
||||
controller = Xbox360ControllerInterface(verbose=True)
|
||||
elif args.controller == 'one':
|
||||
controller = XboxOneControllerInterface(verbose=True)
|
||||
else:
|
||||
raise NotImplementedError("Unknown game controller")
|
||||
|
||||
|
||||
# run controller
|
||||
print('Running controller...')
|
||||
for _ in count():
|
||||
|
||||
# run one step with the interface
|
||||
controller.run() # same as `step()` if we are not using threads
|
||||
|
||||
# get the last update and print it
|
||||
b = controller.last_updated_button
|
||||
print("Last updated button: {} with value: {}".format(b, controller[b]))
|
||||
|
||||
# sleep a bit
|
||||
time.sleep(0.01)
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
"""Draw the 2D velocity and force manipulability ellipsoids on the end-effector of a 3-link planar manipulator.
|
||||
|
||||
References:
|
||||
[1] "Robotics: Modelling, Planning and Control" (section 3.9), Siciliano et al., 2010
|
||||
"""
|
||||
|
||||
import time
|
||||
# from itertools import count
|
||||
import numpy as np
|
||||
|
||||
import pyrobolearn as prl
|
||||
|
||||
|
||||
# create simulator
|
||||
sim = prl.simulators.Bullet()
|
||||
|
||||
# create world
|
||||
world = prl.worlds.BasicWorld(sim)
|
||||
|
||||
# create robot
|
||||
robot = world.load_robot('manipulator2d')
|
||||
robot.reset_joint_states(q=[0.64453457, -1.65045902, -0.31141744])
|
||||
|
||||
# change camera view
|
||||
world.camera.reset(distance=2, yaw=-np.pi / 2, pitch=-np.pi/2.01)
|
||||
|
||||
# draw 2d velocity manipulability ellipsoid
|
||||
# print(robot.end_effector_names)
|
||||
end_effector_id = robot.get_link_ids('gripper')
|
||||
jacobian = robot.get_linear_jacobian(link_id=end_effector_id)
|
||||
jjt = robot.get_JJT(jacobian)
|
||||
robot.draw_velocity_manipulability_ellipsoid(link_id=end_effector_id, JJT=jjt, color=(0, 1, 0, 0.7)) # green
|
||||
robot.draw_force_manipulability_ellipsoid(link_id=end_effector_id, JJT=jjt, color=(1, 0, 0, 0.7)) # red
|
||||
|
||||
# TODO: fix bug
|
||||
|
||||
time.sleep(10000)
|
||||
# run simulator
|
||||
# for t in count():
|
||||
# world.step(sleep_dt=1./240)
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
We provide examples on how to use manipulability ellipsoids.
|
||||
|
||||
Here are a short description of the various examples the user can try:
|
||||
1. `2d_manipulability.py`: draw the 2D velocity and force manipulability ellipsoids on the end-effector of a
|
||||
3-link planar manipulator.
|
||||
2. `com_manipulability_tracking.py`: track the velocity manipulability ellipsoid of the center of mass of a robot
|
||||
with a fixed base.
|
||||
3. `com_manipulability_tracking_with_balance.py`: track the velocity manipulability ellipsoid of the center of mass
|
||||
of a floating-base robot while keeping its balance.
|
||||
4. `com_dynamic_manipulability_tracking_with_balance.py`: track the dynamic manipulability ellipsoid of the center
|
||||
of mass of a floating-base robot while keeping its balance.
|
||||
|
||||
References:
|
||||
- [1] "Robotics: Modelling, Planning and Control", Siciliano et al., 2010
|
||||
- [2] "Springer Handbook of Robotics", Siciliano et al., 2008
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
## Robot examples
|
||||
|
||||
You can try to load different robot by typing `python <robot>.py`.
|
||||
More than 60 robots (of various types) are available through `pyrobolearn`.
|
||||
|
||||
To turn the camera in the simulator, keep pressing the `ctrl` key and the left button on the mouse, and move this last one.
|
||||
Here are the few examples that you can find in this folder:
|
||||
1. `load_robot.py <robot_name>`: load the given robot in the world.
|
||||
2. `visualize_robot.py <robot_name>`: test different visualization tools that can be used on the robot to show its
|
||||
joint axis, bounding boxes, and others.
|
||||
3. `robot_with_sliders.py <robot_name>`: load the given robot in the world and allow you to manipulate the robot's
|
||||
joints with sliders.
|
||||
4. `distribute_epucks.py`: distribute several e-pucks in the world and make them move forward.
|
||||
5. `quadcopter_controller.py`: move a quadcopter in the air using an Xbox or Playstation game controller.
|
||||
6. `robots/<robot>.py`: load the given robot in the simulator by directly instantiating it. Some of these files do
|
||||
more than just loading the robot.
|
||||
|
||||
Notes: to turn the camera in the simulator, keep pressing the `ctrl` key and the left button on the mouse, and
|
||||
move this last one.
|
||||
|
||||
|
||||
#### What to check next?
|
||||
|
||||
Check the `pyrobolearn/examples/interfaces` or `pyrobolearn/examples/kinematics` folder.
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python
|
||||
"""Distribute several e-pucks in the world and make them move forward.
|
||||
|
||||
You can move in the world using the keyboard and mouse:
|
||||
- `ctrl + left click`: rotate the camera
|
||||
- `scroll wheel` or `ctrl + right click`: zoom in/out
|
||||
- `ctrl + middle click`: move the camera
|
||||
- `left click` on an object: if the object has a mass and a collision shape, you can interact with it with the mouse
|
||||
- `w`: wireframe (see collision shapes)
|
||||
- `g`: show/hide menu
|
||||
- `esc`: quit the simulator
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
import argparse
|
||||
|
||||
import pyrobolearn as prl
|
||||
|
||||
|
||||
# create function for the parser to check the number of robots
|
||||
def check(number):
|
||||
"""check that the number of robots is between 1 and 100."""
|
||||
number = int(number)
|
||||
if number < 1:
|
||||
number = 1
|
||||
if number > 100:
|
||||
number = 100
|
||||
return number
|
||||
|
||||
|
||||
# create parser to select the robot
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-n', '--number', help='the number of epucks in the world', type=check, default=10)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# create simulator
|
||||
sim = prl.simulators.Bullet()
|
||||
|
||||
# create basic world (with a floor and gravity enabled by default)
|
||||
world = prl.worlds.BasicWorld(sim, scaling=1)
|
||||
|
||||
# specify distribution ranges for position (x,y,z) and orientation (r,p,y)
|
||||
low_position, high_position = [-3, -3, 0], [3, 3, 0] # x,y,z
|
||||
low_orientation, high_orientation = [0, 0, -np.pi], [0, 0, np.pi] # r,p,y
|
||||
|
||||
# distribute the epucks in the world
|
||||
robots = world.distribute(world.load_robot, size=args.number, position_range=(low_position, high_position),
|
||||
rpy_range=(low_orientation, high_orientation), return_body=True, robot='epuck')
|
||||
|
||||
# run simulator
|
||||
for t in count():
|
||||
|
||||
# move each robot forward
|
||||
for robot in robots:
|
||||
robot.drive(speed=5)
|
||||
|
||||
# perform one step in the world
|
||||
world.step(sleep_dt=1. / 240)
|
||||
@@ -1,33 +1,44 @@
|
||||
# This file creates a basic world, load each robot that can be found in the PRL framework
|
||||
#!/usr/bin/env python
|
||||
"""Load a robot in a basic world.
|
||||
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import implemented_robots
|
||||
You can move in the world using the keyboard and mouse:
|
||||
- `ctrl + left click`: rotate the camera
|
||||
- `scroll wheel` or `ctrl + right click`: zoom in/out
|
||||
- `ctrl + middle click`: move the camera
|
||||
- `left click` on an object: if the object has a mass and a collision shape, you can interact with it with the mouse
|
||||
- `w`: wireframe (see collision shapes)
|
||||
- `g`: show/hide menu
|
||||
- `esc`: quit the simulator
|
||||
"""
|
||||
|
||||
robot_not_working = set(['icub'])
|
||||
from itertools import count
|
||||
import argparse
|
||||
|
||||
import pyrobolearn as prl
|
||||
|
||||
|
||||
# get implemented robots
|
||||
robots = prl.robots.implemented_robots
|
||||
print("All the robots (total number of robots = {}): {}".format(len(robots), robots))
|
||||
|
||||
# create parser to select the robot
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-r', '--robot', help='the robot to load in the world', type=str,
|
||||
choices=robots, default='hyq2max')
|
||||
args = parser.parse_args()
|
||||
|
||||
print("All the robots (total number of robots = {}): {}".format(len(implemented_robots), implemented_robots))
|
||||
|
||||
# create simulator
|
||||
sim = BulletSim()
|
||||
sim = prl.simulators.Bullet()
|
||||
|
||||
# create basic world with floor and gravity
|
||||
world = BasicWorld(sim)
|
||||
world = prl.worlds.BasicWorld(sim)
|
||||
|
||||
# create one robot at a time
|
||||
for i, robot_name in enumerate(implemented_robots):
|
||||
if robot_name not in robot_not_working:
|
||||
# instantiate the given robot
|
||||
robot = world.load_robot(robot_name)
|
||||
# load the robot in the world (note that you can create the robot outside the world (not recommended),
|
||||
# and then give it to the `world.load_robot` method to let know the world that a robot was loaded)
|
||||
robot = world.load_robot(robot=args.robot, position=[0., 0.])
|
||||
|
||||
# print info about the robot
|
||||
print("Robot n{}: {}".format(i+1, robot))
|
||||
# robot.print_info()
|
||||
|
||||
# run for few moments in the world
|
||||
for t in range(250):
|
||||
# run one step and sleep a bit
|
||||
world.step(sleep_dt=1./240)
|
||||
|
||||
# remove the robot from the world
|
||||
world.remove(robot)
|
||||
# run simulator
|
||||
for _ in count():
|
||||
# perform one step in the world
|
||||
world.step(sleep_dt=1. / 240)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python
|
||||
"""Control a quadcopter in the air using an Xbox or Playstation game controller.
|
||||
|
||||
how to run:
|
||||
```
|
||||
$ python quadcopter_controller.py --help # for help
|
||||
$ python quadcopter_controller.py --controller xbox # to use Xbox game controller
|
||||
$ python quadcopter_controller.py --controller ps3 # to use PS3 game controller
|
||||
```
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
import argparse
|
||||
|
||||
import pyrobolearn as prl
|
||||
|
||||
|
||||
# create parser to select the game controller
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--controller', help='the game controller to use', type=str,
|
||||
choices=['xbox', 'ps3'], default='ps3')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# load corresponding interface
|
||||
# if args.controller == 'xbox':
|
||||
# from pyrobolearn.tools.interfaces.controllers.xbox import Xbox360ControllerInterface as Controller
|
||||
# elif args.controller == 'ps3':
|
||||
# from pyrobolearn.tools.interfaces.controllers.playstation import PS3ControllerInterface as Controller
|
||||
# else:
|
||||
# raise NotImplementedError("Unknown game controller")
|
||||
|
||||
|
||||
# create simulator
|
||||
sim = prl.simulators.Bullet()
|
||||
|
||||
# create basic world (with a floor and gravity enabled by default)
|
||||
world = prl.worlds.BasicWorld(sim)
|
||||
|
||||
# load quadcopter
|
||||
robot = prl.robots.Quadcopter(sim, position=[0., 0., 2.])
|
||||
world.load_robot(robot)
|
||||
|
||||
# load interface
|
||||
# controller = Controller()
|
||||
|
||||
# run simulator
|
||||
for t in count():
|
||||
# robot.hover()
|
||||
# robot.set_propeller_velocities(velocity)
|
||||
robot.move([1., 1., 1.])
|
||||
|
||||
# follow quadcopter (seen from behind)
|
||||
world.follow(robot, distance=2, yaw=-np.pi / 2)
|
||||
|
||||
# perform one step in the world
|
||||
world.step(sleep_dt=1. / 240)
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
"""Manipulate the robot's joints with sliders.
|
||||
|
||||
You can move in the world using the keyboard and mouse:
|
||||
- `ctrl + left click`: rotate the camera
|
||||
- `scroll wheel` or `ctrl + right click`: zoom in/out
|
||||
- `ctrl + middle click`: move the camera
|
||||
- `left click` on an object: if the object has a mass and a collision shape, you can interact with it with the mouse
|
||||
- `w`: wireframe (see collision shapes)
|
||||
- `g`: show/hide menu
|
||||
- `esc`: quit the simulator
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
import argparse
|
||||
|
||||
import pyrobolearn as prl
|
||||
|
||||
|
||||
# create parser to select the robot
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-r', '--robot', help='the robot to load in the world', type=str,
|
||||
choices=prl.robots.implemented_robots, default='coman')
|
||||
parser.add_argument('-f', '--fixed_base', help='if we should fix the base when the robot has initially a floating '
|
||||
'base', type=bool, default=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# create simulator
|
||||
sim = prl.simulators.Bullet()
|
||||
|
||||
# create basic world with floor and gravity
|
||||
world = prl.worlds.BasicWorld(sim)
|
||||
|
||||
# load the robot in the world
|
||||
robot = world.load_robot(robot=args.robot, position=[0., 0.], fixed_base=args.fixed_base)
|
||||
|
||||
# add a slider for each specified joint
|
||||
robot.add_joint_slider(joint_ids=robot.joints)
|
||||
|
||||
# run simulator
|
||||
for _ in count():
|
||||
# update the joint slider
|
||||
robot.update_joint_slider()
|
||||
|
||||
# perform one step in the world
|
||||
world.step(sleep_dt=1. / 240)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Aibo
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import AllegroHand
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Ant
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Atlas
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Ballbot
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Baxter
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import BB8
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -85,12 +85,12 @@ class LQR(object):
|
||||
if __name__ == "__main__":
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import World
|
||||
from pyrobolearn.robots import CartPole
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = World(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Cassie
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Centauro
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Cogimon
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Coman
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Crab
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -5,12 +5,12 @@
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
from pyrobolearn.utils.transformation import get_rpy_from_quaternion
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Cubli
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Darwin
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Edo
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Epuck
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import F10Racecar
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Fetch
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Franka
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import HalfCheetah
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Hopper
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Hubo
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Humanoid
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Husky
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import HyQ
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import HyQ2Max
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Jaco
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import KR5
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import KukaIIWA
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import KukaLWR
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Laikago
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import LittleDog
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Manipulator2D
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Minitaur
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import MKZ
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Morphex
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Nao
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import OpenDog
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,13 +3,13 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Pepper
|
||||
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import PhantomX
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Pleurobot
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import PR2
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Quadcopter
|
||||
from pyrobolearn.utils.units import rpm_to_rad_per_second
|
||||
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -24,7 +24,7 @@ robot.print_info()
|
||||
|
||||
rpm = robot.get_stationary_rpm()
|
||||
print("Stationary RPM: {}".format(rpm))
|
||||
v = rpm_to_rad_per_second(rpm+20)
|
||||
v = rpm_to_rad_per_second(rpm + 20)
|
||||
v = [v, -v, v, -v]
|
||||
|
||||
# run simulation
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Rhex
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import RRBot
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -103,7 +103,7 @@ J = sim.calculate_jacobian(robot.id, 1, [0., 0., 0.])
|
||||
print(np.array(J[0]))
|
||||
|
||||
a = robot.get_joint_positions()
|
||||
# print(robot.get_jacobian(1, np.array([0.,0.]))) # TODO: need to convert numpy array to list
|
||||
# print(robot.get_jacobian(1, np.array([0., 0.]))) # TODO: need to convert numpy array to list
|
||||
|
||||
linkId = 2
|
||||
com_frame = robot.get_link_states(linkId)[2]
|
||||
@@ -125,14 +125,14 @@ for i in range(10000):
|
||||
dx = np.array(robot.get_link_world_linear_velocities(linkId))
|
||||
tau = robot.calculate_inverse_dynamics(ddq, dq, q) # Coriolis, centrifugal and gravity compensation
|
||||
Jlin = np.array(sim.calculate_jacobian(robot.id, linkId, com_frame)[0])
|
||||
F = K.dot(xdes - x) - D.dot(dx) # compute cartesian forces
|
||||
F = K.dot(xdes - x) - D.dot(dx) # evaluate cartesian forces
|
||||
# print("force: {}".format(F))
|
||||
tau += Jlin.T.dot(F) # cartesian PD with gravity compensation
|
||||
# tau += Jlin.T.dot(- D.dot(dx)) # active compliance
|
||||
|
||||
# tau = Jlin.T.dot(F)
|
||||
|
||||
# compute manipulability measure :math:`w = sqrt(det(JJ^T))`
|
||||
# evaluate manipulability measure :math:`w = sqrt(det(JJ^T))`
|
||||
Jlin = Jlin[[0, 2], :]
|
||||
w = np.sqrt(np.linalg.det(Jlin.dot(Jlin.T)))
|
||||
# print("manipulability: {}".format(w))
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Sawyer
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import SEAHexapod
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import SEASnake
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import SoftHand
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Swimmer
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Walker2D
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import Walkman
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# Create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import numpy as np
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import WAM
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -5,12 +5,12 @@ These include: YoubotBase, KukaYoubotArm, Youbot, YoubotDualArm
|
||||
"""
|
||||
|
||||
from itertools import count
|
||||
from pyrobolearn.simulators import BulletSim
|
||||
from pyrobolearn.simulators import Bullet
|
||||
from pyrobolearn.worlds import BasicWorld
|
||||
from pyrobolearn.robots import YoubotBase, KukaYoubotArm, Youbot, YoubotDualArm
|
||||
|
||||
# Create simulator
|
||||
sim = BulletSim()
|
||||
sim = Bullet()
|
||||
|
||||
# create world
|
||||
world = BasicWorld(sim)
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python
|
||||
"""Test different visualization tools that can be used on the robot.
|
||||
|
||||
|
||||
Test different visualization tools on a robot. You can notably:
|
||||
- render the robot semi-transparent
|
||||
- draw the robot center of mass and the projected center of mass
|
||||
- draw the center of mass of each link
|
||||
- draw the link frames
|
||||
- draw the joint axis
|
||||
- draw bounding boxes around links
|
||||
- for legged robots:
|
||||
- draw ground reference points such as the ZMP, COP, FRI, and CMP
|
||||
- draw the support polygon
|
||||
- draw friction cones
|
||||
- draw velocity and dynamic manipulability ellipsoids
|
||||
|
||||
|
||||
You can move in the world using the keyboard and mouse:
|
||||
- `ctrl + left click`: rotate the camera
|
||||
- `scroll wheel` or `ctrl + right click`: zoom in/out
|
||||
- `ctrl + middle click`: move the camera
|
||||
- `left click` on an object: if the object has a mass and a collision shape, you can interact with it with the mouse
|
||||
- `w`: wireframe (see collision shapes)
|
||||
- `g`: show/hide menu
|
||||
- `esc`: quit the simulator
|
||||
"""
|
||||
|
||||
import time
|
||||
from itertools import count
|
||||
import argparse
|
||||
|
||||
import pyrobolearn as prl
|
||||
|
||||
|
||||
# create parser to select the robot
|
||||
robots = ['coman', 'hyq2max'] # prl.robots.implemented_robots
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-r', '--robot', help='the robot to load in the world', type=str,
|
||||
choices=robots, default='hyq2max')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# create simulator
|
||||
sim = prl.simulators.Bullet()
|
||||
|
||||
# create basic world with floor and gravity
|
||||
world = prl.worlds.BasicWorld(sim)
|
||||
|
||||
# load the robot in the world
|
||||
robot = world.load_robot(robot=args.robot, position=[0., 0.])
|
||||
|
||||
# move the simulation a bit forward (such that the robot touches the floor)
|
||||
for _ in range(100):
|
||||
world.step()
|
||||
|
||||
# change visualization
|
||||
robot.change_transparency()
|
||||
robot.draw_link_coms()
|
||||
robot.draw_link_frames()
|
||||
robot.draw_bounding_boxes(link_ids=-1)
|
||||
|
||||
robot.draw_friction_cone(floor_id=world.floor_id)
|
||||
robot.draw_support_polygon(floor_id=world.floor_id, lifetime=0)
|
||||
|
||||
robot.compute_and_draw_com_position()
|
||||
robot.compute_and_draw_projected_com_position()
|
||||
# robot.draw_cop(cop=world.floor_id)
|
||||
# robot.draw_zmp(zmp=world.floor_id)
|
||||
# robot.draw_cmp(cmp=world.floor_id)
|
||||
|
||||
time.sleep(10000)
|
||||
# run simulator
|
||||
# for t in count():
|
||||
# # perform one step in the world
|
||||
# world.step(sleep_dt=1. / 240)
|
||||
@@ -14,3 +14,8 @@ and with collisions) that are movable, fixed, or are moving.
|
||||
4. `load_robot.py`: load a robot in a basic world and distribute randomly few objects on the floor.
|
||||
5. `load_heightmap.py`: load a terrain from a heightmap (png) and load a robot on it.
|
||||
6. `generate_terrain.py`: generate a terrain and distribute randomly few objects on the terrain.
|
||||
|
||||
|
||||
#### What to check next?
|
||||
|
||||
Check the `pyrobolearn/examples/robots` folder.
|
||||
|
||||
Reference in New Issue
Block a user