How cyber_bot_gripper_forward_object_distance_with_fb360 Works
First, the script begins by importing the cyberbot and feedback360 modules as expected. Next, the script starts the feedback360.drive system with drive.connect(). Then, the script enters an endless while True: loop that monitors the micro:bit module’s B button to see if it was pressed.
# cyber_bot_gripper_forward_object_distance_with_fb360 from cyberbot import * from feedback360 import * drive.connect() display.show(Image.ARROW_E) while True: if button_b.was_pressed():
If the B button was pressed, the cyber:bot starts by lowering and opening the Gripper. Next, it rolls forward for half of a wheel turn, then stops. Then, the script uses bot(15).servo_angle(30) to close the Gripper. That is followed by sleep(1500) to give the Gripper time to close and lift, and partially to make a slight pause between picking up the object and starting to move.
display.clear() bot(15).servo_angle(150) # Lower & open gripper sleep(1500) drive.goto(32, 32) # Forward 0.5 wheel turn bot(15).servo_angle(30) # Close gripper & lift sleep(1500)
After lifting the object, this part of the script makes the cyber:bot roll forward 1.5 wheel turns. Then, it lowers and opens the Gripper, letting go of the object.
drive.goto(96, 96) # Forward 1.5 wheel turns bot(15).servo_angle(150) # Lower & open gripper sleep(1500)
Finally, it backs up half a wheel turn so that the object is no longer between the Gripper paddles.
drive.goto(-32, -32) # Backward 0.5 wheel turns display.show(Image.ARROW_E)