Knowledge Base

Set Sensor Rotation Block

output-onlinepngtools__10_.png This block works for Ruby Robot! 

The robot's sensors are configured at various pre-determined ports along its body, and are initially pointed in one direction or another. But you can always change these sensors' direction, with the Set Sensor Rotation block.

Some sensors are built with several joints, like a human's arm. Imagine the shoulder, elbow, and wrist joints. In robotics, the joints are numbered, starting with 0. So the first joint, the 'base', would be the shoulder (0), next would be the elbow (1), and then the wrist joint (2).

The 0 Joint

In this example of an ultrasonic sensor placed on top of the robot, the 0 joint can be rotated sideways, allowing the robot to "look around".

rotating_top_US_0_to_90_and_back.gif  mceclip0.png

 

The 1 Joint 

In this code example, changing the 1 joint's values tilts the ultrasonic sensor up and down, allowing the robot to check for objects on the ground or up over its head. 


rotating_top_US_angle_1_to_55_-_look_up.gif  mceclip0.png

 

Some sensors have only one degree of rotation, in which case you should only use the 0 joint.

Tip:

It's best to follow up a Set Sensor Rotation block with a Wait Until block containing a Get Sensor Rotation block and same values you put into the Set Sensor Rotation block.

This way, you can be sure that the robot has completed the adjustment of the sensor's rotation angle before it executes the rest of the code.

Was this article helpful?
0 out of 0 found this helpful

Comments

Please sign in to leave a comment.

Powered by Zendesk