update
This commit is contained in:
@@ -620,8 +620,8 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
|
|||||||
"turbo_linear", "turbo_angular", "slow_linear", "slow_angular",
|
"turbo_linear", "turbo_angular", "slow_linear", "slow_angular",
|
||||||
"axis_linear", "axis_linear_dpad", "axis_angular",
|
"axis_linear", "axis_linear_dpad", "axis_angular",
|
||||||
"axis_angular_dpad", "button_enable", "button_zero",
|
"axis_angular_dpad", "button_enable", "button_zero",
|
||||||
"button_turbo", "button_slow", "lt_stop", "axis_lt",
|
"button_turbo", "button_slow", "invert_linear",
|
||||||
"lt_press_below"});
|
"invert_angular", "lt_stop", "axis_lt", "lt_press_above"});
|
||||||
if (!r.ok()) return r;
|
if (!r.ok()) return r;
|
||||||
}
|
}
|
||||||
out->gamepad.enabled = gp.get<bool>("enabled", false);
|
out->gamepad.enabled = gp.get<bool>("enabled", false);
|
||||||
@@ -664,8 +664,12 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
|
|||||||
out->gamepad.button_slow = gp.get<int>("button_slow", out->gamepad.button_slow);
|
out->gamepad.button_slow = gp.get<int>("button_slow", out->gamepad.button_slow);
|
||||||
out->gamepad.lt_stop = gp.get<bool>("lt_stop", out->gamepad.lt_stop);
|
out->gamepad.lt_stop = gp.get<bool>("lt_stop", out->gamepad.lt_stop);
|
||||||
out->gamepad.axis_lt = gp.get<int>("axis_lt", out->gamepad.axis_lt);
|
out->gamepad.axis_lt = gp.get<int>("axis_lt", out->gamepad.axis_lt);
|
||||||
out->gamepad.lt_press_below =
|
out->gamepad.invert_linear =
|
||||||
gp.get<double>("lt_press_below", out->gamepad.lt_press_below);
|
gp.get<bool>("invert_linear", out->gamepad.invert_linear);
|
||||||
|
out->gamepad.invert_angular =
|
||||||
|
gp.get<bool>("invert_angular", out->gamepad.invert_angular);
|
||||||
|
out->gamepad.lt_press_above =
|
||||||
|
gp.get<double>("lt_press_above", out->gamepad.lt_press_above);
|
||||||
|
|
||||||
// Kiem CA KHI dang tat: `--gamepad` bat duoc no tu dong lenh, va luc do
|
// Kiem CA KHI dang tat: `--gamepad` bat duoc no tu dong lenh, va luc do
|
||||||
// khong con cho nao de tu choi mot cau hinh sai nua.
|
// khong con cho nao de tu choi mot cau hinh sai nua.
|
||||||
|
|||||||
@@ -137,14 +137,23 @@ gamepad:
|
|||||||
button_turbo: 5 # RB
|
button_turbo: 5 # RB
|
||||||
button_slow: 4 # LB
|
button_slow: 4 # LB
|
||||||
|
|
||||||
|
# Duong thoat khi bo tay cam nguoc chieu. Dau mong doi SAU khi ap hai co
|
||||||
|
# nay: day can len = tien, gat trai = quay trai.
|
||||||
|
#
|
||||||
|
# ⚠️ Chieu truc chi kiem duoc bang cach cam tay cam vao robot that. Da mot
|
||||||
|
# lan suy chieu tu log thay vi do, va ket qua la day can len thi xe lui.
|
||||||
|
# Do bang vslam_joy_probe, dung suy.
|
||||||
|
invert_linear: false
|
||||||
|
invert_angular: false
|
||||||
|
|
||||||
# Header cua base_kit hua "LT: EMERGENCY STOP (hold)" nhung code KHONG he doc
|
# Header cua base_kit hua "LT: EMERGENCY STOP (hold)" nhung code KHONG he doc
|
||||||
# truc do. Cai dat o day, mac dinh TAT dung bang hanh vi that cua base_kit.
|
# truc do. Cai dat o day, mac dinh TAT dung bang hanh vi that cua base_kit.
|
||||||
#
|
#
|
||||||
# ⚠️ CHIEU CUA COC DO TREN CHINH TAY CAM NAY bang vslam_joy_probe:
|
# ⚠️ CHIEU CUA COC DO TREN CHINH TAY CAM NAY bang vslam_joy_probe:
|
||||||
# "Logitech Gamepad F710" doc THO ra -1.000 khi khong cham coc; node dao dau
|
# "Logitech Gamepad F710" -> axes[2] = -1.000 khi KHONG cham coc. Tuc coc
|
||||||
# moi truc (giong joy_node cua ROS) nen o day coc nghi o +1.0, bop ve -1.0.
|
# nghi o -1.0 va bop len +1.0, nen nguong la "> lt_press_above".
|
||||||
#
|
#
|
||||||
# Nguong -0.5 chu khong phai 0.0: truoc mau dau tien truc co the doc ra 0.0,
|
# Nguong 0.5 chu khong phai 0.0: truoc mau dau tien truc co the doc ra 0.0,
|
||||||
# va 0.0 nam ngay sat nguong. Bo tay cam khac co the nghi o chieu nguoc lai
|
# va 0.0 nam ngay sat nguong. Bo tay cam khac co the nghi o chieu nguoc lai
|
||||||
# -- do lai bang probe TRUOC khi bat `lt_stop`, neu khong thi coc dang nghi
|
# -- do lai bang probe TRUOC khi bat `lt_stop`, neu khong thi coc dang nghi
|
||||||
# bi hieu la dang bop va robot dung cung vinh vien.
|
# bi hieu la dang bop va robot dung cung vinh vien.
|
||||||
@@ -154,7 +163,7 @@ gamepad:
|
|||||||
# trinh duyet.
|
# trinh duyet.
|
||||||
lt_stop: false
|
lt_stop: false
|
||||||
axis_lt: 2
|
axis_lt: 2
|
||||||
lt_press_below: -0.5
|
lt_press_above: 0.5
|
||||||
|
|
||||||
# ============ Log ============
|
# ============ Log ============
|
||||||
logging:
|
logging:
|
||||||
|
|||||||
@@ -101,40 +101,55 @@ struct GamepadConfig {
|
|||||||
int button_turbo = 5; // RB
|
int button_turbo = 5; // RB
|
||||||
int button_slow = 4; // LB
|
int button_slow = 4; // LB
|
||||||
|
|
||||||
|
// Duong thoat khi bo tay cam nguoc chieu. Doi mot dong YAML thay vi sua code
|
||||||
|
// roi build lai -- chieu truc chi kiem duoc bang cach cam tay cam vao robot
|
||||||
|
// that, nen vong lap sua-thu phai re.
|
||||||
|
//
|
||||||
|
// Dau mong doi SAU khi ap hai co nay: day can len = duong = tien,
|
||||||
|
// gat trai = duong = quay trai (REP-103).
|
||||||
|
bool invert_linear = false;
|
||||||
|
bool invert_angular = false;
|
||||||
|
|
||||||
// Header cua base_kit hua "LT (axis 2): Emergency stop - HOLD to stop"
|
// Header cua base_kit hua "LT (axis 2): Emergency stop - HOLD to stop"
|
||||||
// nhung code KHONG he doc truc do. Cai dat o day, va de TAT mac dinh dung
|
// nhung code KHONG he doc truc do. Cai dat o day, va de TAT mac dinh dung
|
||||||
// bang hanh vi that cua base_kit.
|
// bang hanh vi that cua base_kit.
|
||||||
//
|
//
|
||||||
// ⚠️ CHIEU CUA COC DO DUOC TREN CHINH TAY CAM NAY, khong phai doan.
|
// ⚠️ CHIEU CUA COC DO DUOC TREN CHINH TAY CAM NAY, khong phai doan.
|
||||||
//
|
//
|
||||||
// `vslam_joy_probe` voi "Logitech Gamepad F710" tren may nay doc THO:
|
// `vslam_joy_probe` voi "Logitech Gamepad F710" tren may nay:
|
||||||
// axes[2] = -1.000 va axes[5] = -1.000 suot ca phien, khong cham coc
|
// axes[2] = -1.000 va axes[5] = -1.000 suot ca phien, khong cham coc
|
||||||
// Reader dao dau (xem NormalizeAxis trong gamepad.cc), nen o day coc NGHI o
|
// Reader khong dao dau, nen mapper thay dung con so do: coc NGHI o -1.0 va
|
||||||
// +1.0 va bop ve -1.0.
|
// bop len +1.0. Vi vay nguong la "> lt_press_above" = 0.5.
|
||||||
//
|
//
|
||||||
// Nguong la "< lt_press_below" = -0.5. Khong lay 0.0: truoc mau dau tien
|
// Lay nguong am (vd "< 0") thi coc DANG NGHI thoa dieu kien va robot dung
|
||||||
// driver co the tra 0.0, va 0.0 < 0.0 la sai nhung 0.0 rat gan nguong --
|
// cung vinh vien, khong co dau hieu gi de doan ra.
|
||||||
// -0.5 tach han hai trang thai ra.
|
|
||||||
//
|
//
|
||||||
// Bo tay cam khac co the nghi o chieu nguoc lai. Do bang probe TRUOC khi bat
|
// 0.5 con an toan cho truong hop driver chua gui mau dau tien va truc doc ra
|
||||||
// `lt_stop`, neu khong thi coc dang nghi bi hieu la dang bop va robot dung
|
// 0.0: 0.0 khong vuot 0.5.
|
||||||
// cung vinh vien.
|
//
|
||||||
|
// Bo tay cam khac co the nghi o chieu nguoc lai. DO LAI BANG PROBE truoc khi
|
||||||
|
// bat `lt_stop`.
|
||||||
//
|
//
|
||||||
// KHONG chot e-stop cua he thong: go e-stop bat buoc co token (xem
|
// KHONG chot e-stop cua he thong: go e-stop bat buoc co token (xem
|
||||||
// system.yaml web), nen mot cu va nham vao coc se khoa robot lai cho toi khi
|
// system.yaml web), nen mot cu va nham vao coc se khoa robot lai cho toi khi
|
||||||
// co nguoi mo trinh duyet. Day chi la "giu de dung", dung nhu header hua.
|
// co nguoi mo trinh duyet. Day chi la "giu de dung", dung nhu header hua.
|
||||||
bool lt_stop = false;
|
bool lt_stop = false;
|
||||||
int axis_lt = 2;
|
int axis_lt = 2;
|
||||||
double lt_press_below = -0.5;
|
double lt_press_above = 0.5;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Doi mot gia tri truc THO cua joydev sang quy uoc ma config nay dung.
|
// Doi mot gia tri truc THO cua joydev sang [-1, 1]. KHONG dao dau.
|
||||||
//
|
//
|
||||||
// ⚠️ DAO DAU. joydev tho quy uoc LEN va TRAI la AM; `joy_node` cua ROS dao
|
// ⚠️ DA THU DAO DAU, VA DO LA SAI. Lap luan luc do: joydev quy uoc LEN/TRAI la
|
||||||
// dau truoc khi publish, va moi index/dau trong `system.yaml gamepad` deu chep
|
// am, con `joy_node` cua ROS dao dau truoc khi publish, nen ban port phai dao
|
||||||
// tu base_kit von doc dau ra cua joy_node. Bo phep dao nay di thi day can gat
|
// theo. Nhung DO TREN ROBOT THAT (Logitech F710 qua xpad): ban co dao dau lam
|
||||||
// len se ra lenh LUI -- da xay ra that tren robot, log ghi `gamepad: v=-0.5
|
// day can len thi xe LUI va gat trai thi xe re PHAI -- nguoc ca hai truc.
|
||||||
// m/s` trong khi nguoi lai dang day can len.
|
// Gia tri tho da dung chieu san.
|
||||||
|
//
|
||||||
|
// Lan truoc ket luan nham vi suy tu mot dong log sim (`v=-0.5` luc nguoi lai
|
||||||
|
// dang quet can hai chieu) chu khong phai tu phep do. Bo tay cam khac co the
|
||||||
|
// khac chieu that -- khi do dung `invert_linear` / `invert_angular` trong
|
||||||
|
// `system.yaml`, DUNG sua ham nay.
|
||||||
//
|
//
|
||||||
// De o header CHI de test khoa duoc quy uoc nay. `vslam_joy_probe` nhan ban
|
// De o header CHI de test khoa duoc quy uoc nay. `vslam_joy_probe` nhan ban
|
||||||
// lai phep tinh nay thay vi goi vao day: no co y khong phu thuoc lib nao.
|
// lai phep tinh nay thay vi goi vao day: no co y khong phu thuoc lib nao.
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ double LiftMagnitude(double v, double floor) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Dao dau + kep ve [-1, 1]. Ly do dao dau o gamepad.h -- do la cho bug "day
|
// Kep ve [-1, 1], KHONG dao dau. Xem gamepad.h: da thu dao va robot that cho
|
||||||
// can len thi xe lui" tung nam.
|
// 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) {
|
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));
|
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 -------------------------------------------------
|
// --- Coc LT: giu de dung -------------------------------------------------
|
||||||
// Thu ma header base_kit hua nhung code khong co. Mac dinh TAT.
|
// 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.
|
// Do bang probe tren tay cam nay: coc nghi o -1.0, bop len +1.0. Xem
|
||||||
if (cfg_.lt_stop && s.Axis(cfg_.axis_lt) < cfg_.lt_press_below) {
|
// 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.publish = true;
|
||||||
out.linear = 0.0;
|
out.linear = 0.0;
|
||||||
out.angular = 0.0;
|
out.angular = 0.0;
|
||||||
@@ -179,11 +180,16 @@ GamepadCommand GamepadMapper::Step(const GamepadState& s, UnixTime now) {
|
|||||||
out.angular_mult = ang_mult;
|
out.angular_mult = ang_mult;
|
||||||
|
|
||||||
// --- Truc ----------------------------------------------------------------
|
// --- Truc ----------------------------------------------------------------
|
||||||
const double lin_axis =
|
double lin_axis =
|
||||||
PickLarger(s.Axis(cfg_.axis_linear), s.Axis(cfg_.axis_linear_dpad));
|
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));
|
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 linear = ApplyDeadzone(lin_axis) * cfg_.max_linear_speed * lin_mult;
|
||||||
double angular = ApplyDeadzone(ang_axis) * cfg_.max_angular_speed * ang_mult;
|
double angular = ApplyDeadzone(ang_axis) * cfg_.max_angular_speed * ang_mult;
|
||||||
|
|
||||||
|
|||||||
@@ -47,36 +47,44 @@ void PressEnable(GamepadMapper* m, GamepadState* s, const GamepadConfig& c,
|
|||||||
|
|
||||||
// --- Quy uoc dau cua truc --------------------------------------------------
|
// --- Quy uoc dau cua truc --------------------------------------------------
|
||||||
|
|
||||||
TEST(Gamepad, DaoDauTrucGiongJoyNode) {
|
TEST(Gamepad, KhongDaoDauTruc) {
|
||||||
// ⚠️ BAI TEST NAY KHOA MOT BUG DA XAY RA TREN ROBOT.
|
// ⚠️ BAI TEST NAY KHOA MOT BUG DA XAY RA TREN ROBOT THAT.
|
||||||
//
|
//
|
||||||
// joydev tho quy uoc LEN va TRAI la AM. Ban dau reader khong dao dau, va
|
// Da co mot ban them phep dao dau vao day, voi lap luan "joydev quy uoc
|
||||||
// log robot ghi `gamepad: v=-0.5 m/s` trong khi nguoi lai dang day can gat
|
// len/trai la am, joy_node cua ROS dao dau nen ban port phai dao theo". Lap
|
||||||
// LEN -- xe lui het co vao tuong. Moi index/dau trong system.yaml deu chep
|
// luan do suy tu mot dong log sim chu khong tu phep do, va robot that bac
|
||||||
// tu base_kit, ma base_kit doc dau ra cua joy_node (da dao dau).
|
// bo: ban co dao dau lam day can len thi xe LUI, gat trai thi xe re PHAI.
|
||||||
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(-32767), 1.0); // day len -> tien
|
//
|
||||||
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(32767), -1.0); // keo xuong -> lui
|
// Bo tay cam khac co the khac chieu -- khi do dung invert_linear /
|
||||||
|
// invert_angular, DUNG sua ham nay.
|
||||||
|
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(32767), 1.0);
|
||||||
|
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(-32767), -1.0);
|
||||||
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(0), 0.0);
|
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(0), 0.0);
|
||||||
|
|
||||||
// int16 nho nhat dao dau ra 1.00003 -- phai kep, khong duoc de lot [-1, 1].
|
// int16 nho nhat ra -1.00003 -- phai kep, khong duoc lot khoi [-1, 1].
|
||||||
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(-32768), 1.0);
|
EXPECT_DOUBLE_EQ(NormalizeJoydevAxis(-32768), -1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Gamepad, DayCanLenLaTien) {
|
TEST(Gamepad, CoDaoDauThiDoiChieuCaCanGatLanDpad) {
|
||||||
// Noi hai tang lai: gia tri THO tu joydev -> mapper -> van toc.
|
GamepadConfig c = MakeCfg();
|
||||||
const GamepadConfig c = MakeCfg();
|
c.invert_linear = true;
|
||||||
|
c.invert_angular = true;
|
||||||
GamepadMapper m(c);
|
GamepadMapper m(c);
|
||||||
GamepadState s = MakePad();
|
GamepadState s = MakePad();
|
||||||
PressEnable(&m, &s, c, 1.0);
|
PressEnable(&m, &s, c, 1.0);
|
||||||
|
|
||||||
// -32767 tho = day can gat len het.
|
s.axes[c.axis_linear] = 1.0f;
|
||||||
s.axes[c.axis_linear] = static_cast<float>(NormalizeJoydevAxis(-32767));
|
s.axes[c.axis_angular] = 1.0f;
|
||||||
EXPECT_GT(m.Step(s, T(2.0)).linear, 0.0);
|
const GamepadCommand out = m.Step(s, T(2.0));
|
||||||
|
EXPECT_DOUBLE_EQ(out.linear, -c.max_linear_speed);
|
||||||
|
EXPECT_DOUBLE_EQ(out.angular, -c.max_angular_speed);
|
||||||
|
|
||||||
// Gat can phai sang TRAI (tho am) = quay trai = duong, theo REP-103.
|
// D-pad di chung mot truc logic nen phai chiu cung phep dao -- neu khong
|
||||||
|
// thi can gat va D-pad lai nguoc chieu nhau.
|
||||||
s.axes[c.axis_linear] = 0.0f;
|
s.axes[c.axis_linear] = 0.0f;
|
||||||
s.axes[c.axis_angular] = static_cast<float>(NormalizeJoydevAxis(-32767));
|
s.axes[c.axis_angular] = 0.0f;
|
||||||
EXPECT_GT(m.Step(s, T(2.1)).angular, 0.0);
|
s.axes[c.axis_linear_dpad] = 1.0f;
|
||||||
|
EXPECT_LT(m.Step(s, T(2.1)).linear, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Bat / tat dieu khien --------------------------------------------------
|
// --- Bat / tat dieu khien --------------------------------------------------
|
||||||
@@ -338,23 +346,23 @@ TEST(Gamepad, CocLtChiAnKhiBatVaKhongAnLucChuaChamToi) {
|
|||||||
GamepadState s = MakePad();
|
GamepadState s = MakePad();
|
||||||
PressEnable(&m, &s, c, 1.0);
|
PressEnable(&m, &s, c, 1.0);
|
||||||
|
|
||||||
// Probe doc THO thay coc nghi o -1.0; reader dao dau nen mapper thay +1.0.
|
// Do bang probe tren tay cam that: coc NGHI o -1.0.
|
||||||
s.axes[c.axis_lt] = 1.0f;
|
s.axes[c.axis_lt] = -1.0f;
|
||||||
s.axes[c.axis_linear] = 1.0f;
|
s.axes[c.axis_linear] = 1.0f;
|
||||||
EXPECT_DOUBLE_EQ(m.Step(s, T(2.0)).linear, c.max_linear_speed);
|
EXPECT_DOUBLE_EQ(m.Step(s, T(2.0)).linear, c.max_linear_speed);
|
||||||
|
|
||||||
// Truoc mau dau tien, truc co the doc ra 0.0. Van phai la "khong bop" --
|
// Truoc mau dau tien, truc co the doc ra 0.0. Van phai la "khong bop" --
|
||||||
// day la ly do nguong la -0.5 chu khong phai 0.0.
|
// day la ly do nguong la 0.5 chu khong phai 0.0.
|
||||||
s.axes[c.axis_lt] = 0.0f;
|
s.axes[c.axis_lt] = 0.0f;
|
||||||
EXPECT_DOUBLE_EQ(m.Step(s, T(2.1)).linear, c.max_linear_speed);
|
EXPECT_DOUBLE_EQ(m.Step(s, T(2.1)).linear, c.max_linear_speed);
|
||||||
|
|
||||||
// Bop coc -> ve am -> dung, du can gat van day het.
|
// Bop coc -> len duong -> dung, du can gat van day het.
|
||||||
s.axes[c.axis_lt] = -1.0f;
|
s.axes[c.axis_lt] = 1.0f;
|
||||||
const GamepadCommand stopped = m.Step(s, T(2.2));
|
const GamepadCommand stopped = m.Step(s, T(2.2));
|
||||||
EXPECT_TRUE(stopped.publish);
|
EXPECT_TRUE(stopped.publish);
|
||||||
EXPECT_DOUBLE_EQ(stopped.linear, 0.0);
|
EXPECT_DOUBLE_EQ(stopped.linear, 0.0);
|
||||||
|
|
||||||
// Nha coc -> chay lai ngay. "Giu de dung", khong chot.
|
// Nha coc -> chay lai ngay. "Giu de dung", khong chot.
|
||||||
s.axes[c.axis_lt] = 1.0f;
|
s.axes[c.axis_lt] = -1.0f;
|
||||||
EXPECT_DOUBLE_EQ(m.Step(s, T(2.3)).linear, c.max_linear_speed);
|
EXPECT_DOUBLE_EQ(m.Step(s, T(2.3)).linear, c.max_linear_speed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,16 +39,13 @@ namespace {
|
|||||||
|
|
||||||
constexpr double kAxisScale = 1.0 / 32767.0;
|
constexpr double kAxisScale = 1.0 / 32767.0;
|
||||||
|
|
||||||
// ⚠️ DAO DAU, GIONG HET GamepadReader.
|
// KHONG dao dau -- giong het GamepadReader::NormalizeJoydevAxis.
|
||||||
//
|
//
|
||||||
// joydev tho quy uoc LEN va TRAI la AM; `joy_node` cua ROS dao dau, va moi
|
// Cong cu nay PHAI in cung quy uoc voi node. Neu mot ben dao dau con ben kia
|
||||||
// gia tri trong `system.yaml gamepad` deu theo quy uoc da dao do.
|
// khong, nguoi do se doc dau o day roi dat config nguoc lai, va phat hien ra
|
||||||
//
|
// bang cach thay robot lui khi day can gat len. Da xay ra that.
|
||||||
// Cong cu nay PHAI in cung quy uoc voi node. In so tho thi nguoi do se doc
|
|
||||||
// dau o day roi dat config nguoc lai -- va phat hien ra bang cach thay robot
|
|
||||||
// lui khi day can gat len.
|
|
||||||
double NormalizeAxis(int16_t raw) {
|
double NormalizeAxis(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));
|
return std::max(-1.0, std::min(1.0, v));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,8 +102,9 @@ int main(int argc, char** argv) {
|
|||||||
std::printf("thiet bi : %s\n", dev.c_str());
|
std::printf("thiet bi : %s\n", dev.c_str());
|
||||||
std::printf("ten : %s\n", name);
|
std::printf("ten : %s\n", name);
|
||||||
std::printf("layout : %u truc, %u nut\n", n_axes, n_buttons);
|
std::printf("layout : %u truc, %u nut\n", n_axes, n_buttons);
|
||||||
std::printf("\ntruc in theo DUNG quy uoc node dung (day len / gat trai ="
|
std::printf("\ntruc in DUNG con so ma node nhan duoc (khong dao dau).\n");
|
||||||
" duong).\n");
|
std::printf("Day can len ma ra AM -> dat invert_linear: true trong"
|
||||||
|
" system.yaml.\n");
|
||||||
std::printf("gat can va bam nut; Ctrl-C de thoat.\n");
|
std::printf("gat can va bam nut; Ctrl-C de thoat.\n");
|
||||||
|
|
||||||
std::vector<double> axes(n_axes, 0.0);
|
std::vector<double> axes(n_axes, 0.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user