|
15 | 15 | */ |
16 | 16 | #pragma once |
17 | 17 |
|
18 | | -// ============ Controller Selection ============ |
19 | | -// Set ONE of these as the active controller: |
20 | | -#define CONTROLLER_PRO_CONTROLLER 1 |
21 | | -#define CONTROLLER_CYBORG_STICK 2 |
22 | | - |
23 | | -#define ACTIVE_CONTROLLER CONTROLLER_PRO_CONTROLLER |
24 | | - |
25 | 18 | #include <sensor_msgs/msg/joy.hpp> |
26 | 19 | #include <arm_hardware_interface/ArmSerialProtocol.h> |
27 | 20 | inline static constexpr int MAX_BUTTONS = 20; // can be decreased |
@@ -277,172 +270,6 @@ namespace ArmControllerConfig { // Can make into a class later? |
277 | 270 | // } |
278 | 271 | } |
279 | 272 |
|
280 | | - |
281 | | - |
282 | | - |
283 | | -// Button names (used): |
284 | | -// 0 = BTN_EAST 1 = BTN_SOUTH |
285 | | -// 2 = BTN_NORTH 3 = BTN_WEST |
286 | | -// 12 = up |
287 | | -// 13 = down |
288 | | -// 14 = left |
289 | | -// 15 = right |
290 | | -// |
291 | | -// Axes: |
292 | | -// 0 = Left stick X 1 = Left stick Y |
293 | | -// 2 = Right stick X 3 = Right stick Y |
294 | | -// 4 = ZL analog (rests at 1.0) |
295 | | -// 5 = ZR analog (rests at 1.0) |
296 | | -// |
297 | | -// NOTE: If your button indices differ, adjust the values below |
298 | | -// and rebuild. Verify with: ros2 topic echo /joy |
299 | | -// ============================================================ |
300 | | - |
301 | | -#if ACTIVE_CONTROLLER == CONTROLLER_PRO_CONTROLLER |
302 | | - |
303 | | -namespace ControllerConfig { |
304 | | - |
305 | | - // --- Face Buttons --- |
306 | | - constexpr int BTN_B = 0; // East (A) |
307 | | - constexpr int BTN_A = 1; // South (B) |
308 | | - constexpr int BTN_Y = 2; // North (X) |
309 | | - constexpr int BTN_X = 3; // West (Y) |
310 | | - |
311 | | - constexpr int BTN_HOME = 5; // Home |
312 | | - |
313 | | - constexpr int BTN_UP = 12; // Left shoulder |
314 | | - constexpr int BTN_DOWN = 13; // Right shoulder |
315 | | - |
316 | | - // --- Axes --- |
317 | | - constexpr int AXIS_LEFT_X = 0; |
318 | | - constexpr int AXIS_LEFT_Y = 1; |
319 | | - constexpr int AXIS_RIGHT_X = 2; |
320 | | - constexpr int AXIS_RIGHT_Y = 3; |
321 | | - // axes[4], axes[5] = ZL/ZR triggers (rest at 1.0, pressed = -1.0) — avoid for motion |
322 | | - |
323 | | - // --- Cartesian Button Mapping (6 buttons → 6 translation directions) --- |
324 | | - // Face buttons control X/Y plane, shoulders control Z |
325 | | - // |
326 | | - // Y (+X forward) |
327 | | - // X (+Y) B (-Y) |
328 | | - // A (-X backward) |
329 | | - // |
330 | | - // R shoulder → +Z (up) |
331 | | - // L shoulder → -Z (down) |
332 | | - constexpr int BTN_CART_POS_X = BTN_Y; // North face → +X (forward) |
333 | | - constexpr int BTN_CART_NEG_X = BTN_A; // South face → -X (backward) |
334 | | - constexpr int BTN_CART_POS_Y = BTN_X; // West face → +Y (left) |
335 | | - constexpr int BTN_CART_NEG_Y = BTN_B; // East face → -Y (right) |
336 | | - constexpr int BTN_CART_POS_Z = BTN_UP; // R shoulder → +Z (up) |
337 | | - constexpr int BTN_CART_NEG_Z = BTN_DOWN; // L shoulder → -Z (down) |
338 | | - |
339 | | - // --- Twist Speed --- |
340 | | - // command_in_type is "unitless" (-1 to 1), scaled by servo's linear/rotational params |
341 | | - // 1.0 → full speed (0.5 m/s per servo config) |
342 | | - constexpr double CART_BUTTON_SPEED = 0.5; // unitless, range [0.0, 1.0] |
343 | | - constexpr double ROT_STICK_SPEED = 0.6; // unitless, range [0.0, 1.0] for angular |
344 | | - constexpr double AXIS_DEADZONE = 0.15; |
345 | | - |
346 | | - // --- Frame for Cartesian twist commands --- |
347 | | - // "base_link" = world-fixed directions (forward is always forward) |
348 | | - // "ee_base_link" = relative to end-effector orientation |
349 | | - constexpr const char* CART_FRAME_ID = "base_link"; |
350 | | - |
351 | | - // --- EE Orientation Stick Mapping --- |
352 | | - // Left stick → pitch (tilt forward/back) and yaw (rotate left/right) |
353 | | - // Right stick → roll (tilt sideways) |
354 | | - // |
355 | | - // Servo angular.x = roll, angular.y = pitch, angular.z = yaw |
356 | | - constexpr int AXIS_ROLL = AXIS_RIGHT_X; // right stick X → roll |
357 | | - constexpr int AXIS_PITCH = AXIS_LEFT_Y; // left stick Y → pitch |
358 | | - constexpr int AXIS_YAW = AXIS_LEFT_X; // left stick X → yaw |
359 | | - constexpr bool INVERT_ROLL = false; |
360 | | - constexpr bool INVERT_PITCH = false; |
361 | | - constexpr bool INVERT_YAW = true; // typical: push left = positive yaw |
362 | | - |
363 | | - // --- Gripper --- |
364 | | - constexpr int BTN_GRIPPER_TOGGLE = 7; // ZR button — edge-triggered toggle |
365 | | - constexpr int AXIS_GRIPPER_TOGGLE = 5; // ZR analog axis (rests at 1.0, pressed = -1.0) |
366 | | - constexpr double AXIS_GRIPPER_PRESSED_THRESHOLD = 0.0; // trigger considered pressed below this |
367 | | - constexpr double GRIPPER_OPEN_VALUE = 1.0; |
368 | | - constexpr double GRIPPER_CLOSE_VALUE = 0.0; |
369 | | - |
370 | | - // --- Gripper Sim Positions --- |
371 | | - constexpr double GRIPPER_SIM_LEFT_OPEN_POS = 0.04; |
372 | | - constexpr double GRIPPER_SIM_RIGHT_OPEN_POS = -0.04; |
373 | | - constexpr double GRIPPER_SIM_LEFT_CLOSE_POS = 0.0; |
374 | | - constexpr double GRIPPER_SIM_RIGHT_CLOSE_POS = 0.0; |
375 | | -} |
376 | | - |
377 | | -#elif ACTIVE_CONTROLLER == CONTROLLER_CYBORG_STICK |
378 | | - |
379 | | -// ============================================================ |
380 | | -// Saitek Cyborg USB Stick |
381 | | -// ============================================================ |
382 | | -// Axes: |
383 | | -// 0 = Stick X (left/right) |
384 | | -// 1 = Stick Y (forward/back) |
385 | | -// 2 = Throttle slider (rests non-zero — DO NOT USE for motion) |
386 | | -// 3 = Stick twist/rudder (rotation) |
387 | | -// 4 = Hat X |
388 | | -// 5 = Hat Y |
389 | | -// |
390 | | -// Buttons: |
391 | | -// 0 = Trigger |
392 | | -// ============================================================ |
393 | | - |
394 | | -namespace ControllerConfig { |
395 | | - |
396 | | - // --- Axes --- |
397 | | - constexpr int AXIS_STICK_X = 0; |
398 | | - constexpr int AXIS_STICK_Y = 1; |
399 | | - constexpr int AXIS_THROTTLE = 2; // rests non-zero — skip |
400 | | - constexpr int AXIS_TWIST = 3; // rudder/twist |
401 | | - constexpr int AXIS_HAT_X = 4; |
402 | | - constexpr int AXIS_HAT_Y = 5; |
403 | | - |
404 | | - // --- Buttons --- |
405 | | - constexpr int BTN_TRIGGER = 0; |
406 | | - |
407 | | - // --- Cartesian Button Mapping --- |
408 | | - // Cyborg stick has no natural button-based Cartesian; set to -1 (disabled) |
409 | | - constexpr int BTN_CART_POS_X = -1; |
410 | | - constexpr int BTN_CART_NEG_X = -1; |
411 | | - constexpr int BTN_CART_POS_Y = -1; |
412 | | - constexpr int BTN_CART_NEG_Y = -1; |
413 | | - constexpr int BTN_CART_POS_Z = -1; |
414 | | - constexpr int BTN_CART_NEG_Z = -1; |
415 | | - |
416 | | - constexpr double CART_BUTTON_SPEED = 0.3; |
417 | | - constexpr double AXIS_DEADZONE = 0.15; |
418 | | - constexpr const char* CART_FRAME_ID = "base_link"; |
419 | | - |
420 | | - // --- Gripper --- |
421 | | - constexpr int BTN_GRIPPER_TOGGLE = BTN_TRIGGER; // trigger = gripper toggle |
422 | | - constexpr int AXIS_GRIPPER_TOGGLE = -1; // no analog trigger axis |
423 | | - constexpr double AXIS_GRIPPER_PRESSED_THRESHOLD = 0.0; |
424 | | - constexpr double GRIPPER_OPEN_VALUE = 1.0; |
425 | | - constexpr double GRIPPER_CLOSE_VALUE = 0.0; |
426 | | - |
427 | | - // --- Gripper Sim Positions --- |
428 | | - constexpr double GRIPPER_SIM_LEFT_OPEN_POS = 0.04; |
429 | | - constexpr double GRIPPER_SIM_RIGHT_OPEN_POS = -0.04; |
430 | | - constexpr double GRIPPER_SIM_LEFT_CLOSE_POS = 0.0; |
431 | | - constexpr double GRIPPER_SIM_RIGHT_CLOSE_POS = 0.0; |
432 | | - |
433 | | - // --- Orientation --- |
434 | | - constexpr double ROT_STICK_SPEED = 0.4; |
435 | | - constexpr int AXIS_ROLL = AXIS_STICK_X; // stick X → roll |
436 | | - constexpr int AXIS_PITCH = AXIS_STICK_Y; // stick Y → pitch |
437 | | - constexpr int AXIS_YAW = AXIS_TWIST; // twist → yaw |
438 | | - constexpr bool INVERT_ROLL = false; |
439 | | - constexpr bool INVERT_PITCH = false; |
440 | | - constexpr bool INVERT_YAW = false; |
441 | | - |
442 | | - // --- Misc --- |
443 | | - constexpr int BTN_HOME = -1; // no home button on Cyborg stick |
444 | | -} |
445 | | - |
446 | 273 | #else |
447 | 274 | #pragma warning "Warning: No valid ACTIVE_CONTROLLER defined in controller_config.h" |
448 | 275 | #endif |
0 commit comments