Robot settings - NTheuws/linorobot2_software GitHub Wiki

On the robot computer, go to the config folder and open lino_base_config.h. Uncomment the base, motor driver and IMU you want to use for your robot. For example:

#define LINO_BASE DIFFERENTIAL_DRIVE
#define USE_GENERIC_2_IN_MOTOR_DRIVER
#define USE_GY85_IMU

Constants' Meaning:

ROBOT TYPE (LINO_BASE)

  • DIFFERENTIAL_DRIVE - 2 wheel drive or tracked robots w/ 2 motors.

  • SKID_STEER - 4 wheel drive robots.

  • MECANUM - 4 wheel drive robots using mecanum wheels.

MOTOR DRIVERS

  • USE_GENERIC_2_IN_MOTOR_DRIVER - Motor drivers that have EN (pwm) pin, and 2 direction pins (usually DIRA, DIRB pins).

  • USE_GENERIC_1_IN_MOTOR_DRIVER - Motor drivers that have EN (pwm) pin, and 1 direction pin (usual DIR pin). These drivers usually have logic gates included to lessen the pins required in controlling the driver.

  • USE_BTS7960_MOTOR_DRIVER - BTS7960 motor driver.

  • USE_ESC_MOTOR_DRIVER - Bi-directional (forward/reverse) electronic speed controllers.

INERTIAL MEASUREMENT UNIT (IMU)

  • USE_GY85_IMU - GY-85 IMUs.

  • USE_MPU6050_IMU - MPU6060 IMUs.

  • USE_MPU9150_IMU - MPU9150 IMUs.

  • USE_MPU9250_IMU - MPU9250 IMUs.



Next, fill in the robot settings accordingly:

#define K_P 0.6
#define K_I 0.8
#define K_D 0.5

#define MOTOR_MAX_RPM 100             
#define MAX_RPM_RATIO 0.85          
#define MOTOR_OPERATING_VOLTAGE 24
#define MOTOR_POWER_MAX_VOLTAGE 12
#define MOTOR_POWER_MEASURED_VOLTAGE 11.7

#define COUNTS_PER_REV1 2200    
#define COUNTS_PER_REV2 2200      
#define COUNTS_PER_REV3 2200      
#define COUNTS_PER_REV4 2200      

#define WHEEL_DIAMETER 0.09  
#define LR_WHEELS_DISTANCE 0.2  

#define PWM_BITS 10
#define PWM_FREQUENCY 20000

Constants' Meaning:

  • K_P, K_I, K_D - PID constants used to translate the robot's target velocity to motor speed. These values would likely work on your build, change these only if you experience jittery motions from the robot or you'd want to fine-tune it further.

  • MOTOR_MAX_RPM - Motor's maximum number of rotations it can do in a minute specified by the manufacturer.

  • MAX_RPM_RATIO - Percentage of the motor's maximum RPM that the robot is allowed to move. This parameter ensures that the user-defined velocity will not be more than or equal the motor's max RPM, allowing the PID to have ample space to add/subtract RPM values to reach the target velocity. For instance, if your motor's maximum velocity is 0.5 m/s with MAX_RPM_RATIO set to 0.85, and you asked the robot to move at 0.5 m/s, the robot's maximum velocity will be capped at 0.425 m/s (0.85 * 0.5m/s). You can set this parameter to 1.0 if your wheels can spin way more than your operational speed.

    Wheel velocity can be computed as: MAX_WHEEL_VELOCITY = (MOTOR_MAX_RPM / 60.0) * PI * WHEEL_DIAMETER

  • MOTOR_OPERATING_VOLTAGE - Motor's operating voltage specified by the manufacturer (usually 5V/6V, 12V, 24V, 48V). This parameter is used to calculate the motor encoder's COUNTS_PER_REV constant during calibration and actual maximum RPM of the motors. For instance, a robot with MOTOR_OPERATING_VOLTAGE of 24V with a MOTOR_POWER_MAX_VOLTAGE of 12V, will only have half of the manufacturer's specified maximum RPM ((MOTOR_POWER_MAX_VOLTAGE / MOTOR_OPERATING_VOLTAGE) * MOTOR_MAX_RPM).

  • MOTOR_POWER_MAX_VOLTAGE - Maximum voltage of the motor's power source. This parameter is used to calculate the actual maximum RPM of the motors.

  • MOTOR_POWER_MEASURED_VOLTAGE - Measured voltage of the motor's power source. If you don't have a multimeter, it's best to fully charge your battery and set this parameter to your motor's operating voltage (MOTOR_OPERATING_VOLTAGE). This parameter is used to calculate the motor encoder's COUNTS_PER_REV constant. You can ignore this if you're using the manufacturer's specified counts per rev.

  • COUNTS_PER_REVX - The total number of pulses the encoder has to read to be considered as one revolution. You can either use the manufacturer's specification or the calibrated value in the next step. If you're planning to use the calibrated value, ensure that you have defined the correct values for MOTOR_OPERATING_VOLTAGE and MOTOR_POWER_MEASURED_VOLTAGE.

  • WHEEL_DIAMETER - Diameter of the wheels in meters.

  • LR_WHEELS_DISTANCE - The distance between the center of left and right wheels in meters.

  • PWM_BITS - Number of bits in generating the PWM signal. You can use the default value if you're unsure what to put here. More info here.

  • PWM_FREQUENCY - Frequency of the PWM signals used to control the motor drivers. You can use the default value if you're unsure what to put here. More info here.



Previous step: Firmware

Next step: Pin assignment

⚠️ **GitHub.com Fallback** ⚠️