What should I do to generate a smooth reciprocating motion with ros?

asked 2020-05-29 03:22:24 -0500

doubleJ gravatar image

updated 2020-05-29 05:00:27 -0500

gvdhoorn gravatar image

Hello. First, I want you to know that English is not my native language, so my words would not naturally reach to you.

I'm trying to generate a reciprocating motion of UR3e with ros melodic and ubuntu 18.04 lts. The robot's end-effector should move between 2 points with a linear trajectory. Therefore, I set waypoints between two points to make sure the trajectory of the end-effector is a linear one. I modified the following example code to generate the motion. (https://github.com/fmauch/universal_r...)

This is part of the modified code:

freq=.5
pi=3.141592653589793
period=0.1
steps=20

P = [[0 for x in range(6)] for y in range(steps)] # Waypoints of the position of the end-effector
Q = [[0 for x in range(6)] for y in range(steps)] # Waypoints of the position of the joints
W = [[0 for x in range(6)] for y in range(steps)] # Waypointe of the velocity of the joints
A = [[0 for x in range(6)] for y in range(steps)] # Waypoints of the acceleration of the joints

for i in range(0, steps):
    (P[i])[:] = [
        0.03 * math.sin(freq * 2 * pi * i * period),
        0.25 + 0.03 * math.sin(freq * 2 * pi * i * period),
        0.25 + 0.03 * math.sin(freq * 2 * pi * i * period),
        0.1 * math.sin(freq * 2 * pi * i * period),
        0.1 * math.sin(freq * 2 * pi * i * period),
        0.1 * math.sin(freq * 2 * pi * i * period),
        ]
 # Defining waypoints of the position of the end-effector

for i in range (0,steps):
    Q[i][:] = IK(P[i][:])
 # Defining waypoints of the position of the joints

for i in range (0,steps):
    if i == 0:
        W[i][:] = [0, 0, 0, 0, 0, 0]
    else:
        W[i][0] = (Q[i][0] - Q[i-1][0])/period
        W[i][1] = (Q[i][1] - Q[i-1][1])/period
        W[i][2] = (Q[i][2] - Q[i-1][2])/period
        W[i][3] = (Q[i][3] - Q[i-1][3])/period
        W[i][4] = (Q[i][4] - Q[i-1][4])/period
        W[i][5] = (Q[i][5] - Q[i-1][5])/period
 # Defining waypoints of the velocity of the joints

for i in range (0,steps):
    if i == 0:
        A[i][:] = [0, 0, 0, 0, 0, 0]
    else:
        A[i][0] = (W[i][0] - W[i-1][0])/period
        A[i][1] = (W[i][1] - W[i-1][1])/period
        A[i][2] = (W[i][2] - W[i-1][2])/period
        A[i][3] = (W[i][3] - W[i-1][3])/period
        A[i][4] = (W[i][4] - W[i-1][4])/period
        A[i][5] = (W[i][5] - W[i-1][5])/period
 # Defining waypoints of the acceleration of the joints

client = None

def move1():

    g = FollowJointTrajectoryGoal()
    g.trajectory = JointTrajectory()
    g.trajectory.joint_names = JOINT_NAMES

    for i in range (0,steps):
        g.trajectory.points = [JointTrajectoryPoint(positions=(Q[i])[:],
                       velocities=(W[i])[:], accelerations=(A[i])[:],
                       time_from_start=rospy.Duration.from_sec(period))]
        client.send_goal(g)

        try:
            client.wait_for_result()

        except KeyboardInterrupt:
            client.cancel_goal()
            raise

The problem is when the robot ... (more)

edit retag flag offensive close merge delete

Comments

What should I do to generate a smooth motion?

create a single trajectory and submit a single goal?

gvdhoorn gravatar image gvdhoorn  ( 2020-05-29 05:01:05 -0500 )edit

I mean generating a smooth reciprocating motion, that is the end-effector reciprocates between 2 points smoothly. Currently, the robot generates a discontinuous and unsmooth motion, that is the robot stops at a waypoint, then it moves to the next waypoint.

doubleJ gravatar image doubleJ  ( 2020-05-29 05:12:10 -0500 )edit