Code: Select all
import sim
sim.simxFinish(-1)
clientID = sim.simxStart('127.0.0.1',19998,True,True,5000,5)
_, youBot_handle = sim.simxGetObjectHandle(clientID, 'youBot', sim.simx_opmode_blocking)
wheel_joints_handle = [-1,-1,-1,-1];
_, wheel_joints_handle[0] = sim.simxGetObjectHandle(clientID, 'rollingJoint_fl', sim.simx_opmode_blocking)
_, wheel_joints_handle[1] = sim.simxGetObjectHandle(clientID, 'rollingJoint_fr', sim.simx_opmode_blocking)
_, wheel_joints_handle[2] = sim.simxGetObjectHandle(clientID, 'rollingJoint_rr', sim.simx_opmode_blocking)
_, wheel_joints_handle[3] = sim.simxGetObjectHandle(clientID, 'rollingJoint_rl', sim.simx_opmode_blocking)
[forward_back_vel, left_right_vel, rotation_vel] = [0.5, 0, 0]
while True:
sim.simxSetJointTargetVelocity(clientID, wheel_joints_handle[0], -forward_back_vel + left_right_vel - rotation_vel, sim.simx_opmode_blocking)
sim.simxSetJointTargetVelocity(clientID, wheel_joints_handle[1], -forward_back_vel - left_right_vel + rotation_vel, sim.simx_opmode_blocking)
sim.simxSetJointTargetVelocity(clientID, wheel_joints_handle[2], -forward_back_vel + left_right_vel + rotation_vel, sim.simx_opmode_blocking)
sim.simxSetJointTargetVelocity(clientID, wheel_joints_handle[3], -forward_back_vel - left_right_vel - rotation_vel, sim.simx_opmode_blocking)
_, youBot_position = sim.simxGetObjectPosition(clientID, youBot_handle, -1, sim.simx_opmode_blocking)
print(youBot_position)