Calculate velocity and acceleration when joint positions are provided
I am working Ubuntu 16.04, Ros-Kinetic and using 7-DOF panda manipulator arm (all rotary joints). I have a function which gives me the joint_positions as
[ [q1, q2, ..q7], [q1+dq1, q2+dq2....., q7+dq7], ....... [q1+n*dq1, q2+n*dq2,......., q7+n*dq7]]
I want to create a joint trajectory just like the group.plan()
function in moveit. This moveit function generates velocities, acceleration, time_from_start etc which then is fed to group.go()
or group.execute()
. I would like to use exactly the same functionality but with my joint positions in the trajectory_msgs\JointTrajectory
message.
Is there a way to use some functions to calculate the velocities, accelerations etc? I am hoping to find something so that I can use the following function to create the jointTrajectory msg
def create_trajectory(positions, velocities, accelerations, t):
joint_trajectory = JointTrajectory()
for i in range(0, len(q_list)):
point = JointTrajectoryPoint()
point.positions = list(q_list[i])
point.velocities = list(v_list[i])
point.accelerations = list(a_list[i])
point.time_from_start = rospy.Duration(t[i])
joint_trajectory.points.append(point)
joint_trajectory.joint_names = self.joint_names
return joint_trajectory
Any help would be really appreciated.