vrep
Package¶
-
pypot.vrep.
from_vrep
(config, vrep_host='127.0.0.1', vrep_port=19997, scene=None, tracked_objects=[], tracked_collisions=[], id=None, shared_vrep_io=None)[source]¶ Create a robot from a V-REP instance.
Parameters: - config (str or dict) – robot configuration (either the path to the json or directly the dictionary)
- vrep_host (str) – host of the V-REP server
- vrep_port (int) – port of the V-REP server
- scene (str) – path to the V-REP scene to load and start
- tracked_objects (list) – list of V-REP dummy object to track
- tracked_collisions (list) – list of V-REP collision to track
- id (int) – robot id in simulator (useful when using a scene with multiple robots)
- vrep_io (
VrepIO
) – use an already connected VrepIO (useful when using a scene with multiple robots)
This function tries to connect to a V-REP instance and expects to find motors with names corresponding as the ones found in the config.
Note
The
Robot
returned will also provide a convenience reset_simulation method which resets the simulation and the robot position to its intial stance.Note
Using the same configuration, you should be able to switch from a real to a simulated robot just by switching from
from_config()
tofrom_vrep()
. For instance:import json with open('my_config.json') as f: config = json.load(f) from pypot.robot import from_config from pypot.vrep import from_vrep real_robot = from_config(config) simulated_robot = from_vrep(config, '127.0.0.1', 19997, 'poppy.ttt')
io
Module¶
-
class
pypot.vrep.io.
VrepIO
(vrep_host='127.0.0.1', vrep_port=19997, scene=None, start=False)[source]¶ Bases:
pypot.robot.io.AbstractIO
This class is used to get/set values from/to a V-REP scene.
It is based on V-REP remote API (http://www.coppeliarobotics.com/helpFiles/en/remoteApiOverview.htm).
Starts the connection with the V-REP remote API server.
Parameters: Warning
Only one connection can be established with the V-REP remote server API. So before trying to connect make sure that all previously started connections have been closed (see
close_all_connections()
)-
MAX_ITER
= 5¶
-
TIMEOUT
= 0.4¶
-
load_scene
(scene_path, start=False)[source]¶ Loads a scene on the V-REP server.
Parameters: Note
It is assumed that the scene file is always available on the server side.
-
start_simulation
()[source]¶ Starts the simulation.
Note
Do nothing if the simulation is already started.
Warning
if you start the simulation just after stopping it, the simulation will likely not be started. Use
restart_simulation()
instead.
-
get_motor_force
(motor_name)[source]¶ Retrieves the force or torque applied to a joint along/about its active axis.
-
set_motor_force
(motor_name, force)[source]¶ Sets the maximum force or torque that a joint can exert.
-
call_remote_api
(func_name, *args, **kwargs)[source]¶ Calls any remote API func in a thread_safe way.
Parameters: - func_name (str) – name of the remote API func to call
- args – args to pass to the remote API call
- kwargs – args to pass to the remote API call
Note
You can add an extra keyword to specify if you want to use the streaming or sending mode. The oneshot_wait mode is used by default (see here for details about possible modes).
Warning
You should not pass the clientId and the operationMode as arguments. They will be automatically added.
As an example you can retrieve all joints name using the following call:
vrep_io.remote_api_call('simxGetObjectGroupData', vrep_io.remote_api.sim_object_joint_type, 0, streaming=True)
-
-
pypot.vrep.io.
close_all_connections
()[source]¶ Closes all opened connection to V-REP remote API server.
controller
Module¶
-
class
pypot.vrep.controller.
VrepController
(vrep_io, scene, motors, sync_freq=50.0, id=None)[source]¶ Bases:
pypot.robot.controller.MotorsController
V-REP motors controller.
Parameters:
-
class
pypot.vrep.controller.
VrepObjectTracker
(io, sensors, sync_freq=50.0)[source]¶ Bases:
pypot.robot.controller.SensorsController
Tracks the 3D position and orientation of a V-REP object.
Parameters: - io (
AbstractIO
) – IO used to communicate with the hardware motors - sensors (list) – list of sensors attached to the controller
- sync_freq (float) – synchronization frequency
- io (
-
class
pypot.vrep.controller.
VrepCollisionDetector
(name)[source]¶ Bases:
pypot.robot.sensor.Sensor
-
colliding
¶
-
-
class
pypot.vrep.controller.
VrepCollisionTracker
(io, sensors, sync_freq=50.0)[source]¶ Bases:
pypot.robot.controller.SensorsController
Tracks collision state.
Parameters: - io (
AbstractIO
) – IO used to communicate with the hardware motors - sensors (list) – list of sensors attached to the controller
- sync_freq (float) – synchronization frequency
- io (