-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Protocol refactor #46
base: cart-pole-3
Are you sure you want to change the base?
Conversation
Перед мерджем не забудьте пересобрать контейнер. |
|
betterproto = {version = "^2.0.0b6", allow-prereleases = true} | ||
crc = "^4.3.0" | ||
cobs = "^1.2.0" | ||
jsonref = "^1.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем?
@@ -40,6 +36,10 @@ torch = [ | |||
{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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не боимся юзать бету?
Target target = 5; | ||
} | ||
enum HardwareError { | ||
NO_ERRORS = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне почему-то хочется в единственном числе, но дело вкуса...
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- А почему все они
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Отдельно взять состояние потеряли возможность? Или это делается через пустой 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему это не 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так грязновато делать, это словно неявное действие, которое название не отражает :)
protocol.resetCallback = reset; | ||
protocol.targetCallback = setTarget; | ||
protocol.configCallback = setConfig; | ||
stepper.homingCallback = homingCallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А в чем смысл все колбэки динамически тут выставлять, а не во время компиляции?
|
||
void homingCallback() { | ||
if (!stepper.getErrors()) { | ||
config.max_cart_position = stepper.getFullRange() / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сбиваем то, что задал нам пользователь... сильно :)
if (target.has_position) { | ||
stepper.setMaxAccel(accel); | ||
stepper.setMaxSpeed(velocity); | ||
stepper.setPosition(target.position); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У вас многие штуки построенные на асинхронных тасках, тогда надо заботиться об атомарности всех гетеров/сеттеров и вообще делать все с идеей, что мир асинхронен.
No description provided.