The inverse kinematics is implemented in the inverse_kinematics method of the Robot class which includes the formulas covered in the previous part of the lesson:
123
definverse_kinematics(self,v_f,v0):self.vr=v_f+self.track_radius*v0# Velocity of right wheelsself.vl=v_f-self.track_radius*v0# Velocity of left wheels
This involves setting each set of wheels(left and right), with the velocity calculated from the inverse kinematics. This way we are able to make our robot move.
1 2 3 4 5 6 7 8 9101112131415161718
defsetVelocity(self):# setting velocity on the left and right wheels(you set wheels to left and right not individual in tank drive)forwheelinself.wheels_left:p.setJointMotorControl2(bodyIndex=self.robot_id,jointIndex=wheel,controlMode=p.VELOCITY_CONTROL,targetVelocity=self.vl,force=50# i think the torque on a jackal)forwheelinself.wheels_right:p.setJointMotorControl2(bodyIndex=self.robot_id,jointIndex=wheel,controlMode=p.VELOCITY_CONTROL,targetVelocity=self.vr,force=50# i think the torque on a jackal)