Sensors and Actionators - NUbots/robocup GitHub Wiki

How do I Actionate Something?

Everything is actionated using a NUActionatorsData. There is a (single) NUActionatorsData instance that is passed around between modules, each module adds actions it wants performed. Once all modules have completed, the actions are processed.

There are only a few functions needed to add actions to NUActionatorsData. For example, addJointPosition(joint_id_t jointid, double time, float position, float velocity, float gain) and addJointPositions(bodypart_id_t partid, double time, const vector<float>& positions, const vector<float>& velocities, const vector<float>& gains); are used to move the joints, with the former changing only a single joint, and the latter specify an action for every joint in a body part.

How do I Sense Something?

Everything that is sensed is put into a NUSensorsData. There is a (single) NUSensorsData instance available to each module.

You can extract data from the class using the get methods, where a vector is updated the order will be according to Joint Orders and Coordinate Orders. For example, get a single joint position with getJointPosition(joint_id_t jointid, float& position) or get a vector of them using getJointPositions(bodypart_id_t bodypart, vector<float>& positions).

Joint Orders

As joint data is stored in vectors, you need to know the order of joints in the vector. The joints are ordered according to the following rules:

  • Top to Bottom
  • Left to Right

The degrees of freedom for each joint are then ordered as

  • Roll, Pitch, Yaw

For example, the joint order might be HeadPitch, LShoulderRoll, LShoulderPitch, RShoulderRoll, RShoulderPitch, TorsoYaw, LHipRoll, LHipPitch, RHipRoll, RHipPitch.

Coordinate Orders

As sensor data is stored in vectors, you need to know the order coordinates are stored in vectors. The order follows from the standard coordinate system.

  • [x, y, z] for cartesian sensors (accelerometer)
  • [roll, pitch, yaw] for angular sensors (gyro)
  • top to bottom, left to right, and front to back for tactile sensors (buttons)
  • [red, blue, green] for coloured sensors and actionators (leds)
⚠️ **GitHub.com Fallback** ⚠️