update
This commit is contained in:
@@ -52,12 +52,12 @@ double LiftMagnitude(double v, double floor) {
|
||||
|
||||
} // namespace
|
||||
|
||||
// Dao dau + kep ve [-1, 1]. Ly do dao dau o gamepad.h -- do la cho bug "day
|
||||
// can len thi xe lui" tung nam.
|
||||
// Kep ve [-1, 1], KHONG dao dau. Xem gamepad.h: da thu dao va robot that cho
|
||||
// thay nguoc ca hai truc.
|
||||
//
|
||||
// Kep can that: int16 nho nhat la -32768, dao dau ra 1.00003.
|
||||
// Kep can that: int16 nho nhat la -32768, chia 32767 ra -1.00003.
|
||||
double NormalizeJoydevAxis(int16_t raw) {
|
||||
const double v = -(static_cast<double>(raw) * kAxisScale);
|
||||
const double v = static_cast<double>(raw) * kAxisScale;
|
||||
return std::max(-1.0, std::min(1.0, v));
|
||||
}
|
||||
|
||||
@@ -143,8 +143,9 @@ GamepadCommand GamepadMapper::Step(const GamepadState& s, UnixTime now) {
|
||||
|
||||
// --- Coc LT: giu de dung -------------------------------------------------
|
||||
// Thu ma header base_kit hua nhung code khong co. Mac dinh TAT.
|
||||
// Sau khi dao dau: coc nghi o +1.0, bop ve -1.0. Xem gamepad.h.
|
||||
if (cfg_.lt_stop && s.Axis(cfg_.axis_lt) < cfg_.lt_press_below) {
|
||||
// Do bang probe tren tay cam nay: coc nghi o -1.0, bop len +1.0. Xem
|
||||
// gamepad.h truoc khi doi chieu so sanh nay.
|
||||
if (cfg_.lt_stop && s.Axis(cfg_.axis_lt) > cfg_.lt_press_above) {
|
||||
out.publish = true;
|
||||
out.linear = 0.0;
|
||||
out.angular = 0.0;
|
||||
@@ -179,11 +180,16 @@ GamepadCommand GamepadMapper::Step(const GamepadState& s, UnixTime now) {
|
||||
out.angular_mult = ang_mult;
|
||||
|
||||
// --- Truc ----------------------------------------------------------------
|
||||
const double lin_axis =
|
||||
double lin_axis =
|
||||
PickLarger(s.Axis(cfg_.axis_linear), s.Axis(cfg_.axis_linear_dpad));
|
||||
const double ang_axis =
|
||||
double ang_axis =
|
||||
PickLarger(s.Axis(cfg_.axis_angular), s.Axis(cfg_.axis_angular_dpad));
|
||||
|
||||
// Dao dau o DAY, sau khi da chon giua can gat va D-pad: hai nguon do cung
|
||||
// mot truc logic nen phai chiu cung mot phep dao.
|
||||
if (cfg_.invert_linear) lin_axis = -lin_axis;
|
||||
if (cfg_.invert_angular) ang_axis = -ang_axis;
|
||||
|
||||
double linear = ApplyDeadzone(lin_axis) * cfg_.max_linear_speed * lin_mult;
|
||||
double angular = ApplyDeadzone(ang_axis) * cfg_.max_angular_speed * ang_mult;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user