how can i make my robot move to a point directly?

Typically: "How do I... ", "How can I... " questions
Post Reply
kiko
Posts: 1
Joined: 20 Nov 2019, 16:36

how can i make my robot move to a point directly?

Post by kiko » 21 Nov 2019, 08:13

My robot doesn't move correctly.
I wanna my robot moves to a point directly, but my robot move like a crazy horse.
And it arrives at a wrong position
But, a position in a line "#" has robot's right behavior.
i don't know what is wrong

Code: Select all

def restart_sim():
    print("In restart_sim")
    sim_ret, UR5_target_handle = vrep.simxGetObjectHandle(sim_client, 'UR5_target', vrep.simx_opmode_blocking)
    vrep.simxSetObjectPosition(sim_client, UR5_target_handle, -1, (0.0, 0.3, 0.3), vrep.simx_opmode_blocking)
    # vrep.simxSetObjectPosition(sim_client, UR5_target_handle, -1, (-0.5, 0.0, 0.3), vrep.simx_opmode_blocking)
    vrep.simxStopSimulation(sim_client, vrep.simx_opmode_blocking)
    vrep.simxStartSimulation(sim_client, vrep.simx_opmode_blocking)
    time.sleep(2)
    sim_ret, RG2_tip_handle = vrep.simxGetObjectHandle(sim_client, 'UR5_tip', vrep.simx_opmode_blocking)
    sim_ret, gripper_position = vrep.simxGetObjectPosition(sim_client, RG2_tip_handle, -1, vrep.simx_opmode_blocking)
    while gripper_position[2] > 0.6:  # V-REP bug requiring multiple starts and stops to restart
        print("Not 0.5 gripper pos[2]")
        vrep.simxStopSimulation(sim_client, vrep.simx_opmode_blocking)
        vrep.simxStartSimulation(sim_client, vrep.simx_opmode_blocking)
        time.sleep(1)
        sim_ret, gripper_position = vrep.simxGetObjectPosition(sim_client, RG2_tip_handle, -1, vrep.simx_opmode_blocking)



sim_client = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)  # Connect to V-REP on port 19997
if sim_client == -1:
    print('Failed to connect to simulation (V-REP remote API server). Exiting.')
    exit()
else:
    print('Connected to simulation.')
    time.sleep(3)
    restart_sim()

coppelia
Site Admin
Posts: 7450
Joined: 14 Dec 2012, 00:25

Re: how can i make my robot move to a point directly?

Post by coppelia » 27 Nov 2019, 14:02

Hello, and sorry for the delay,

it is very difficult to say what is going on, we don't even know what kind of robot you are using.
Make sure to identify the source of problem: is it the physics simulation, or the algorithm? If it is the physics simulation, make sure that your robot is correctly designed for the physics engines. Also, make sure that your robot is not hyper static on the ground, since some engines can't cope well with that (in that case, simple add a spring-damper somewhere).
If it is the algorithm that causes problems, we probably won't be of big help, and are no specialists in that field. A simple approach for a two-wheeled robot (with caster/slider) would be to constantly compute the direction vector to the target, in the robot's frame. Then, from that vector, you can differentially actuate the left and right motors.

Cheers

Post Reply