Ejemplo n.º 1
0
    def __init__(self, enables_acturator_dynamics = False):

        self.vrep_client_id=vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # Connect to V-REP
        
        self.current_goal = 0.

        self.path_list = []

        self.current_car_position = []
        while True:
            print('Connected to remote API server')
            if self.vrep_client_id != -1:
                break
            else:
                sleep(0.2)
        
        self.path_list = self.readCSV()
        
        self.left_motor_handles = vrep.simxGetObjectHandle(clientID=self.vrep_client_id, objectName='Team12_motorLeft', operationMode=vrep.simx_opmode_blocking)[1]
        
        self.right_motor_handles = vrep.simxGetObjectHandle(clientID=self.vrep_client_id, objectName='Team12_motorRight', operationMode=vrep.simx_opmode_blocking)[1]
        
        self.steeringLeft_handles = vrep.simxGetObjectHandle(clientID=self.vrep_client_id, objectName='Team12_steeringLeft', operationMode=vrep.simx_opmode_blocking)[1]
        
        self.steeringRight_handles = vrep.simxGetObjectHandle(clientID=self.vrep_client_id, objectName='Team12_steeringRight', operationMode=vrep.simx_opmode_blocking)[1]

        self.car_handle = vrep.simxGetObjectHandle(clientID=self.vrep_client_id,objectName='Team12_VehicleFrontPose', operationMode=vrep.simx_opmode_blocking)[1]

        self.collision_handle = vrep.simxGetCollisionHandle(clientID=self.vrep_client_id,collisionObjectName='Collision', operationMode=vrep.simx_opmode_blocking)[1]

        self.goal_number = 0

        self.goal_angle = 0
Ejemplo n.º 2
0
    def __init__(self):
        try:
            vrep.simxFinish(-1)
        except:
            pass
        
        self.clientID=vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # Connect to V-REP
        #vrep.simxSynchronous(self.clientID, True)

        
        self.opmode_blocking = vrep.simx_opmode_blocking
        self.obs_handle1 = vrep.simxGetObjectHandle(self.clientID, objectName="obs1", operationMode=vrep.simx_opmode_blocking)[1]
        self.obs_handle2 = vrep.simxGetObjectHandle(self.clientID, objectName="obs2", operationMode=vrep.simx_opmode_blocking)[1]
        self.obs_handle3 = vrep.simxGetObjectHandle(self.clientID, objectName="obs3", operationMode=vrep.simx_opmode_blocking)[1]
        self.obs_handle4 = vrep.simxGetObjectHandle(self.clientID, objectName="obs4", operationMode=vrep.simx_opmode_blocking)[1]
        self.obs_handle5 = vrep.simxGetObjectHandle(self.clientID, objectName="obs5", operationMode=vrep.simx_opmode_blocking)[1]
        self.d_obs_handle = vrep.simxGetObjectHandle(self.clientID, objectName="Obstacle_shape_1", operationMode=vrep.simx_opmode_blocking)[1]
        self.robot_handle = vrep.simxGetObjectHandle(self.clientID, objectName="dualarm_mobile", operationMode=vrep.simx_opmode_blocking)[1]
        



        self.x_rand1 = 1.2362  #random.uniform(-2.5, 2.5)
        self.x_rand3 = -2.388  #random.uniform(-2.5, 2.5)
        self.x_rand4 =  1.8112  #random.uniform(-2.5, 2.5)
        self.x_rand5 = -2.5138  #random.uniform(-2.5, 2.5)

        vrep.simxSetObjectPosition(self.clientID, self.obs_handle1, -1, [6.75, self.x_rand1, 0.5], self.opmode_blocking)
        vrep.simxSetObjectPosition(self.clientID, self.obs_handle3, -1, [1.75, self.x_rand3, 0.5], self.opmode_blocking)
        vrep.simxSetObjectPosition(self.clientID, self.obs_handle4, -1, [-2.75, self.x_rand4, 0.5], self.opmode_blocking)
        vrep.simxSetObjectPosition(self.clientID, self.obs_handle5, -1, [-5.75, self.x_rand5, 0.5], self.opmode_blocking)
        

        self.alpha = 0.1

        self.deviation = 0

        self._pos_x = -8
        self._pos_y = 0

        self._d_x = 4.95
        self._d_y = -1.0696
      
        self.graph_switch = True

        self.csv_container = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Ejemplo n.º 3
0
import sys
import time
import math

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

clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
if clientID != -1:
    print("Connected to remote API server")

    vrep.simxStopSimulation(clientID, operationMode=vrep.simx_opmode_blocking)

    _, handle = vrep.simxGetObjectHandle(clientID, 'dualarm_mobile',
                                         vrep.simx_opmode_blocking)
    time.sleep(1)

    vrep.simxSetObjectPosition(clientID, handle, -1, [0.0, 0.0, 0.1],
                               vrep.simx_opmode_blocking)
    time.sleep(1)

    vrep.simxSetObjectOrientation(clientID, handle, -1,
                                  [math.pi, math.pi / 2, 0.0],
                                  vrep.simx_opmode_blocking)
    time.sleep(1)

    #vrep.simxFinish(clientID)
    #time.sleep(1)

    #vrep.simxPauseSimulation(clientID, operationMode=vrep.simx_opmode_oneshot)
Ejemplo n.º 4
0
        pass

    opmode_blocking = vrep.simx_opmode_blocking

    clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000,
                              5)  # Connect to V-REP

    if clientID != -1:
        print('Connected to remote API server')

        # enable the synchronous mode on the client:
        vrep.simxSynchronous(clientID, True)

        # get joint handles:
        joint_handle = [
            vrep.simxGetObjectHandle(clientID, 'Motor_left',
                                     opmode_blocking)[1],
            vrep.simxGetObjectHandle(clientID, 'Motor_right',
                                     opmode_blocking)[1]
        ]

        # get target handle
        robot_handle = vrep.simxGetObjectHandle(clientID, 'Robot',
                                                opmode_blocking)[1]

        # start the simulation:
        vrep.simxStartSimulation(clientID, vrep.simx_opmode_blocking)
        vrep.simxSynchronousTrigger(clientID)

        # Now step a few times:
        for t in range(1, 500):
            vrep.simxSynchronousTrigger(clientID)
Ejemplo n.º 5
0
    vrep.simxFinish(-1)  # just in case, close all opened connections
except:
    pass

clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000,
                          5)  # Connect to V-REP
if clientID != -1:
    print('Connected to remote API server')

    #Get object handle
    #(
    #client ID,
    #'object name',
    #operation mode
    #)
    e, handle = vrep.simxGetObjectHandle(clientID, 'Cuboid',
                                         vrep.simx_opmode_blocking)
    time.sleep(3)

    #Set object position
    #(
    #client ID,
    #object handle,
    #relative to object handle (-1 if absolute),
    #position,
    #operation mode
    #)
    vrep.simxSetObjectPosition(clientID, handle, -1, [0.0, 0.0, 1.0],
                               vrep.simx_opmode_blocking)
    time.sleep(3)

    #Set object orientation
Ejemplo n.º 6
0
    except:
        pass

    opmode_blocking = vrep.simx_opmode_blocking

    clientID=vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # Connect to V-REP

    if clientID != -1:
        print('Connected to remote API server')

        # enable the synchronous mode on the client:
        vrep.simxSynchronous(clientID, True)

        # get joint handles:
        joint_handle = [
            vrep.simxGetObjectHandle(clientID, 'MTB_axis1', opmode_blocking)[1],
            vrep.simxGetObjectHandle(clientID, 'MTB_axis2', opmode_blocking)[1]
        ]

        # get target handle
        cube_handle = vrep.simxGetObjectHandle(clientID, 'Cube', opmode_blocking)[1]

        # link length
        a1 = 0.467
        a2 = 0.405

        # start the simulation:
        vrep.simxStartSimulation(clientID,vrep.simx_opmode_blocking)
        vrep.simxSynchronousTrigger(clientID)

        # desired pose of end-effector
Ejemplo n.º 7
0
    vrep.simxFinish(-1)  # just in case, close all opened connections
except:
    pass

clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000,
                          5)  # Connect to V-REP
if clientID != -1:
    print('Connected to remote API server')

    #Get joint handle
    #(
    #client ID,
    #'joint name',
    #operation mode
    #)
    e, handle = vrep.simxGetObjectHandle(clientID, 'Revolute_joint',
                                         vrep.simx_opmode_blocking)

    #Start simulation(
    #client ID,
    #operation mode
    #)
    vrep.simxStartSimulation(clientID, vrep.simx_opmode_blocking)

    #Set joint target position
    #(
    #client ID,
    #joint handle,
    #target position,
    #operation mode
    #)
    vrep.simxSetJointTargetPosition(clientID, handle, pi / 4,
Ejemplo n.º 8
0
        pass

    opmode_blocking = vrep.simx_opmode_blocking

    clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000,
                              5)  # Connect to V-REP

    if clientID != -1:
        print('Connected to remote API server')

        # enable the synchronous mode on the client:
        vrep.simxSynchronous(clientID, True)

        # get joint handles:
        joint_handle = [
            vrep.simxGetObjectHandle(clientID, 'steeringLeft',
                                     opmode_blocking)[1],
            vrep.simxGetObjectHandle(clientID, 'steeringRight',
                                     opmode_blocking)[1],
            vrep.simxGetObjectHandle(clientID, 'motorLeft',
                                     opmode_blocking)[1],
            vrep.simxGetObjectHandle(clientID, 'motorRight',
                                     opmode_blocking)[1]
        ]

        # start the simulation:
        vrep.simxStartSimulation(clientID, vrep.simx_opmode_blocking)
        vrep.simxSynchronousTrigger(clientID)

        # Now step a few times:
        for t in range(1, 300):
            vrep.simxSynchronousTrigger(clientID)