From d39862a74b61470f5b58527170f27e532509d4a7 Mon Sep 17 00:00:00 2001 From: Prathyoosha Chaya Date: Thu, 4 Oct 2018 19:50:37 -0700 Subject: [PATCH] Fixes to work with new controller and manipulate pitch. Thanks Ben Signed-off-by: Prathyoosha Chaya --- .../DriveAndCameraControlSender.py | 4 +- .../EffectorsAndArmControlSender.py | 21 +++-- .../src/Resources/Ui/right_screen.ui | 88 +++++++++++++++++-- .../rover_main/launch/rover/cameras.launch | 2 +- 4 files changed, 93 insertions(+), 22 deletions(-) diff --git a/software/ros_packages/ground_station/src/Framework/ControlSystems/DriveAndCameraControlSender.py b/software/ros_packages/ground_station/src/Framework/ControlSystems/DriveAndCameraControlSender.py index d37b2a2..9c62fc7 100644 --- a/software/ros_packages/ground_station/src/Framework/ControlSystems/DriveAndCameraControlSender.py +++ b/software/ros_packages/ground_station/src/Framework/ControlSystems/DriveAndCameraControlSender.py @@ -13,8 +13,8 @@ from rover_control.msg import DriveCommandMessage, TowerPanTiltControlMessage ##################################### # Global Variables ##################################### -GAME_CONTROLLER_NAME = "Microsoft X-Box One S pad" - +#GAME_CONTROLLER_NAME = "Microsoft X-Box One S pad" <-- This was the actual xbox controller that Dylan had to buy at CIRC 2018 +GAME_CONTROLLER_NAME = "PowerA Xbox One wired controller" DEFAULT_DRIVE_COMMAND_TOPIC = "/rover_control/command_control/ground_station_drive" DEFAULT_TOWER_PAN_TILT_COMMAND_TOPIC = "/rover_control/tower/pan_tilt/control" DEFAULT_CHASSIS_PAN_TILT_COMMAND_TOPIC = "/rover_control/chassis/pan_tilt/control" diff --git a/software/ros_packages/ground_station/src/Framework/ControlSystems/EffectorsAndArmControlSender.py b/software/ros_packages/ground_station/src/Framework/ControlSystems/EffectorsAndArmControlSender.py index f1bc41e..29e0172 100644 --- a/software/ros_packages/ground_station/src/Framework/ControlSystems/EffectorsAndArmControlSender.py +++ b/software/ros_packages/ground_station/src/Framework/ControlSystems/EffectorsAndArmControlSender.py @@ -197,6 +197,8 @@ class EffectorsAndArmControlSender(QtCore.QThread): self.gripper_mode_wide_label = self.right_screen.gripper_mode_wide_label # type: QtWidgets.QLabel self.gripper_mode_scissor_label = self.right_screen.gripper_mode_scissor_label # type: QtWidgets.QLabel + self.arm_speed_limit_slider = self.right_screen.arm_speed_limit_slider # type: QtWidgets.QSlider + # ########## Get the settings instance ########## self.settings = QtCore.QSettings() @@ -373,30 +375,27 @@ class EffectorsAndArmControlSender(QtCore.QThread): right_x_axis = self.controller.controller_states["right_x_axis"] if abs(self.controller.controller_states[ "right_x_axis"]) > RIGHT_X_AXIS_DEADZONE else 0 - # print left_x_axis, ":", left_y_axis, ":", right_x_axis, ":", right_y_axis - - left_trigger_ratio = left_trigger / 255.0 - right_trigger_ratio = right_trigger / 255.0 + speed_limit = self.arm_speed_limit_slider.value() / 100.0 if left_trigger > 0: should_publish_arm = True - arm_control_message.base = ((left_x_axis / THUMB_STICK_MAX) * BASE_SCALAR) * left_trigger_ratio - arm_control_message.shoulder = ((left_y_axis / THUMB_STICK_MAX) * SHOULDER_SCALAR) * left_trigger_ratio - arm_control_message.elbow = (-(right_y_axis / THUMB_STICK_MAX) * ELBOW_SCALAR) * left_trigger_ratio - arm_control_message.roll = (-(right_x_axis / THUMB_STICK_MAX) * ROLL_SCALAR) * left_trigger_ratio + arm_control_message.base = ((left_x_axis / THUMB_STICK_MAX) * BASE_SCALAR) * speed_limit + arm_control_message.shoulder = ((left_y_axis / THUMB_STICK_MAX) * SHOULDER_SCALAR) * speed_limit + arm_control_message.elbow = (-(right_y_axis / THUMB_STICK_MAX) * ELBOW_SCALAR) * speed_limit + arm_control_message.roll = (-(right_x_axis / THUMB_STICK_MAX) * ROLL_SCALAR) * speed_limit elif right_trigger > 0: should_publish_arm = True should_publish_gripper = True - arm_control_message.wrist_roll = ((left_x_axis / THUMB_STICK_MAX) * BASE_SCALAR) * right_trigger_ratio + arm_control_message.wrist_roll = ((left_x_axis / THUMB_STICK_MAX) * BASE_SCALAR) * speed_limit # ##### FIXME ##### # Remove this once the arm is fixed - # arm_control_message.wrist_pitch = (-(left_y_axis / THUMB_STICK_MAX) * WRIST_PITCH_SCALAR) * right_trigger_ratio + # arm_control_message.wrist_pitch = (-(left_y_axis / THUMB_STICK_MAX) * WRIST_PITCH_SCALAR) * speed_limit # ################# - gripper_control_message.gripper_position_relative = (-(right_y_axis / THUMB_STICK_MAX) * GRIPPER_MOVEMENT_SCALAR) * right_trigger_ratio + gripper_control_message.gripper_position_relative = (-(right_y_axis / THUMB_STICK_MAX) * GRIPPER_MOVEMENT_SCALAR) if should_publish_arm: self.relative_arm_control_publisher.publish(arm_control_message) diff --git a/software/ros_packages/ground_station/src/Resources/Ui/right_screen.ui b/software/ros_packages/ground_station/src/Resources/Ui/right_screen.ui index d166be0..5dda76d 100644 --- a/software/ros_packages/ground_station/src/Resources/Ui/right_screen.ui +++ b/software/ros_packages/ground_station/src/Resources/Ui/right_screen.ui @@ -2217,7 +2217,7 @@ Position - 14 + 12 75 true @@ -2308,7 +2308,7 @@ Position - 14 + 12 75 true @@ -2378,13 +2378,13 @@ Position - 14 + 12 75 true - Speed Limit + Rover Speed Limit Qt::AlignCenter @@ -2419,11 +2419,71 @@ Position + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 12 + 75 + true + + + + Arm Speed Limit + + + Qt::AlignCenter + + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + - 14 + 12 75 true @@ -2534,7 +2594,7 @@ Position - 14 + 12 75 true @@ -2578,7 +2638,13 @@ Position 0 - 50 + 25 + + + + + 16777215 + 25 @@ -2611,7 +2677,13 @@ Position 0 - 50 + 25 + + + + + 16777215 + 25 diff --git a/software/ros_packages/rover_main/launch/rover/cameras.launch b/software/ros_packages/rover_main/launch/rover/cameras.launch index 52aae29..b4a374f 100644 --- a/software/ros_packages/rover_main/launch/rover/cameras.launch +++ b/software/ros_packages/rover_main/launch/rover/cameras.launch @@ -3,7 +3,7 @@ - +