Sensors Challenges 1

Ready to go?

Goal of these challenges:

Star Scale


Blinking LED

Using the LED

Control blinking speed with a function:


Push Button

Applications:

Push that button!

  1. Have the button call your blink_led()function!
    • 01-blink-with-button.cpp
  2. Have the button change the servo position
    • Hint: add 10 to the servo's position if the button is pressed
  3. ★★ With arrays: Have the button index through an array of integers
    • Bonus: use this array to set servo positions

Motor Characterization

Why bother?

Procedure

  1. Have the push button start each test
  2. Make sure you have a battery plugged in to your Raft! (the DC motors need 9V)
  3. Find the minimum power required to get each motor to spin
    • This minimum power is called the "deadband" of the motor
    • Keep note of each deadband somewhere
  4. Set both motors to some power above the deadband
    • Determine which motor is faster based on how your robot moves

Odometry Challenges

What is Odometry?

Stop after a distance

  1. Use the button to start the motors
  2. Give both motors the same power (something above the deadband)
  3. Stop the robot when BOTH encoders reach 200 counts
200 counts on each motor

More Odometry Challenges

Preview to Rotational Kinematics ;)

How many counts in one rotation?

  1. Experimentally determine how many counts getCount() returns in one rotation of the wheel
  2. How many counts for 10 rotations?

Rotate robot 360 Degrees

  1. Pick your favorite wheel, only give that wheel power
  2. Experimentally determine how many counts for the robot to spin around itself once (full 360)

Rotate robot 90 Degrees

  1. Give only one wheel power
  2. Experimentally determine number of counts to rotate 90 degrees
  3. Stop the robot after it rotates 90 degrees

★★★ Making functions

  1. Make a function right_turn() that makes a right turn >:)
  2. Make another function for left turns
  3. Make a travel forward function that takes in a number of counts as a parameter

Lidar Challenges

How can we detect objects?

Searching for object by spinning robot

  1. Use button to start wheels
  2. Hint: it is helpful if you make servo face forwards:)
  3. Have robot spin clockwise, have 2 options:
    • rotate only one wheel
    • rotate one wheel forwards, one backwards
  4. Stop the motors when lidar detects an object less than 200 mm away
  5. Bonus: blink the LED to show object detected!

★★★ Write a Function:

  1. Write a function that when called searches for the object
robot rotates until sees an object

Intro to Autonomous Navigation

Autonomous?

Hit the brakes!

  1. Use button to start robot's wheels
  2. Have servo face forwards
  3. Have robot drive forwards
  4. If an obstacle is detected, hit the brakes!

★★ Like that suitcase...

  1. Use button to start robot's wheels
  2. Have the robot stay 20 cm from an object

★★★ Target Acquired

  1. Use the button to start rotating the servo back and forth
  2. When an object is detected, stop the servo
  3. Store somewhere the "location" of the object
  4. Have the servo face forwards
  5. Rotate the robot towards the object until the object is detected again
  6. Blink LED when target acquired:)
robot stops 20 cm from object

Using IMU Data

Lots of options:

Measure Angular Velocity

  1. Using imu.getAngVelZ() data, figure out how fast you can spin the robot!

★★★ Intro to Control Theory