why my while is not working?

Typically: "How do I... ", "How can I... " questions
Post Reply
jetixmen
Posts: 14
Joined: 03 Oct 2023, 08:45

why my while is not working?

Post by jetixmen »

Hello, I want to control the trajectory of the robot going to the target position. For this, I divided the distance between the target point and the first position of the endeffector by a hundred, and each time I control the trajectory by determining the next target of these 100 steps. BUT, as far as I understand, it only takes about one simulation loop time for each of my iterated goal sets of 100 steps. For this reason, let's say the time spent for 100 steps is 5 seconds, it cannot go somewhere it cannot reach in 5 seconds. I tried to fix this problem and ensure that it doesn't enter the next loop step until it reaches the target step each time, but it doesn't work. I'm sure the error is in this while part because it works without it.
So why doesn't this part work?
Thank you

Code: Select all

#python
theta1 += dq[0] 
    theta2 += dq[1]
    sim.setJointTargetPosition(joint1,theta1)
    sim.setJointTargetPosition(joint2,theta2)

    while joint1 != theta1:
        while joint2 != theta2:
            sim.setJointTargetPosition(joint1,theta1)
            sim.setJointTargetPosition(joint2,theta2)

fferri
Posts: 1230
Joined: 09 Sep 2013, 19:28

Re: why my while is not working?

Post by fferri »

jetixmen wrote: 02 Feb 2024, 15:58

Code: Select all

    while joint1 != theta1:
joint1 is the handle of a joint, theta1 is an angle.
What are you trying to do here?

Post Reply