Пример #1
0
	def flipper_jcb(self, joy):
		if joy.buttons[self.deadman_button]:
			flipper_command = FlipperCommand()
			if joy.buttons[self.rl_button]:
				flipper_command.object_id = ID_FLIPPER_REAR_LEFT
				if joy.pressed(self.reset_button):
					flipper_command.angle = 0.
					self.flipper_pub.publish(flipper_command)
				if joy.axis_touched(self.flipper_axis):
					flipper_command.angle = joy.axes[self.flipper_axis]*pi/2.
					self.flipper_pub.publish(flipper_command)
Пример #2
0
 def flipper_jcb(self, joy):
     if joy.buttons[self.deadman_button]:
         flipper_command = FlipperCommand()
         if joy.buttons[self.rl_button]:
             flipper_command.object_id = ID_FLIPPER_REAR_LEFT
             if joy.pressed(self.reset_button):
                 flipper_command.angle = 0.
                 self.flipper_pub.publish(flipper_command)
             if joy.axis_touched(self.flipper_axis):
                 flipper_command.angle = joy.axes[
                     self.flipper_axis] * pi / 2.
                 self.flipper_pub.publish(flipper_command)
Пример #3
0
 def flipper_jcb(self, joy):
     '''Handle flippers command based on the joystick input.'''
     if joy.is_down_any(self.deadman_buttons):
         if joy.pressed(self.flipper_reset_button):  # flat button
             self.posture_cmd_pub.publish(0)
         elif joy.axis_touched(self.flipper_axis):
             try:
                 if all([
                         joy.buttons[button]
                         for button in self.get_flipper_buttons()
                 ]):
                     self.fs.frontLeft -= joy.axes[
                         self.flipper_axis] * self.flipper_increment
                     self.fs.frontRight -= joy.axes[
                         self.flipper_axis] * self.flipper_increment
                     self.fs.rearLeft += joy.axes[
                         self.flipper_axis] * self.flipper_increment
                     self.fs.rearRight += joy.axes[
                         self.flipper_axis] * self.flipper_increment
                     self.flippers_pub.publish(self.fs)
                 else:  # individual control
                     flipperMotion = FlipperCommand()
                     if joy.buttons[self.flipper_button_fl]:
                         flipperMotion.object_id = ID_FLIPPER_FRONT_LEFT
                         flipperMotion.angle = self.fs.frontLeft - joy.axes[
                             self.flipper_axis] * self.flipper_increment
                         self.flipper_pub.publish(flipperMotion)
                     if joy.buttons[self.flipper_button_fr]:
                         flipperMotion.object_id = ID_FLIPPER_FRONT_RIGHT
                         flipperMotion.angle = self.fs.frontRight - joy.axes[
                             self.flipper_axis] * self.flipper_increment
                         self.flipper_pub.publish(flipperMotion)
                     if joy.buttons[self.flipper_button_rl]:
                         flipperMotion.object_id = ID_FLIPPER_REAR_LEFT
                         flipperMotion.angle = self.fs.rearLeft + joy.axes[
                             self.flipper_axis] * self.flipper_increment
                         self.flipper_pub.publish(flipperMotion)
                     if joy.buttons[self.flipper_button_rr]:
                         flipperMotion.object_id = ID_FLIPPER_REAR_RIGHT
                         flipperMotion.angle = self.fs.rearRight + joy.axes[
                             self.flipper_axis] * self.flipper_increment
                         self.flipper_pub.publish(flipperMotion)
             except (TypeError, AttributeError), e:
                 rospy.logwarn(
                     'Flipper command ignored since no FlippersState message received.'
                 )
Пример #4
0
	def flipper_jcb(self, joy):
		'''Handle flippers command based on the joystick input.'''
		if joy.is_down_any(self.deadman_buttons):
			if joy.pressed(self.flipper_reset_button):	# flat button
				self.posture_cmd_pub.publish(0)
			elif joy.axis_touched(self.flipper_axis):
				try:
					if all([joy.buttons[self.flipper_button_fl],
							joy.buttons[self.flipper_button_fr],
							joy.buttons[self.flipper_button_rl],
							joy.buttons[self.flipper_button_rr]]):
						self.fs.frontLeft -= joy.axes[self.flipper_axis]*self.flipper_increment
						self.fs.frontRight -= joy.axes[self.flipper_axis]*self.flipper_increment
						self.fs.rearLeft += joy.axes[self.flipper_axis]*self.flipper_increment
						self.fs.rearRight += joy.axes[self.flipper_axis]*self.flipper_increment
						self.flippers_pub.publish(self.fs)
					else:	# individual control
						flipperMotion = FlipperCommand()
						if joy.buttons[self.flipper_button_fl]:
							flipperMotion.object_id = ID_FLIPPER_FRONT_LEFT
							flipperMotion.angle = self.fs.frontLeft - joy.axes[self.flipper_axis]*self.flipper_increment
							self.flipper_pub.publish(flipperMotion)
						if joy.buttons[self.flipper_button_fr]:
							flipperMotion.object_id = ID_FLIPPER_FRONT_RIGHT
							flipperMotion.angle = self.fs.frontRight - joy.axes[self.flipper_axis]*self.flipper_increment
							self.flipper_pub.publish(flipperMotion)
						if joy.buttons[self.flipper_button_rl]:
							flipperMotion.object_id = ID_FLIPPER_REAR_LEFT
							flipperMotion.angle = self.fs.rearLeft + joy.axes[self.flipper_axis]*self.flipper_increment
							self.flipper_pub.publish(flipperMotion)
						if joy.buttons[self.flipper_button_rr]:
							flipperMotion.object_id = ID_FLIPPER_REAR_RIGHT
							flipperMotion.angle = self.fs.rearRight + joy.axes[self.flipper_axis]*self.flipper_increment
							self.flipper_pub.publish(flipperMotion)
				except (TypeError, AttributeError), e:
					rospy.logwarn('Flipper command ignored since no FlippersState message received.')