Skip to content

Commit

Permalink
Automated autoyapf fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 1, 2023
1 parent ba88939 commit 9783172
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions mission/joystick_interface/scripts/joystick_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#git remote set-url origin [email protected]:vortexntnu/vortex-asv.git
import yaml


class JoystickInterface(Node):

def __init__(self):
Expand All @@ -27,10 +28,10 @@ def __init__(self):
]

self.joystick_axes_map = [
"horizontal_axis_left_stick", #Translation (Left and Right)
"vertical_axis_left_stick", #Translation (Forwards and Backwards)
"horizontal_axis_left_stick", #Translation (Left and Right)
"vertical_axis_left_stick", #Translation (Forwards and Backwards)
"LT",
"horizontal_axis_right_stick", #Rotation
"horizontal_axis_right_stick", #Rotation
"vertical_axis_right_stick",
"RT",
"dpad_horizontal",
Expand All @@ -39,38 +40,38 @@ def __init__(self):

#Create a Publisher and a suscriber from the ros2 tutorial
super().__init__('joystick_interface_node')
self.joy_subscriber = self.create_subscription(Joy, "/joystick/joy", self.joystick_cb, 1)

self.wrench_publisher = self.create_publisher(Wrench, "/thrust/wrench_input", 1)
self.joy_subscriber = self.create_subscription(Joy, "/joystick/joy",
self.joystick_cb, 1)

self.wrench_publisher = self.create_publisher(Wrench,
"/thrust/wrench_input",
1)

#YAML file first need to be translating in ROS2 ; Getting the input from the controller'
self.declare_parameter('surge', 100.0)
self.declare_parameter('sway', 100.0)
self.declare_parameter('yaw', 100.0)

self.joystick_surge_scaling = self.get_parameter('surge').value #is it getting the parameters from the YAML file ? No --> TO DO
self.joystick_surge_scaling = self.get_parameter(
'surge'
).value #is it getting the parameters from the YAML file ? No --> TO DO
self.joystick_sway_scaling = self.get_parameter('sway').value
self.joystick_yaw_scaling = self.get_parameter('yaw').value



def create_2d_wrench_message(self, x, y, yaw):
wrench_msg = Wrench()
wrench_msg.force.x = x
wrench_msg.force.y = y
wrench_msg.torque.z = yaw
return wrench_msg


def publish_wrench_message(self, wrench):
self.wrench_publisher.publish(wrench)


def joystick_cb(self, msg):

#Input from controller to joystick_interface
buttons = {} #dictionnary
buttons = {} #dictionnary
axes = {}

for i in range(len(msg.buttons)):
Expand All @@ -88,10 +89,8 @@ def joystick_cb(self, msg):

self.publish_wrench_message(wrench_msg)


#a = msg.buttons #to remove
return wrench_msg



def main(args=None):
Expand Down

0 comments on commit 9783172

Please sign in to comment.