Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
qhdwight committed Apr 27, 2024
1 parent 35e4a7e commit 7dcfcc7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/localization/gps_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ def main():


if __name__ == "__main__":
main()
main()
16 changes: 6 additions & 10 deletions src/teleoperation/arm_automation/arm_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@ def execute_callback(goal: ArmActionGoal):
rospy.logerr("No joint state data available")
server.set_aborted(ArmActionResult())
return

if goal.name == "de_home":
target_names = ["joint_de_pitch", "joint_de_roll"]
target_positions = [
joint_state.position[joint_state.name.index('joint_de_pitch')],
np.pi / 8
]
target_positions = [joint_state.position[joint_state.name.index("joint_de_pitch")], np.pi / 8]
rospy.loginfo(f"Moving to {target_positions} for {target_names}")
else:
rospy.logerr("Invalid goal name")
server.set_aborted(ArmActionResult())
return

rate = rospy.Rate(20)
while not rospy.is_shutdown():
if server.is_preempt_requested():
Expand All @@ -51,14 +48,13 @@ def execute_callback(goal: ArmActionGoal):
server.set_aborted(ArmActionResult())
return


pos_pub.publish(Position(names=target_names, positions=target_positions))

feedback = [
joint_state.position[joint_state.name.index('joint_de_pitch')],
joint_state.position[joint_state.name.index('joint_de_roll')]
joint_state.position[joint_state.name.index("joint_de_pitch")],
joint_state.position[joint_state.name.index("joint_de_roll")],
]

if np.allclose(target_positions, feedback, atol=0.1):
rospy.loginfo("Reached target")
break
Expand Down
17 changes: 8 additions & 9 deletions src/teleoperation/backend/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,14 @@ def publish_throttle(self, type, names, axes, buttons):
throttle_cmd.throttles = [
self.ra_config["joint_a"]["multiplier"] * self.filter_xbox_axis(axes[self.xbox_mappings["left_x"]]),
self.ra_config["joint_b"]["multiplier"] * self.filter_xbox_axis(axes[self.xbox_mappings["left_y"]]),
self.ra_config["joint_c"]["multiplier"] * quadratic(self.filter_xbox_axis(axes[self.xbox_mappings["right_y"]])),
self.ra_config["joint_de_pitch"]["multiplier"] * self.filter_xbox_axis(
self.ra_config["joint_c"]["multiplier"]
* quadratic(self.filter_xbox_axis(axes[self.xbox_mappings["right_y"]])),
self.ra_config["joint_de_pitch"]["multiplier"]
* self.filter_xbox_axis(
buttons[self.xbox_mappings["right_trigger"]] - buttons[self.xbox_mappings["left_trigger"]]
),
self.ra_config["joint_de_roll"]["multiplier"] * self.filter_xbox_axis(
self.ra_config["joint_de_roll"]["multiplier"]
* self.filter_xbox_axis(
buttons[self.xbox_mappings["right_bumper"]] - buttons[self.xbox_mappings["left_bumper"]]
),
self.ra_config["allen_key"]["multiplier"] * self.filter_xbox_button(buttons, "y", "a"),
Expand Down Expand Up @@ -433,7 +436,7 @@ def get_axes_input(
# angular_from_lateral = get_axes_input("left_right", 0.4, True)
angular = get_axes_input("twist", 0.03, True, self.max_angular_speed * dampen)

linear += get_axes_input("tilt", 0.5, scale=0.1)
linear += get_axes_input("tilt", 0.5, scale=0.1)

self.twist_pub.publish(
Twist(
Expand Down Expand Up @@ -475,11 +478,7 @@ def arm_controller_callback(self, msg):
def sa_joint_callback(self, msg):
names = msg.name
z = msg.position[names.index("sa_z")]
self.send(
text_data=json.dumps(
{"type": "sa_z", "sa_z": z}
)
)
self.send(text_data=json.dumps({"type": "sa_z", "sa_z": z}))

def drive_controller_callback(self, msg):
hits = []
Expand Down

0 comments on commit 7dcfcc7

Please sign in to comment.