<filename>src/publish_joystick.py
#!/usr/bin/env python
from detect_joystick import Joystick, JoystickInput
from sensor_msgs.msg import Joy
import rospy


def joystick_publisher(hz: int = 10, wired: bool = False):
    jinput_pub: rospy.Publisher = rospy.Publisher('joystick_input', Joy, queue_size=10)
    rospy.init_node('joystick_input_pub')
    rate: rospy.Rate = rospy.Rate(hz)
    js: Joystick = Joystick(wired=wired)
    while not rospy.is_shutdown():
        jinput: JoystickInput = js.get_input()
        rospy.logdebug("Joystick Input: %s" % jinput)
        jinput_msg: Joy = jinput.to_msg()
        jinput_pub.publish(jinput_msg)
        rate.sleep()


if __name__ == '__main__':
    wired_controller: bool = False
    joystick_publisher(wired=wired_controller)

<filename>src/publish_joystick.py
#!/usr/bin/env python
from detect_joystick import Joystick, JoystickInput
from sensor_msgs.msg import Joy
import rospy


def joystick_publisher(hz: int = 10, wired: bool = False):
    jinput_pub: rospy.Publisher = rospy.Publisher('joystick_input', Joy, queue_size=10)
    rospy.init_node('joystick_input_pub')
    rate: rospy.Rate = rospy.Rate(hz)
    js: Joystick = Joystick(wired=wired)
    while not rospy.is_shutdown():
        jinput: JoystickInput = js.get_input()
        rospy.logdebug("Joystick Input: %s" % jinput)
        jinput_msg: Joy = jinput.to_msg()
        jinput_pub.publish(jinput_msg)
        rate.sleep()


if __name__ == '__main__':
    wired_controller: bool = False
    joystick_publisher(wired=wired_controller)

#!/usr/bin/env python