资源说明:
SBHS Code SBHS CODE
This is the library for and by the SBHS Robotics Club.
This library is based on the Norman Advanced Robotics OpenCode library.
The two files follow what are fairly drastically different coding methodologies.CBC CLASS
The CBC class file defines a class called cbc. Two cbc instances are called by default called lego and create.
Obivously, the lego instance is used to control the CBC connected to the lego bot and the create instance is used to control the cbc connected to the create.
The cbc class has multiple structures that control different states of the bot.
The class also uses several methods that alter the states of the bot and control the bots in different ways.
Structures:
drive_motors:This structure contains the states of the motors that make the robot move around. Generally only used for the robot used in the lego bot because the create has its own drive motors. Initialized by default are left and right.
includes:
- port: the number port the drive motor is in
- radius_to_middle: one half the distance between the drive motors (wheels)
- ticks: amount of ticks in one revolution of the wheel. Nominally (or normally) 1000
- diameter: diameter of the wheel attatched to the motor
gen_motor:This structure contains the states of the motors that do not make the robot move around, eg arms, levers, massive cranes. Normally used for both bots. Initialized by default are motors called gen[i] where i is the index of the motor.
includes:
- port: the number port that the motor is in
- ticks: amount of ticks in one revolution of the wheel (1000)
- diameter: diameter of the wheel attatched to the motor
servo:This structure contains the states of the servos connected to the bots. Normally used for both bots.
includes:
- port: the number port that the servo is in
- ticks: amount of ticks that the servo can go through (2048)
- min: the minimum tick value (0)
- max: the maximum tick value (2047)
s_analog:This structure contains the two states used for analog sensors.
includes:
- port: the port that the sensor is in
- value: the current value of the port, defined by the analog10 function
s_digital:This structure containse the two states used for digital sensors.
includes:
- port: the port that the sensor is in
- value: the current value of the port defined by the digital function
Methods:
build_left_motor(int , float , float , float)This method sets up the left drive motor, populating its values.
- int p: port that the left drive motor is in
- float r: radius to middle: one half the distance from one motor to the other
- float t: ticks: the amount of ticks in one revolution of the wheel (1000)
- float d: diameter of the wheel attatched to the motors
build_right_motor(int , float , float , float)This method sets up the right drive motor, populating its values.
- int p: port that the left drive motor is in
- float r: radius to middle: one half the distance from one motor to the other
- float t: ticks: the amount of ticks in one revolution of the wheel (1000)
- float d: diameter of the wheel attatched to the motors
build_generic_motor(int , int , int , float)This method sets up any index of the generic, non-drive related motors.
- int n: index of the motor
- int p: port of the motor
- int t: ticks: the amount of ticks in one revolution of the wheel (1000)
- float d: diameter: the diameter of the wheel attatched to the motor
build_servo(int , int , int , int , int)This method sets up any index of the default servos.
- int n: the index of the servo
- int p: the port that the servo is in
- int t: ticks: amount of ticks that the servo can go through (2048)
- int mi: min: the minimum value of the servo (0)
- int ma: max: the maximum value of the servo (2047)
drive_straight(int , float)This method makes the left and right motors drive forward at the same speed.
- int s: speed: the forward velocity at ticks per second
- int
drive_arc(int, float , float , float)drive_spin(int , float , int)motor_spin_for(int , float , float , int)motor_spin_ticks(int , int , int , int)move_servo_to(int , int)double_servo_move(int , int , int)average(int , int)ramp_up(float , float)mm_to_ticks(float)ticks_to_mm(float)bmd_both()
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。