Main refactor#189
Conversation
|
Doxygen warnings output: (if empty, there are no warnings). Please correct any warnings before merging. |
| return (primary_val != 0) ? primary_val : secondary_val; | ||
| }; | ||
|
|
||
| pos_x = merge_input(mouse_x,ref.ref_data.kbm_interaction.mouse_speed_x) * 0.05 * delta; |
There was a problem hiding this comment.
I believe this breaks mouse aiming. The old code accumulated mouse movement with +=. Aiming now only reflects the mouse's tiny delta each loop.
|
|
||
| pos_x = merge_input(mouse_x,ref.ref_data.kbm_interaction.mouse_speed_x) * 0.05 * delta; | ||
| pos_y = merge_input(mouse_y,ref.ref_data.kbm_interaction.mouse_speed_y) * 0.05 * delta; | ||
| l_mouse_button = merge_input(l_mouse_button,ref.ref_data.kbm_interaction.button_left); |
There was a problem hiding this comment.
This writes the merged value, which is based on l_mouse_button, back into l_mouse_button. merge_input(l_mouse_button, ...) can keep selecting that previous true value even after the button is released, causing it to latch.
| #define LOOP_FREQ 1000 | ||
| #define HEARTBEAT_FREQ 2 | ||
| #ifdef PROFILER | ||
| Profiler prof; |
There was a problem hiding this comment.
Linker error when profiling is enabled through the flag in Profiler.hpp:
./build/./src/main.cpp.o:/Users/ranto/robotics/firmware/src/hello_robot.hpp:42: multiple definition of `prof'; ./build/./src/hello_robot.cpp.o:/Users/ranto/robotics/firmware/src/hello_robot.hpp:42: first defined here
This header is included in multiple source files, so we have to move this definition to a source file and access it through the extern in profiler.hpp.
Just a little main refactor to keep things interesting. Moved all Main functionality to member functions of a (hypervisor?) class called HelloRobot. This breaks up what was previously main.cpp into 5 primary functions, which can be individually run and tested. This reduces our main script to simply initializing the robot and running its main loop. The loop itself is now also broken up into the division I suggested above. The HelloRobot class owns all of the managers and hardware interfaces, except for ref and the comms_layer, which have been globalized. The purpose of this architectural change is to allow for unit tests of all main file functionality.