Comparing LEGO SPIKE Prime Programming : Which Is Best for Robotics Competitions? - 2
Does the Programming Environment Affect Precision? A 360° Rotation Test When using LEGO SPIKE Prime in robotics competitions, does the choice of programming environment impact movement precision? To investigate this, I conducted an experiment comparing different programming environments. Tested Programming Environments I compared the following four environments: Word Blocks (SPIKE App 3) → Download here Python (SPIKE App 3) → Download here Python (Pybricks) → More info C Language (spike-rt) → GitHub repository Robot Configuration For the test, I used a car-type robot with the following setup: •Left motor: Port A •Right motor: Port B Test Method To compare the environments, I conducted the following test: Command the robot to rotate 360° using a specified motor angle Measure the difference between the target and actual rotation angles Perform 10 trials for each environment and calculate the average error The same logic was used for all environments Program Code (for all environments): Word Blocks (SPIKE App3) Python (SPIKE App3) tread = 8 d_tire = 5.6 goal = 360; for i in range(10): motor.reset_relative_position(port.A, 0) start_angle = motor.relative_position(port.A) motor.run(port.A, -300) motor.run(port.B, -300) while tread/d_tire*goal > -motor.relative_position(port.A): pass motor.stop(port.A, stop=motor.BRAKE) motor.stop(port.B, stop=motor.BRAKE) time.sleep_ms(500) print("error:", abs(motor.relative_position(port.A)-start_angle) - tread/d_tire*goal ) Python (Pybricks) hub = PrimeHub() motorA = Motor(Port.A, Direction.COUNTERCLOCKWISE) motorB = Motor(Port.B, Direction.CLOCKWISE) tread = 8 d_tire = 5.6 goal = 360 for i in range(10): start_angle = motorA.angle() motorA.run(300) motorB.run(-300) while tread/d_tire*goal > motorA.angle() - start_angle: pass motorA.brake() motorB.brake() wait(500) print("error", motorA.angle()-start_angle - tread/d_tire*goal ) C Language (spike-rt) void Main(intptr_t exinf) { dly_tsk(5000000); uint8_t tread = 8; float d_tire = 5.6; uint32_t goal = 360; motorA = pup_motor_init(PBIO_PORT_ID_A, PUP_DIRECTION_COUNTERCLOCKWISE); motorB = pup_motor_init(PBIO_PORT_ID_B, PUP_DIRECTION_CLOCKWISE); int8_t i; for (i = 0; i < 10; i++){ pup_motor_reset_count(motorA); pup_motor_set_speed(motorA, 300); pup_motor_set_speed(motorB, -300); while(tread/d_tire*goal > pup_motor_get_count(motorA)); pup_motor_brake(motorA); pup_motor_brake(motorB); dly_tsk(500000); float error = pup_motor_get_count(motorA) - (tread / d_tire * goal); syslog(LOG_NOTICE, "error: %d.%05d", (int)error, (int)((error - (int)error) * 100000)); } } Results: Which Environment Was Most Precise? Here are the average rotation errors (smaller is better): 1️⃣ 12° - C Language (spike-rt)

Does the Programming Environment Affect Precision? A 360° Rotation Test
When using LEGO SPIKE Prime in robotics competitions, does the choice of programming environment impact movement precision?
To investigate this, I conducted an experiment comparing different programming environments.
Tested Programming Environments
I compared the following four environments:
- Word Blocks (SPIKE App 3) → Download here
- Python (SPIKE App 3) → Download here
- Python (Pybricks) → More info
- C Language (spike-rt) → GitHub repository
Robot Configuration
For the test, I used a car-type robot with the following setup:
•Left motor: Port A
•Right motor: Port B
Test Method
To compare the environments, I conducted the following test:
- Command the robot to rotate 360° using a specified motor angle
- Measure the difference between the target and actual rotation angles
- Perform 10 trials for each environment and calculate the average error
- The same logic was used for all environments
Program Code (for all environments):
Word Blocks (SPIKE App3)
Python (SPIKE App3)
tread = 8
d_tire = 5.6
goal = 360;
for i in range(10):
motor.reset_relative_position(port.A, 0)
start_angle = motor.relative_position(port.A)
motor.run(port.A, -300)
motor.run(port.B, -300)
while tread/d_tire*goal > -motor.relative_position(port.A):
pass
motor.stop(port.A, stop=motor.BRAKE)
motor.stop(port.B, stop=motor.BRAKE)
time.sleep_ms(500)
print("error:", abs(motor.relative_position(port.A)-start_angle) - tread/d_tire*goal )
Python (Pybricks)
hub = PrimeHub()
motorA = Motor(Port.A, Direction.COUNTERCLOCKWISE)
motorB = Motor(Port.B, Direction.CLOCKWISE)
tread = 8
d_tire = 5.6
goal = 360
for i in range(10):
start_angle = motorA.angle()
motorA.run(300)
motorB.run(-300)
while tread/d_tire*goal > motorA.angle() - start_angle:
pass
motorA.brake()
motorB.brake()
wait(500)
print("error", motorA.angle()-start_angle - tread/d_tire*goal )
C Language (spike-rt)
void Main(intptr_t exinf)
{
dly_tsk(5000000);
uint8_t tread = 8;
float d_tire = 5.6;
uint32_t goal = 360;
motorA = pup_motor_init(PBIO_PORT_ID_A, PUP_DIRECTION_COUNTERCLOCKWISE);
motorB = pup_motor_init(PBIO_PORT_ID_B, PUP_DIRECTION_CLOCKWISE);
int8_t i;
for (i = 0; i < 10; i++){
pup_motor_reset_count(motorA);
pup_motor_set_speed(motorA, 300);
pup_motor_set_speed(motorB, -300);
while(tread/d_tire*goal > pup_motor_get_count(motorA));
pup_motor_brake(motorA);
pup_motor_brake(motorB);
dly_tsk(500000);
float error = pup_motor_get_count(motorA) - (tread / d_tire * goal);
syslog(LOG_NOTICE, "error: %d.%05d", (int)error, (int)((error - (int)error) * 100000));
}
}
Results: Which Environment Was Most Precise?
Here are the average rotation errors (smaller is better):
1️⃣ 12° - C Language (spike-rt)