Code: Select all
function sysCall_init()
jointHandles={-1,-1,-1,-1,-1,-1}
for i=1,6,1 do
jointHandles[i]=sim.getObjectHandle('prbt_joint_'..i)
end
sub=simROS.subscribe('/trajectory', 'trajectory_msgs/JointTrajectory', 'joint_callback')
simROS.subscriberTreatUInt8ArrayAsString(sub)
end
function joint_callback(msg)
targetPos1={msg.points[1].positions[1], msg.points[1].positions[2], msg.points[1].positions[3], msg.points[1].positions[4], msg.points[1].positions[5], msg.points[1].positions[6]}
print(msg)
for i=1,6,1 do
sim.setJointTargetPosition(jointHandles[i], targetPos1[i])
end
end
function sysCall_actuation()
end
function sysCall_cleanup()
simROS.shutdownSubscriber(sub)
end
Moreover, what should I write in the function sysCall_actuation if I already put the actuation part of the code in the function joint_callback()?
Thanks for your time!