def __init__(self, headless=False): self.venv = venv = vrepper(headless=headless) venv.start() time.sleep(0.1) file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Sarah_vortex_CPG.ttt') print(file_path) venv.load_scene(file_path) time.sleep(0.1) # Pressure Sensors self.L_Force_Front = venv.get_object_by_name('L_Force_F') self.L_Force_Back = venv.get_object_by_name('L_Force_B') self.R_Force_Front = venv.get_object_by_name('R_Force_F') self.R_Force_Back = venv.get_object_by_name('R_Force_B') # Angle Sensors / Actuators self.L_Abduction = venv.get_object_by_name('L_Abduction') self.R_Abduction = venv.get_object_by_name('R_Abduction') self.L_Hip_Angle = venv.get_object_by_name('L_Hip_Angle') self.R_Hip_Angle = venv.get_object_by_name('R_Hip_Angle') self.L_Linear = venv.get_object_by_name('L_Hip_Linear') self.R_Linear = venv.get_object_by_name('R_Hip_Linear') # Structural Components self.Center = venv.get_object_by_name('Central_Addon') print('(CartPoleVREP) initialized') obs = np.array([np.inf] * 16) act = np.array([1.] * 3) self.seed() self.action_space = spaces.Box(-act, act) self.observation_space = spaces.Box(-obs, obs) self.Frequency = 0 self.Center_mass = 0 self.observation = 0 self.parameters = 0 self.Time = 0
import os import numpy as np import time import matplotlib.pyplot as plt from vrepper.core import vrepper # create a vrepper object using the following command: # dir_vrep is the path to vrep directory. # port_num denotes the port on which to start vrep(if port_num=None then a random port will be assigned) venv = vrepper(dir_vrep='/home/nikhil/V-REP_PRO_EDU_V3_5_0_Linux/', headless=True) # Start a V-REP instance venv.start() current_dir = os.path.dirname(os.path.realpath(__file__)) # To load a scene after creating V-REP instance: venv.load_scene(current_dir + '/scenes/bubbleRob.ttt') # To start simulation in realtime moe # Set is_sync=True, to enables the synchronous operation mode for the remote API server service that the client is connected to venv.start_simulation(is_sync=False) l_motor = venv.get_object_by_name("bubbleRob_leftMotor", is_joint=True) r_motor = venv.get_object_by_name("bubbleRob_rightMotor", is_joint=True) ps = venv.get_object_by_name("bubbleRob_sensingNose", is_joint=False) err_code, detectionState, detectedPoint, detectedObjectHandle, detectedSurfaceNormalVector = ps.read_proximity_sensor( is_first_time=True)
import os, math, time from vrepper import core # sorry but that's how the namespace works venv = core.vrepper(headless=True, emulate_framebuffer=True) venv.start() # load scene venv.load_scene(os.getcwd() + '/scenes/body_joint_wheel.ttt') body = venv.get_object_by_name('body') wheel = venv.get_object_by_name('wheel') joint = venv.get_object_by_name('joint') print(body.handle, wheel.handle, joint.handle) for j in range(5): venv.start_blocking_simulation() for i in range(20): print('simulation step', i) print('body position', body.get_position()) print('wheel orientation', wheel.get_orientation()) joint.set_velocity(10 * math.sin(i / 5)) # you should see things moving back and forth venv.step_blocking_simulation() # forward 1 timestep # stop the simulation and reset the scene: venv.stop_simulation()
### This demo is using the Poppy Ergo Jr. robotic arm. ### We've developed this arm at INRIA Bordeaux. ### It's a cheap open source arm, i.e. you can just make it yourself. ### We also sell the parts online in a pack for around 300$. import os import numpy as np import time import matplotlib.pyplot as plt from vrepper.core import vrepper venv = vrepper(headless=True) venv.start() current_dir = os.path.dirname(os.path.realpath(__file__)) venv.load_scene(current_dir + '/scenes/poppy_ergo_jr.ttt') motors = [] for i in range(6): motor = venv.get_object_by_name('m{}'.format(i + 1), is_joint=True) motors.append(motor) cam = venv.get_object_by_name("cam") venv.start_simulation( is_sync=False) # start in realtime mode to set initial position def set_motors(positions, speeds=None): for i, m in enumerate(motors): target = positions[i] if i == 0: # first joint is inverted in simulation
import os,math,time from vrepper import core # sorry but that's how the namespace works venv = core.vrepper(headless=True) venv.start() # load scene venv.load_scene(os.getcwd() + '/scenes/body_joint_wheel.ttt') body = venv.get_object_by_name('body') wheel = venv.get_object_by_name('wheel') joint = venv.get_object_by_name('joint') print(body.handle,wheel.handle,joint.handle) for j in range(5): venv.start_blocking_simulation() for i in range(20): print('simulation step',i) print('body position',body.get_position()) print('wheel orientation',wheel.get_orientation()) joint.set_velocity(10 * math.sin(i/5)) # you should see things moving back and forth venv.step_blocking_simulation() # forward 1 timestep # stop the simulation and reset the scene: venv.stop_blocking_simulation()