Beispiel #1
0
    def __init__(self):
        self._low_degrees_bound = 0
        self._low_radians_bound = 0
        self._high_degrees_bound = 180
        self._high_radians_bound = np.pi
        # Get client id from the V-REP server-side
        vrep.simxFinish(-1)
        self.conn_handler = vrep.simxStart('127.0.0.1', 19999, True, True,
                                           5000, 5)
        if self.conn_handler == -1:
            print('Failed connecting to the remote API server')
            return -1
        print('Succesfully connected to the remote API server...')

        # Get UARM entity
        # Implemented it in the dict style for future purposes
        # (if there're several robots in the env, call them like
        # env.robot['uarm'], env.robot['universal_robotics'], etc)
        uarm = UARM(self.conn_handler)
        self.robot = {'uarm': uarm}

        # Get cameras from V-REP
        # vs_0 - global view,
        # vs_1 - details basket,
        # vs_2 - destination basket,
        self.camera_handlers = []
        for i in range(3):
            err, handler = vrep.simxGetObjectHandle(
                self.conn_handler, 'vs_' + str(i),
                vrep.simx_opmode_oneshot_wait)
            if err == vrep.simx_return_ok:
                self.camera_handlers.append(handler)
            else:
                print('Error getting camera handlers, ERR:', err)
                return
Beispiel #2
0
 def __init__(self, args):
     self.args = args
     # just in case, close all opened connections
     vrep.simxFinish(-1)
     self.client_id = self.connect(args.scene_file, args.port)
     # set the dt (simulation timestep, default is 0.05)
     self.set_simulation_timestep()
     self.handles_dict = self.get_handles()
     self.set_simulation_timestep()
def connect_to_vrep():
    vrep.simxFinish(-1) # just in case, close all opened connections
    clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # Connect to V-REP
    if clientID == -1:
        print('Failed connecting to V-REP remote API server.')
        exit()
    else:
        vrep.simxSynchronous(clientID, True)
    return clientID
Beispiel #4
0
    def start_sim(self):
        """
            Function to start the simulation. The scene must be running before running this code.
            Returns:
                clientID: This ID is used to start the objects on the scene.
        """
        vrep.simxFinish(-1)
        clientID = vrep.simxStart(self.SERVER_IP, self.SERVER_PORT, True, True, 2000, 5)
        if clientID != -1:
            print("Connected to remoteApi server.")
        else:
            vrep.simxFinish(clientID)
            sys.exit("\033[91m ERROR: Unable to connect to remoteApi server. Consider running scene before executing script.")

        return clientID
import sys
import glob
import h5py
import numpy as np
import trimesh
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection

sys.path.append('..')

import lib
import lib.utils
from lib.config import config_mesh_dir, config_output_collected_dir
from lib import vrep
vrep.simxFinish(-1)
import simulator as SI


def load_mesh(mesh_path):
    """Loads a mesh from file &computes it's centroid using V-REP style."""

    mesh = trimesh.load_mesh(mesh_path)

    # V-REP encodes the object centroid as the literal center of the object,
    # so we need to make sure the points are centered the same way
    center = lib.utils.calc_mesh_centroid(mesh, center_type='vrep')
    mesh.vertices -= center
    return mesh

Beispiel #6
0
 def stop_and_finish(self):
     self.stop()
     vrep.simxFinish(self.client_id)
Beispiel #7
0
import numpy as np

from utilities import vrep_utils as vu

from lib import vrep

vrep.simxFinish(-1)  # just in case, close all opened connections

client_id = vu.connect_to_vrep()
print(client_id)

res = vu.load_scene(client_id,
                    '/home/mohit/projects/cooking/code/sim_vrep/scene_0.ttt')
print(res)
if res != vrep.simx_return_ok:
    print("Error in loading scene: {}".format(res))

vu.start_sim(client_id)

cam_rgb_names = ["Camera"]
cam_rgb_handles = [
    vrep.simxGetObjectHandle(client_id, n, vrep.simx_opmode_blocking)[1]
    for n in cam_rgb_names
]
print("Camera handle: {}".format(cam_rgb_handles))

octree_handle = vu.get_handle_by_name(client_id, 'Octree')
print('Octree handle: {}'.format(octree_handle))

voxel_list = []
for t in range(100):
Beispiel #8
0
 def __init__(self, args):
     self.args = args
     # just in case, close all opened connections
     vrep.simxFinish(-1)
     self.client_id = self.connect(args.scene_file)
     self.handles_dict = self.get_handles()
Beispiel #9
0
    def finish(self):
        """ Closing connection between client and server-side V-REP 
		"""
        vrep.simxFinish(self.conn_handler)