[WIP] Protocol refactor#46
Conversation
|
Перед мерджем не забудьте пересобрать контейнер. |
|
| betterproto = {version = "^2.0.0b6", allow-prereleases = true} | ||
| crc = "^4.3.0" | ||
| cobs = "^1.2.0" | ||
| jsonref = "^1.1.0" |
| {url="https://download.pytorch.org/whl/cpu/torch-2.0.1%2Bcpu-cp310-cp310-win_amd64.whl", markers="platform_system == 'Windows' and platform_machine == 'amd64'"} | ||
| ] | ||
| varint = "^1.0.2" | ||
| betterproto = {version = "^2.0.0b6", allow-prereleases = true} |
| Target target = 5; | ||
| } | ||
| enum HardwareError { | ||
| NO_ERRORS = 0; |
There was a problem hiding this comment.
Мне почему-то хочется в единственном числе, но дело вкуса...
| optional float pole_angle = 4; // [rad] Current pole angle | ||
| optional float pole_angular_velocity = 5; // [rad/s] Current pole angular velocity | ||
| optional int32 error = 6; // Global error code | ||
| optional int32 hardware_errors = 7; // Hardware error bitmask |
There was a problem hiding this comment.
- А почему все они
optional? Вроде бы в состоянии нет опциональных полей. - МБ тогдак и назвать
hardware_error_bitmaskилиhardware_error_flags?
P.S. Надеюсь, 32 бита хватит на hardware_errors :)
| RESET = 5; | ||
| RESET = 0; | ||
| CONFIG = 1; | ||
| TARGET = 2; |
There was a problem hiding this comment.
Отдельно взять состояние потеряли возможность? Или это делается через пустой TARGET?
| static constexpr float HOMING_SPEED = 0.4; | ||
| static constexpr float HOMING_ACCELERATION = 1.0; | ||
|
|
||
| static const int METERS_TO_STEPS_MULTIPLIER = MICROSTEPS * FULL_STEPS_PER_METER; |
There was a problem hiding this comment.
А почему это не float? Мы не теряем тут точности, неужели там такое кратное попадание?
| } else if (std::abs(state.cart_acceleration) > config.max_cart_acceleration) { | ||
| state.error = Error_CART_ACCELERATION_OVERFLOW; | ||
| } | ||
| if (state.error) stepper.disable(); |
There was a problem hiding this comment.
Так грязновато делать, это словно неявное действие, которое название не отражает :)
| protocol.resetCallback = reset; | ||
| protocol.targetCallback = setTarget; | ||
| protocol.configCallback = setConfig; | ||
| stepper.homingCallback = homingCallback; |
There was a problem hiding this comment.
А в чем смысл все колбэки динамически тут выставлять, а не во время компиляции?
|
|
||
| void homingCallback() { | ||
| if (!stepper.getErrors()) { | ||
| config.max_cart_position = stepper.getFullRange() / 2; |
There was a problem hiding this comment.
Сбиваем то, что задал нам пользователь... сильно :)
| if (target.has_position) { | ||
| stepper.setMaxAccel(accel); | ||
| stepper.setMaxSpeed(velocity); | ||
| stepper.setPosition(target.position); | ||
| } |
There was a problem hiding this comment.
У вас многие штуки построенные на асинхронных тасках, тогда надо заботиться об атомарности всех гетеров/сеттеров и вообще делать все с идеей, что мир асинхронен.
No description provided.