View on GitHub

ece4960-fast-robots

Lab Reports and Assignments for ECE 4960: Fast Robots

Lab 8: Stunts

Note: This lab was redone. To see the most updated results, check out this page.

Controlled Stunts

To do the flip, I first tried using PID control to get as close to the wall as possible. However, that would often cause my robot to stop too close to the wall instead; I needed it to have some forward velocity in order for the car to flip. To try to get around that, I set the proportional constant much higher than I normally would. However, that just caused the robot to slam into the wall:

P control fail

I didn’t implement the Kalman filter on the robot because of how its results weren’t reliable enough for my liking, so I then went for a simple approach of timing forward movement and suddenly reversing. This was the same approach I used before when the robots still relied on their remote controls.

bot.move_forward(255)
time.sleep(1)
bot.move_backward(255)
time.sleep(1)
bot.stop()

This caused the robot to move forward and then gently move backwards. I suspected that it took too long for bluetooth to send each command, so I eliminated that variability by creating a “sudden flip” command.

case SUDDEN_FLIP:
  success = robot_cmd.get_next_value(base_power);
  if (!success) return;
  stop_motors(true);
  move_backward(base_power);
  break;

I then called my command in Python code, and after some tries figuring out a good starting position, I got my car to do a flip.

bot.set_motor_calibration(1.8)
bot.start_data_collection()
bot.move_forward(255)
time.sleep(1)
bot.sudden_flip(255, scale=False)
time.sleep(1)
bot.stop()
bot.stop_data_collection()

You may notice that the sudden_flip() function has an option to scale. This refers to how my movement functions scale the maximum power down to 255 / motor_calibration_factor in order to ensure straight-line driving. For this flip, I suspected I would need all the power I could get given my bot’s tendancy to simply drive backwards instead of flip, so I made a way to turn the scaling off. This may also explain why we get a flip that’s more curved than straight.

Flip 1

Flip 2