2019 Botball Training
Week Two
Using a Drive Base and More C Programming
Training Schedule
We will meet from 7:00 - 9:30 PM every Friday from January 11 to February 1.
1/11: Introduction to Programming
1/18: Using a Drive Base and More C Programming
1/25: Using the iCreate
2/1: Advanced Topics
Please try to be on time for the training meetings and make sure to bring your own device!
Week One Recap
We went over:
Building Your First Robot
Your First Bot
The robot will include:
Attaching the beam to the servo
Attaching the beam to the servo
Attaching the beam to the servo
Attaching the beam to the servo
Attaching the beam to the servo
Attaching the beam to the servo
Attaching the beam to the servo
Servo Mount, Caster Ball, and Motors
Putting the servo into the servo mount
Putting the servo into the servo mount
Putting the servo into the servo mount
Putting the servo into the servo mount
Putting the servo into the servo mount
Screwing the beams onto the chassis
Screwing the beams onto the chassis
Attaching more beams onto the chassis
Attaching more beams onto the chassis
Attaching more beams onto the chassis
Attaching more beams onto the chassis
Attaching more beams onto the chassis
Attaching more beams onto the chassis
Attaching more beams onto the chassis
Attaching more beams onto the chassis
Attaching the Wallaby onto the beams
Attaching the Wallaby onto the beams
Attaching the Wallaby onto the beams
Connect
Battery
Connect
Wires
Make sure the motor wires are both plugged in the same direction
Servo should be plugged in with the yellow cable closest to the screen
Done!
Programming
Motors and Servos
Motors
Motors
Motor ports
Motor Functions
motor() vs. mav()
More Motor Commands
Motor Screen
Servos
Servo ports
Servos
Motors vs. Servos
How to use a servo
More Servo Commands
Servo Screen
Servos
Exercise 1
Your program must:
Remember to run the robot on the ground!
Useful commands:
Solution for Exercise 1
int main() {
mav(0, 1000); // drive forward
mav(1, 1000);
msleep(2000);
mav(0, 0); // stop motors
mav(1, 0);
set_servo_position(0, 600); // move arm up
msleep(1000); // wait for servo to move
mav(0, -1000); // drive backward
mav(1, -1000);
msleep(2000);
mav(0, 0); // stop motors
mav(1, 0);
set_servo_position(0, 0); // move arm down
msleep(1000);
}
Exercise 2
Your program must:
Consider using a for-loop.
Solution for Exercise 2
int main() {
mav(0, 1000);
mav(1, 1000);
msleep(2000);
clear_motor_position_counter(0);
mav(0, 1000);
mav(1, 400);
while (get_motor_position_counter(0) < 7000) {
msleep(50);
}
mav(0, 0);
mav(1, 0);
}
Adjust until 90 degrees!
Exercise 3
(Harder)
Create a function slow_servo with the following specs.
void slow_servo(int port, int position);
Solution for Exercise 3
void slow_servo(int port, int position) {
enable_servo(port);
float i;
int interval = (position - get_servo_position(port)) / 100; // compute small movements to increment with
for(i = 0; i < 100; i++) {
set_servo_position(port, get_servo_position(port) + interval);
msleep(20);
}
disable_servo(port);
}
Summary
Today we covered:
Closing Thoughts
Next week, we will cover using sensors on the Wallaby and driving the iCreate.
If you would like to learn more about the C language in the meantime, take a look at these resources:
Code Solutions are posted at: https://tinyurl.com/botballtraining
More botball functions (old but most are the same):
https://tinyurl.com/botballfunctions
See you next week!