Skip to content

Commit

Permalink
Adding the reference_Pose function
Browse files Browse the repository at this point in the history
  • Loading branch information
malenef committed Sep 23, 2024
1 parent 2191f7f commit d422ff0
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,14 @@ def transition_to_reference_mode(self):
"""
Publishes a zero force wrench message and signals that the system is turning on reference mode.
"""
current_pose = self.get_current_pose()
pose_msg = self.create_pose_message(current_pose)
self.reference_signal_publisher_.publish(pose_msg)
self.operational_mode_signal_publisher_.publish(String(data="Reference mode"))
self.state = States.REFERENCE_MODE
self.get_logger().info("Transitioning to reference mode")


def transition_to_autonomous_mode(self):
"""
Publishes a zero force wrench message and signals that the system is turning on autonomous mode.
Expand Down Expand Up @@ -281,18 +286,6 @@ def joystick_cb(self, msg: Joy) -> Wrench:
) * self.joystick_yaw_scaling_ * self.precise_manuevering_scaling_


if self.reference_mode:
self.current_pose.pose.position.x += self.surge
self.current_pose.pose.position.y += self.sway
self.current_pose.pose.position.z += self.heave

#Convert roll, pitch, and yaw to quaternion
quaternion = quaternion_from_euler(self.roll, self.pitch, self.yaw)
self.current_pose.pose.orientation.x = quaternion[0]
self.current_pose.pose.orientation.y = quaternion[1]
self.current_pose.pose.orientation.z = quaternion[2]
self.current_pose.pose.orientation.w = quaternion[3]
self.pose_publisher.publish(self.current_pose)

# Debounce for the buttons
if current_time - self.last_button_press_time_ < self.debounce_duration_:
Expand Down Expand Up @@ -354,7 +347,22 @@ def joystick_cb(self, msg: Joy) -> Wrench:

# return wrench_msg

def reference_pose(self):
if self.reference_mode:
self.current_pose.pose.position.x += self.surge
self.current_pose.pose.position.y += self.sway
self.current_pose.pose.position.z += self.heave

#Convert roll, pitch, and yaw to quaternion
quaternion = quaternion_from_euler(self.roll, self.pitch, self.yaw)
self.current_pose.pose.orientation.x = quaternion[0]
self.current_pose.pose.orientation.y = quaternion[1]
self.current_pose.pose.orientation.z = quaternion[2]
self.current_pose.pose.orientation.w = quaternion[3]
self.pose_publisher.publish(self.current_pose)

def timer_cb(self):
self.reference_pose()
msg = self.create_pose_message(self.current_pose)
self.pose_publisher.publish(msg)

Expand Down

0 comments on commit d422ff0

Please sign in to comment.