Source

#!/usr/bin/env python"""Shows usage of the JointTorque sensor, with the CentrifugalForce program.Sensor data is stored in a queue, which is retrieved after the simulation ends(but it can be accessed at any time).Sensor is created in :meth:`create_sim_objects`.>>> self.sensor = sen.JointTorque(joint_object, self.sim)It is updated automatically every time torque is added to the joint, i.e.each time ``joint.addTorque(x)`` is called.Sensor measurements can be easily retrieved at any time>>> self.sensor.data_queue.pull()"""importars.model.robot.sensorsassenfrombaseimportCentrifugalForceclassJointTorque(CentrifugalForce):defcreate_sim_objects(self):CentrifugalForce.create_sim_objects(self)joint_object=self.sim.get_joint('r2')self.sensor=sen.JointTorque(joint_object,self.sim)if__name__=='__main__':sim_program=JointTorque()sim_program.start()sensor=sim_program.sensorprint('sensor data queue count %d'%sensor.data_queue.count())print(sensor.data_queue)