I have two joint values, initial and final (q_init and q_final).
If I want to write an RTDE loop on the external device that uses servoj() to move from q_init to q_final how would I do it.
I want to keep the dt = 1/500 to be able to send commands in 500Hz but the movement is not like I want it to be.
I know that there are tons of threads on the forum about servoj but I can’t find one that has an example like I need.
Thank you for help
to use the servoj - Command you would need to split the initial movement from q_init to q_final into smaller pieces for each joint. Depending on how fast the trajectory should be you need the steps to be smaller or larger. Other than the different move-commands servoj does not contain an acceleration or de-acceleration ramp. This needs also to be taken into account by you.
In the following you can find a rough sample for a possible approach:
global qJoint0 = 0 global qJoint1 = 0 global qJoint2 = 0 global qJoint3 = 0 global qJoint4 = 0 global qJoint5 = 0 global targetJointAngle = [0,0,0,0,0,0] thread getJointData(): while ( True ): qJoint0 = read_input_float_register( ... ) qJoint1 = read_input_float_register( ... ) qJoint2 = read_input_float_register( ... ) qJoint3 = read_input_float_register( ... ) qJoint4 = read_input_float_register( ... ) qJoint5 = read_input_float_register( ... ) sync() end end thrdGetJointData = run getJointData() def trajectoryWithServoJ(): while( True ): targetJointAngle = [ qJoint0, qJoint1, qJoint2, qJoint3, qJoint4, qJoint5 ] servoj( targetJointAngle, 0, 0, 0.002, 0.1, 300 ) end end trajectoryWithServoJ()
Please be cautious as I did not have run this code. Also the parameters provided in the servoj-Command are the sample ones. If you movement is not as intended, you can also adjust these within the given range.
Will try it out
You can find a very simple example on how to use RTDE and servoj here:
Would you be available for some questions regarding your github privately?
I would love to ask you some more specific question via mail or whatsapp whatever is more comfortable for you
You can write me to firstname.lastname@example.org