Skip to content

Commit 73aee13

Browse files
committed
rename
1 parent 9681df5 commit 73aee13

3 files changed

Lines changed: 21 additions & 23 deletions

File tree

pybricks/experimental/odometry.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: MIT
12
#include "py/mpconfig.h"
23
#include "py/mphal.h"
34
#include "py/runtime.h"
@@ -20,8 +21,8 @@ mp_obj_t calculate_odometry(int num_iters, float wheel_circ, float axle_track, m
2021

2122
float dR = (float)(cur_r - last_r) * deg_to_mm;
2223
float dL = (float)(cur_l - last_l) * deg_to_mm;
23-
float dD = (dR + dL) * 0.5f;
24-
float dH = (dR - dL) * inv_axle_track;
24+
float dD = (dR + dL) * 0.5f;
25+
float dH = (dR - dL) * inv_axle_track;
2526

2627
if (dD != 0.0f || dH != 0.0f) {
2728
float avg_h = rh + (dH * 0.5f);
@@ -39,9 +40,9 @@ mp_obj_t calculate_odometry(int num_iters, float wheel_circ, float axle_track, m
3940

4041
uint32_t dur = mp_hal_ticks_ms() - start_time;
4142
mp_obj_t tuple[5] = {
42-
mp_obj_new_float_from_f((float)dur * 0.001f),
43+
mp_obj_new_float_from_f((float)dur * 0.001f),
4344
mp_obj_new_int(num_iters),
44-
mp_obj_new_float_from_f((float)num_iters / ((float)dur * 0.001f)),
45+
mp_obj_new_float_from_f((float)num_iters / ((float)dur * 0.001f)),
4546
mp_obj_new_float_from_f(rx),
4647
mp_obj_new_float_from_f(ry)
4748
};

pybricks/experimental/pb_module_experimental.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#include "pybricks/experimental/odometry.h"
88

9-
// 1. The actual benchmark logic
10-
// Keep this STATIC as it is used by the function object below
119
static mp_obj_t experimental_odometry_benchmark(size_t n_args, const mp_obj_t *args) {
1210
int num_iters = mp_obj_get_int(args[0]);
1311
float wheel_circ = mp_obj_get_float(args[1]);
@@ -17,21 +15,13 @@ static mp_obj_t experimental_odometry_benchmark(size_t n_args, const mp_obj_t *a
1715

1816
return calculate_odometry(num_iters, wheel_circ, axle_track, right_func, left_func);
1917
}
20-
// Define the function object
2118
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(experimental_odometry_benchmark_obj, 5, 5, experimental_odometry_benchmark);
2219

23-
// 2. The Globals Table
24-
// REMOVED 'STATIC' to prevent 'defined but not used' error
2520
const mp_rom_map_elem_t pb_module_experimental_globals_table[] = {
2621
{ MP_ROM_QSTR(MP_QSTR_odometry_benchmark), MP_ROM_PTR(&experimental_odometry_benchmark_obj) },
2722
};
28-
29-
// 3. Define the dict WITHOUT 'STATIC'
30-
// This makes it visible to the auto-registration system without triggering the warning
3123
MP_DEFINE_CONST_DICT(pb_module_experimental_globals, pb_module_experimental_globals_table);
3224

33-
// 4. Define the module structure WITHOUT 'STATIC'
34-
// This matches the 'extern' declaration the build system generates
3525
const mp_obj_module_t pb_module_experimental = {
3626
.base = { &mp_type_module },
3727
.globals = (mp_obj_dict_t *)&pb_module_experimental_globals,

pybricks/experimental/platform_math.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@ static inline float pb_fast_sin(float theta) {
88

99
// 1. Range Reduction to [-PI, PI]
1010
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
11-
// Spike Prime (Cortex-M4F) optimized wrap
12-
float x_wrap = theta * 0.159154943f;
13-
x = theta - (float)((int)(x_wrap + (x_wrap > 0.0f ? 0.5f : -0.5f))) * 6.2831853f;
11+
// Spike Prime (Cortex-M4F) optimized wrap
12+
float x_wrap = theta * 0.159154943f;
13+
x = theta - (float)((int)(x_wrap + (x_wrap > 0.0f ? 0.5f : -0.5f))) * 6.2831853f;
1414
#else
15-
// EV3 (ARM9) stable wrap
16-
while (x > 3.14159265f) x -= 6.28318531f;
17-
while (x < -3.14159265f) x += 6.28318531f;
15+
// EV3 (ARM9) stable wrap
16+
while (x > 3.14159265f) {
17+
x -= 6.28318531f;
18+
}
19+
while (x < -3.14159265f) {
20+
x += 6.28318531f;
21+
}
1822
#endif
1923

2024
// 2. Mirroring to [-PI/2, PI/2]
21-
if (x > 1.5707963f) x = 3.1415926f - x;
22-
else if (x < -1.5707963f) x = -3.1415926f - x;
23-
25+
if (x > 1.5707963f) {
26+
x = 3.1415926f - x;
27+
} else if (x < -1.5707963f) {
28+
x = -3.1415926f - x;
29+
}
30+
2431
// 3. The Spike Minimax Polynomial
2532
float x2 = x * x;
2633
return x * (0.99999906f + x2 * (-0.16665554f + x2 * (0.00831190f + x2 * -0.00018488f)));

0 commit comments

Comments
 (0)