本文整理汇总了Python中vrep.simxSetJointTargetVelocity函数的典型用法代码示例。如果您正苦于以下问题:Python simxSetJointTargetVelocity函数的具体用法?Python simxSetJointTargetVelocity怎么用?Python simxSetJointTargetVelocity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了simxSetJointTargetVelocity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drive
def drive(self):
Left = self.v0
Right = self.v0
for i in range(0,len(self.ultra_sensors)-1):
res, detectionState, \
detectedPoint, detectedObjectHandle, \
detectedSurfaceNormalVector = \
vrep.simxReadProximitySensor(self.clientID,
self.ultra_sensors[i],
vrep.simx_opmode_buffer)
dist = vec_length(detectedPoint)
if (res==0) and (dist<self.noDetectionDist):
if (dist<self.maxDetectionDist):
dist=self.maxDetectionDist
self.detect[i]=1-((dist-self.maxDetectionDist)/(self.noDetectionDist-self.maxDetectionDist))
else:
self.detect[i]=0
Left=Left+self.braitenbergL[i]*self.detect[i]
Right=Right+self.braitenbergR[i]*self.detect[i]
vrep.simxSetJointTargetVelocity(self.clientID,
self.left_motor_handle,
Left,
vrep.simx_opmode_streaming)
vrep.simxSetJointTargetVelocity(self.clientID,
self.right_motor_handle,
Right,
vrep.simx_opmode_streaming)
示例2: moveKJuniorReadProxSensors
def moveKJuniorReadProxSensors(self):
"slowly move forward and print normal vector readings"
rightInput = vrep.simxReadProximitySensor(self.simulID, self.KJrightEye, vrep.simx_opmode_streaming)
leftInput = vrep.simxReadProximitySensor(self.simulID, self.KJleftEye, vrep.simx_opmode_streaming)
vrep.simxSynchronousTrigger(self.simulID)
print "Proximity sensor readings error codes: ", rightInput[0],leftInput[0]
for step in xrange(self.noSteps):
rightSpeed = 10
leftSpeed = rightSpeed
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.KJrightMotor, rightSpeed, vrep.simx_opmode_oneshot_wait)
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.KJleftMotor, leftSpeed, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
rightInput = vrep.simxReadProximitySensor(self.simulID, self.KJrightEye, vrep.simx_opmode_buffer)
vrep.simxSynchronousTrigger(self.simulID)
leftInput = vrep.simxReadProximitySensor(self.simulID, self.KJleftEye, vrep.simx_opmode_buffer)
vrep.simxSynchronousTrigger(self.simulID)
print "Left-->err:%s - Detct'd: %s\t%s\t\t\tRight--> err:%s - Detct'd: %s\t%s" % (leftInput[0],
leftInput[3],
leftInput[4],
rightInput[0],
rightInput[3],
rightInput[4])
sleep(.2)
示例3: moveRobotRaw_dr20_
def moveRobotRaw_dr20_(leftJoint, rightJoint, clientID):
err_move_leftJ = vrep.simxSetJointTargetVelocity(clientID, leftJoint, 2, vrep.simx_opmode_oneshot)
err_move_rightJ = vrep.simxSetJointTargetVelocity(clientID, rightJoint, 2, vrep.simx_opmode_oneshot)
if err_move_leftJ != vrep.simx_error_noerror:
print "Das linke Gelenk konnte nicht bewegt werden!"
if err_move_rightJ != vrep.simx_error_noerror:
print "Das rechte Gelenk konnte nicht bewegt werden!"
示例4: testMaxSpeed
def testMaxSpeed(self, maxSpeed, mode):
"""test max speed of khepera-like robot in V-Rep
revving the motors up to maxSpeed in the self.noSteps and then backward.
mode--> 1, both motors, 2: right only, 3: left only"""
if mode == 1:
rightOn = leftOn = 1
elif mode == 2:
rightOn = 1
leftOn = 0
elif mode == 3:
rightOn = 0
leftOn = 1
unitSpeed = maxSpeed /self.noSteps
for i in xrange(self.noSteps):
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.rightMotor, unitSpeed *(i+1)*rightOn, vrep.simx_opmode_oneshot_wait)
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.leftMotor, unitSpeed *(i+1)*leftOn, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
print "Step: %s\t Speed now: %.2f" %(str(i),(unitSpeed *(i+1)))
for i in xrange(self.noSteps):
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.rightMotor, -(maxSpeed/(i+1))*rightOn, vrep.simx_opmode_oneshot_wait)
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.leftMotor, -(maxSpeed/(i+1))*leftOn, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
print "Step: %s\t Speed now: %.2f" % (str(i), (maxSpeed/(i+1))*rightOn)
示例5: moveAndReadProxSensors
def moveAndReadProxSensors(self):
"rotate in place and print sensor distance and normal vector readings"
for step in xrange(self.noSteps):
if step>self.noSteps / 2:
rightSpeed = -1
leftSpeed = -rightSpeed
else:
rightSpeed = 1
leftSpeed = -rightSpeed
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.rightMotor, rightSpeed, vrep.simx_opmode_oneshot_wait)
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.leftMotor, leftSpeed, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
rightInput = vrep.simxReadProximitySensor(self.simulID, self.rightEye, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
leftInput = vrep.simxReadProximitySensor(self.simulID, self.leftEye, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
print "Left-->err:%s - Detct'd: %s\t%s\t\tRight--> err:%s - Detct'd: %s\t\t\t%s" % (leftInput[0],
leftInput[3],
leftInput[2],
rightInput[0],
rightInput[3],
rightInput[2])
sleep(.1)
self.stopRobot(self.simulID,[self.rightMotor,self.leftMotor])
vrep.simxSynchronousTrigger(self.simulID)
示例6: braiten1b
def braiten1b(self):
"slowly move forward and print normal vector readings"
intens = 100
ambientIntensRatio = 0.2
attVect = [0,0,pi *4]
for step in xrange(self.noSteps):
rightInput = vrep.simxReadProximitySensor(self.simulID, self.rightEye, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
leftInput = vrep.simxReadProximitySensor(self.simulID, self.leftEye, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
centerInput = vrep.simxReadProximitySensor(self.simulID, self.KJcenterEye, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
angle = degrees(self.angleBetVecs([0,0,1], centerInput[2]))
lightReading = self.irradAtSensor(intens, ambientIntensRatio, centerInput[2], attVect)
print "Center-->err:%s - Detct'd: %s\tAngle:%.3f\tIrrad:%.3f\tNorm: %.3f\tVector:%s\t" % (centerInput[0],
centerInput[3],
angle,
lightReading,
norm(centerInput[2]),
centerInput[2])
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.rightMotor, 1/lightReading, vrep.simx_opmode_oneshot_wait)
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.leftMotor, 1/lightReading, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
sleep(0)
示例7: execute_action
def execute_action(clientID, RobotHandle, LMotorHandle, RMotorHandle, raw_pose_data, next_action):
linearVelo, angularVelo, goal_pose = compute_control(raw_pose_data, next_action)
l_ang_v, r_ang_v = dif_drive(linearVelo, angularVelo)
#----------
dist_bound = 0.15
ang_bound = 0.1*PI
# retDia, DialogHandle, uiHandle = vrep.simxDisplayDialog(clientID, 'Current Action', next_action, vrep.sim_dlgstyle_message, 'None', None, None, vrep.simx_opmode_blocking)
#----------
while (distance(raw_pose_data, goal_pose)>= dist_bound) or (abs(raw_pose_data[2]-goal_pose[2])>=ang_bound):
# print '--line_distance--', distance(raw_pose_data, goal_pose)
# print '--angle distance--', abs(raw_pose_data[2]-goal_pose[2])
pret, RobotPos = vrep.simxGetObjectPosition(clientID, RobotHandle, -1, vrep.simx_opmode_blocking)
#print "robot position: (x = " + str(RobotPos[0]) + ", y = " + str(RobotPos[1]) + ")"
oret, RobotOrient = vrep.simxGetObjectOrientation(clientID, RobotHandle, -1, vrep.simx_opmode_blocking)
#print "robot orientation: (a = " + str(RobotOrient[0]) + ", b = " + str(RobotOrient[1]) +", g = " + str(RobotOrient[2]) + ")"
raw_pose_data = shift_raw_pose([RobotPos[0], RobotPos[1], RobotOrient[2]])
#------------------------------
linearVelo, angularVelo = Find_Control(raw_pose_data, next_action, goal_pose)
l_ang_v, r_ang_v = dif_drive(linearVelo, angularVelo)
#print 'raw_pose_data', raw_pose_data
vrep.simxSetJointTargetVelocity(clientID, LMotorHandle, l_ang_v, vrep.simx_opmode_streaming)
vrep.simxSetJointTargetVelocity(clientID, RMotorHandle, r_ang_v, vrep.simx_opmode_streaming)
#print 'distance_x_y:%s; angle_dif:%s' %(str(distance(raw_pose_data, goal_pose)),str(abs(raw_pose_data[2]-goal_pose[2])))
print 'Goal pose reached!'
# vrep.simxSetJointTargetVelocity(clientID, LMotorHandle, 0, vrep.simx_opmode_blocking)
# vrep.simxSetJointTargetVelocity(clientID, RMotorHandle, 0, vrep.simx_opmode_blocking)
# time.sleep(0.5)
# retEnd = vrep.simxEndDialog(clientID, DialogHandle, vrep.simx_opmode_blocking)
return raw_pose_data
示例8: set_motors
def set_motors():
global linearVelocityLeft, linearVelocityRight, wheelRadius, vrep, clientID, leftJointDynamic, rightJointDynamic
t1 = linearVelocityLeft/wheelRadius
t2 = linearVelocityRight/wheelRadius
print t1, t2
vrep.simxSetJointTargetVelocity(clientID, leftJointDynamic, t1, vrep.simx_opmode_oneshot_wait)
vrep.simxSetJointTargetVelocity(clientID, rightJointDynamic, t2, vrep.simx_opmode_oneshot_wait)
示例9: set_motor_velocity
def set_motor_velocity(self, control):
"""Set a target velocity on the pioneer motors, multiplied by the gain
defined in self.gain
Args:
control(list): the control [left_motor, right_motor]
"""
vrep.simxSetJointTargetVelocity(self.client_id, self.left_motor, self.gain*control[0], vrep.simx_opmode_oneshot_wait)
vrep.simxSetJointTargetVelocity(self.client_id, self.right_motor, self.gain*control[1], vrep.simx_opmode_oneshot_wait)
示例10: handle_input
def handle_input(self, values):
# Set the velocity to some large number with the correct sign,
# because v-rep is weird like that
vrep.simxSetJointTargetVelocity(self.cid, self.arm_joint, values[0]*100,
vrep.simx_opmode_oneshot)
# Apply the desired torques to the joints
# V-REP is looking for just the absolute value here
vrep.simxSetJointForce(self.cid, self.arm_joint, abs(values[0]),
vrep.simx_opmode_oneshot)
示例11: setController
def setController(self, name, typeController, val):
"""
Give an order to a controller
"""
if typeController == "motor":
if name in self.handles.keys():
pass
else:
self.initHandle(name)
motor_handle=self.handles[name]
vrep.simxSetJointTargetVelocity(self.clientID,motor_handle,val, vrep.simx_opmode_streaming)
示例12: applyActionAbsolute
def applyActionAbsolute(self,action):
self.desiredWheelRotSpeed=self.absSpeed[action[0]]
self.desiredSteeringAngle=self.absAngle[action[1]]
returnCode=vrep.simxSetJointTargetVelocity(self.clientID,self.ml,self.desiredWheelRotSpeed,vrep.simx_opmode_oneshot)
returnCode=vrep.simxSetJointTargetVelocity(self.clientID,self.mr,self.desiredWheelRotSpeed,vrep.simx_opmode_oneshot)
steeringAngleLeft=math.atan(self.l/(-self.d+self.l/math.tan(self.desiredSteeringAngle+0.00001)))
steeringAngleRight=math.atan(self.l/(self.d+self.l/math.tan(self.desiredSteeringAngle+0.00001)))
returnCode=vrep.simxSetJointTargetPosition(self.clientID,self.sl,steeringAngleLeft,vrep.simx_opmode_oneshot)
returnCode=vrep.simxSetJointTargetPosition(self.clientID,self.sr,steeringAngleRight,vrep.simx_opmode_oneshot)
示例13: run360
def run360():
print "connecting to vrep with address", IPADDRESS, "on port", PORT
clientID = vrep.simxStart(IPADDRESS, PORT, True, True, 5000, 5)
print "hello vrep! ", clientID
if clientID == -1:
print "failed to connect to vrep server"
return
# get the motor joint handle
error,jointHandle = vrep.simxGetObjectHandle(clientID, "plantStandMotor", vrep.simx_opmode_oneshot_wait)
print "starting the motor..."
# set the velocity of the joint
vrep.simxSetJointTargetVelocity(clientID, jointHandle, 1.0, vrep.simx_opmode_oneshot_wait);
print "spinning 360 degrees..."
# set up to stream joint positions
vrep.simxGetJointPosition(clientID, jointHandle, vrep.simx_opmode_streaming);
passed90Degrees = False
# The control loop:
while vrep.simxGetConnectionId(clientID) != -1 : # while we are connected to the server..
(error,position) = vrep.simxGetJointPosition(
clientID,
jointHandle,
vrep.simx_opmode_buffer
)
# Fetch the newest joint value from the inbox (func. returns immediately (non-blocking)):
if error==vrep.simx_error_noerror :
# here we have the newest joint position in variable jointPosition!
# break when we've done a 360
if passed90Degrees and position >= 0 and position < math.pi/2.0:
break
elif not passed90Degrees and position > math.pi/2.0:
passed90Degrees = True
print "stoppping..."
vrep.simxSetJointTargetVelocity(clientID, jointHandle, 0.0, vrep.simx_opmode_oneshot_wait);
if clientID != -1:
vrep.simxFinish(clientID)
print "done!"
示例14: reset_vrep
def reset_vrep():
print 'Start to connect vrep'
# Close eventual old connections
vrep.simxFinish(-1)
# Connect to V-REP remote server
clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
opmode = vrep.simx_opmode_oneshot_wait
# Try to retrieve motors and robot handlers
# http://www.coppeliarobotics.com/helpFiles/en/remoteApiFunctionsPython.htm#simxGetObjectHandle
ret_l, LMotorHandle = vrep.simxGetObjectHandle(clientID, "Pioneer_p3dx_leftMotor", opmode)
ret_r, RMotorHandle = vrep.simxGetObjectHandle(clientID, "Pioneer_p3dx_rightMotor", opmode)
ret_a, RobotHandle = vrep.simxGetObjectHandle(clientID, "Pioneer_p3dx", opmode)
vrep.simxSetJointTargetVelocity(clientID, LMotorHandle, 0, vrep.simx_opmode_blocking)
vrep.simxSetJointTargetVelocity(clientID, RMotorHandle, 0, vrep.simx_opmode_blocking)
time.sleep(1)
vrep.simxStopSimulation(clientID, vrep.simx_opmode_oneshot_wait)
vrep.simxFinish(clientID)
print 'Connection to vrep reset-ed!'
示例15: moveKJuniorReadProxSensors
def moveKJuniorReadProxSensors(self):
"slowly move forward and print normal vector readings"
intens = 100
ambientIntens = 0
attVect = [0,0,pi *4]
rightInput = vrep.simxReadProximitySensor(self.simulID, self.KJrightEye, vrep.simx_opmode_streaming)
leftInput = vrep.simxReadProximitySensor(self.simulID, self.KJleftEye, vrep.simx_opmode_streaming)
centerInput = vrep.simxReadProximitySensor(self.simulID, self.KJcenterEye, vrep.simx_opmode_streaming)
vrep.simxSynchronousTrigger(self.simulID)
print "Proximity sensor readings error codes: ", rightInput[0],leftInput[0]
for step in xrange(self.noSteps):
rightSpeed = 10
leftSpeed = rightSpeed
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.KJrightMotor, rightSpeed, vrep.simx_opmode_oneshot_wait)
eCode = vrep.simxSetJointTargetVelocity(self.simulID, self.KJleftMotor, leftSpeed, vrep.simx_opmode_oneshot_wait)
vrep.simxSynchronousTrigger(self.simulID)
rightInput = vrep.simxReadProximitySensor(self.simulID, self.KJrightEye, vrep.simx_opmode_buffer)
vrep.simxSynchronousTrigger(self.simulID)
leftInput = vrep.simxReadProximitySensor(self.simulID, self.KJleftEye, vrep.simx_opmode_buffer)
vrep.simxSynchronousTrigger(self.simulID)
centerInput = vrep.simxReadProximitySensor(self.simulID, self.KJcenterEye, vrep.simx_opmode_buffer)
vrep.simxSynchronousTrigger(self.simulID)
#===================================================================
# print "Left-->err:%s - Detct'd: %s\t%s\t\t\tRight--> err:%s - Detct'd: %s\t%s" % (leftInput[0],
# leftInput[3],
# leftInput[4],
# rightInput[0],
# rightInput[3],
# rightInput[4])
#===================================================================
angle = degrees(self.angleBetVecs([0,0,1], centerInput[2]))
lightReading = self.irradAtSensor(intens, ambientIntens, centerInput[2], attVect)
print "Center-->err:%s - Detct'd: %s\tAngle:%.3f\tIrrad:%.3f\tNorm: %.3f\tVector:%s\t" % (centerInput[0],
centerInput[3],
angle,
lightReading,
norm(centerInput[2]),
centerInput[2])
sleep(0)