Skip to content

Instantly share code, notes, and snippets.

@cole-wilson
Created January 17, 2026 07:23
Show Gist options
  • Select an option

  • Save cole-wilson/76ba03b62dcff141855664d559e7d473 to your computer and use it in GitHub Desktop.

Select an option

Save cole-wilson/76ba03b62dcff141855664d559e7d473 to your computer and use it in GitHub Desktop.
def logitech_twist(controller_state):
twist = Twist()
twist.linear.x = controller_state["axes"][4] # right stick vertical
twist.linear.y = controller_state["axes"][3] # right stick horizontal
twist.linear.z = -controller_state["axes"][1] # left stick vertical
twist.angular.y = float(controller_state["dpad"][1]) # pitch
twist.angular.x = -float(controller_state["dpad"][0]) # roll
yaw_r = controller_state["axes"][5] # right trigger
yaw_l = controller_state["axes"][2] # left trigger
yaw_r = (yaw_r + 1) / 2
yaw_l = (yaw_l + 1) / 2 * (-1)
twist.angular.z = -(yaw_r + yaw_l)
return twist
def series_x_twist(controller_state):
twist = Twist()
twist.linear.x = controller_state["axes"][4] # right stick vertical
twist.linear.y = controller_state["axes"][3] # right stick horizontal
twist.linear.z = -controller_state["axes"][1] # left stick
twist.angular.y = float(controller_state["dpad"][1]) # pitch
twist.angular.x = -float(controller_state["dpad"][0]) # roll
yaw_r = controller_state["axes"][5] # right trigger
yaw_l = controller_state["axes"][2] # left trigger
yaw_r = (yaw_r + 1) / 2
yaw_l = (yaw_l + 1) / 2 * (-1)
twist.angular.z = -(yaw_r + yaw_l)
return twist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment