コード例 #1
0
    def publishControl(self):
	# relevant tutorial: http://wiki.ros.org/joy/Tutorials/ConfiguringALinuxJoystick
	# button mapping: Joystick (Logitech Gamepad F710) has 8 axes (X, Y, Z, Rx, Ry, Rz, Hat0X, Hat0Y)
	#       & 11 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnThumbL, BtnThumbR, ?, ?, ?).

	# pressure/depth control - right stick up/down (+1.0 up to -1.0 down)
	# yaw control - right stick left/right (-1.0 right to +1.0 left)
	# speed control - left stick up/down (+1.0 up to -1.0 down)
	# frequency control - left stick right/left (-1.0 right to +1.0 left)
	
	global bcu_toggle_prev
	global valve_toggle_prev	

	cmd_out = joystick_in()	

	cmd_out.header.stamp = self.joy.header.stamp
	cmd_out.freq_ctrl = -1*int(self.joy.axes[0] * 127)
	cmd_out.speed_ctrl = int(self.joy.axes[1] * 127)
	cmd_out.yaw_ctrl = -1*int(self.joy.axes[3] * 127)
	cmd_out.depth_ctrl = int(self.joy.axes[4] * 127)

	cmd_out.bcu_toggle = bool(self.joy.buttons[5]) and not bcu_toggle_prev # send on rising edge only
	cmd_out.valve_toggle = bool(self.joy.buttons[4]) and not valve_toggle_prev

	cmd_out.bcu_forwards = bool(self.joy.buttons[3])
	cmd_out.bcu_backwards = bool(self.joy.buttons[2])
		
	self.pub_toSerial.publish(cmd_out)
	bcu_toggle_prev = bool(self.joy.buttons[5])
	valve_toggle_prev = bool(self.joy.buttons[4])
コード例 #2
0
    def __init__(self):
        self.node_name = rospy.get_name()
        rospy.loginfo("[%s] Initializing " %(self.node_name))
        
        self.joy = None

	self.pub_toSerial = rospy.Publisher("to_serial", joystick_in, queue_size = 1)
	cmd_init = joystick_in(rospy.Time.now(), 0,0,0,0,0,0,0,0)
	self.pub_toSerial.publish(cmd_init)

        # Subscriptions
        self.sub_joy = rospy.Subscriber("joy", Joy, self.cbJoy, queue_size=1)
コード例 #3
0
    def publishControl(self):
        # relevant tutorial: http://wiki.ros.org/joy/Tutorials/ConfiguringALinuxJoystick
        # button mapping: Joystick (Logitech Gamepad F710) has 8 axes (X, Y, Z, Rx, Ry, Rz, Hat0X, Hat0Y)
        #       & 11 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnThumbL, BtnThumbR, ?, ?, ?).

        # pressure/depth control - right stick up/down (+1.0 up to -1.0 down)
        # yaw control - right stick left/right (-1.0 right to +1.0 left)
        # speed control - left stick up/down (+1.0 up to -1.0 down)
        # frequency control - left stick right/left (-1.0 right to +1.0 left)

        cmd_out = joystick_in()

        cmd_out.header.stamp = self.joy.header.stamp
        cmd_out.freq_ctrl = -1 * int(self.joy.axes[0] * 127)
        cmd_out.speed_ctrl = int(self.joy.axes[1] * 127)
        cmd_out.yaw_ctrl = -1 * int(self.joy.axes[3] * 127)
        cmd_out.depth_ctrl = int(self.joy.axes[4] * 127)

        self.pub_toSerial.publish(cmd_out)