Skip to content
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

Joystick does not move Go2 #47

Open
tamutamuto opened this issue Mar 2, 2025 · 0 comments
Open

Joystick does not move Go2 #47

tamutamuto opened this issue Mar 2, 2025 · 0 comments

Comments

@tamutamuto
Copy link

Overview

I read the README as saying that setting USE_JOYSTICK = 1 allows controlling Go2 with a joystick.
However, in reality, the joystick input was not reflected in the movement of the robot..

To confirm this issue, I added a debug print() statement in unitree_sdk2py_bridge.py and verified that joystick input is correctly being received.

Actual Behavior

🔹 Steps to Reproduce

  1. Set USE_JOYSTICK = 1 in simulate_python/config.py
  2. Run python3 unitree_mujoco.py
  3. Operate the joystick
  4. Add a debug print() statement in PublishWirelessController() in unitree_sdk2py_bridge.py
  5. Confirm that joystick input is received but the robot does not move at all

Added Debug Code**

I added the following debug print() statement in PublishWirelessController() in unitree_sdk2py_bridge.py:

def PublishWirelessController(self):
    if self.joystick is not None:
        pygame.event.get()
        
        key_state = [0] * 16
        key_state[self.key_map["R1"]] = self.joystick.get_button(self.button_id["RB"])
        key_state[self.key_map["L1"]] = self.joystick.get_button(self.button_id["LB"])
        key_state[self.key_map["start"]] = self.joystick.get_button(self.button_id["START"])
        key_state[self.key_map["select"]] = self.joystick.get_button(self.button_id["SELECT"])
        key_state[self.key_map["R2"]] = (self.joystick.get_axis(self.axis_id["RT"]) > 0)
        key_state[self.key_map["L2"]] = (self.joystick.get_axis(self.axis_id["LT"]) > 0)
        key_state[self.key_map["F1"]] = 0
        key_state[self.key_map["F2"]] = 0
        key_state[self.key_map["A"]] = self.joystick.get_button(self.button_id["A"])
        key_state[self.key_map["B"]] = self.joystick.get_button(self.button_id["B"])
        key_state[self.key_map["X"]] = self.joystick.get_button(self.button_id["X"])
        key_state[self.key_map["Y"]] = self.joystick.get_button(self.button_id["Y"])
        key_state[self.key_map["up"]] = self.joystick.get_hat(0)[1] > 0
        key_state[self.key_map["right"]] = self.joystick.get_hat(0)[0] > 0
        key_state[self.key_map["down"]] = self.joystick.get_hat(0)[1] < 0
        key_state[self.key_map["left"]] = self.joystick.get_hat(0)[0] < 0

        key_value = 0
        for i in range(16):
            key_value += key_state[i] << i

        self.wireless_controller.keys = key_value
        self.wireless_controller.lx = self.joystick.get_axis(self.axis_id["LX"])
        self.wireless_controller.ly = -self.joystick.get_axis(self.axis_id["LY"])
        self.wireless_controller.rx = self.joystick.get_axis(self.axis_id["RX"])
        self.wireless_controller.ry = -self.joystick.get_axis(self.axis_id["RY"])

        # Output joystick state here
        print(f"Joystick State:")
        print(f"  LX: {self.wireless_controller.lx:.2f}, LY: {self.wireless_controller.ly:.2f}")
        print(f"  RX: {self.wireless_controller.rx:.2f}, RY: {self.wireless_controller.ry:.2f}")
        print(f"  Keys: {bin(self.wireless_controller.keys)}")

        self.wireless_controller_puber.Write(self.wireless_controller)

Actual Output (When Moving Joystick)

After running this code, I confirmed that joystick input is correctly received when I moved the joystick, as shown below:

Joystick State:
  LX: 0.00, LY: 1.00
  RX: 0.00, RY: 0.00
  Keys: 0b0
Joystick State:
  LX: 0.00, LY: 1.00
  RX: 0.00, RY: 0.00
  Keys: 0b0
Joystick State:
  LX: 0.00, LY: 1.00
  RX: 0.00, RY: 0.00
  Keys: 0b0
Joystick State:
  LX: 0.00, LY: 1.00
  RX: 0.00, RY: 0.00
  Keys: 0b0
Joystick State:
  LX: 0.00, LY: 1.00
  RX: 0.00, RY: 0.00
  Keys: 0b0
Joystick State:
  LX: 0.00, LY: 1.00
  RX: 0.00, RY: 0.00
  Keys: 0b0

Despite receiving joystick input, the robot does not move.

Issue

PublishWirelessController() only sends data to rt/wireless_controller and does not affect the LowCmd controlling the robot.
I think the README misleads users into thinking that enabling the joystick allows direct control of the robot.
I also couldn't find any reports of anyone successfully moving Go2 using the joystick.

Request

The README is misleading and should be corrected to clarify that enabling USE_JOYSTICK = 1 does not allow direct control of the robot.
If joystick support for robot movement is planned, it would be helpful to update the documentation accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant