Skip to content

Commit 782aed4

Browse files
committed
please build i need this
1 parent 1abc66d commit 782aed4

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

pybricks/experimental/odometry.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef PYBRICKS_EXPERIMENTAL_ODOMETRY_H
2+
#define PYBRICKS_EXPERIMENTAL_ODOMETRY_H
3+
4+
#include "py/obj.h"
5+
6+
// The signature must use float to match the core and avoid double-promotion errors
7+
mp_obj_t calculate_odometry(int num_iters, float wheel_circ, float axle_track, mp_obj_t right_angle_func, mp_obj_t left_angle_func);
8+
9+
#endif // PYBRICKS_EXPERIMENTAL_ODOMETRY_H

pybricks/experimental/pb_module_experimental.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,31 @@
55

66
#if PYBRICKS_PY_EXPERIMENTAL
77

8+
// Include this AFTER the MicroPython headers so mp_obj_t is defined
89
#include "pybricks/experimental/odometry.h"
910

10-
// Define STATIC if not already defined (usually it is in mpconfig.h)
1111
#ifndef STATIC
1212
#define STATIC static
1313
#endif
1414

15-
// This is the function that Python calls
1615
STATIC mp_obj_t experimental_odometry_benchmark(size_t n_args, const mp_obj_t *args) {
1716
int num_iters = mp_obj_get_int(args[0]);
1817
float wheel_circ = mp_obj_get_float(args[1]);
1918
float axle_track = mp_obj_get_float(args[2]);
2019
mp_obj_t right_func = args[3];
2120
mp_obj_t left_func = args[4];
2221

22+
// With the header included, the compiler now knows these are floats, not doubles
2323
return calculate_odometry(num_iters, wheel_circ, axle_track, right_func, left_func);
2424
}
25-
// Define as a MicroPython function object
25+
2626
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(experimental_odometry_benchmark_obj, 5, 5, experimental_odometry_benchmark);
2727

28-
// Map the C function to the Python name "odometry_benchmark"
2928
STATIC const mp_rom_map_elem_t experimental_globals_table[] = {
3029
{ MP_ROM_QSTR(MP_QSTR_odometry_benchmark), MP_ROM_PTR(&experimental_odometry_benchmark_obj) },
3130
};
3231
STATIC MP_DEFINE_CONST_DICT(pb_module_experimental_globals, experimental_globals_table);
3332

34-
// Structure for MicroPython to register the module
3533
const mp_obj_module_t pb_module_experimental = {
3634
.base = { &mp_type_module },
3735
.globals = (mp_obj_dict_t *)&pb_module_experimental_globals,

0 commit comments

Comments
 (0)