ars / demos / sensors /

"""Shows usage of the JointPower 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 = sensors.JointPower(joint_object, self.sim)

It is updated automatically every time torque or force is added to the joint,
i.e. each call to ``joint.add_torque`` or ``joint.add_force``.

Sensor measurements can be easily retrieved at any time
>>> self.sensor.data_queue.pull()

from ars.model.robot import sensors

from .base import CentrifugalForce, PrintDataMixin

class JointPower(CentrifugalForce, PrintDataMixin):

	"""Simulation of a virtual power sensor attached to a joint (``r2``).

	This joint is not powered. However, because friction is considered,
	an external torque is applied at each simulation step
	(see :meth:`apply_friction`). Due to the fact it is a friction torque,
	**the applied power is negative**.

	The laser is positioned at :attr:`RAY_POS` and its detection range
	is determined by :attr:`RAY_LENGTH`. The default orientation
	(positive Z-axis) of the :class:`ars.model.robot.sensors.Laser`
	may be modified with :attr:`RAY_ROTATION`.

	.. seealso::

	The sensor is created in :meth:`create_sim_objects`:
		`self.sensor = sen.Laser(space, self.RAY_LENGTH)`

	and it is updated in :meth:`on_post_step`:


	def create_sim_objects(self):
		joint_object = self.sim.get_joint('r2')
		self.sensor = sensors.JointPower(joint_object, self.sim)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.