Skip to content

Commit

Permalink
Fixed bugs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldokan committed Nov 12, 2023
1 parent 9b936dc commit c744344
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mission/joystick_interface/test/test_joystick_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from joystick_interface.joystick_interface import JoystickInterface
from joystick_interface.joystick_interface import states
from joystick_interface.joystick_interface import States
import rclpy
from sensor_msgs.msg import Joy
from sensor_msgs.msg import Joy
Expand Down Expand Up @@ -41,16 +41,16 @@ def test_input_from_controller_into_wrench_msg(self):
joy_msg.axes = [-1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
joy_msg.buttons = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
wrench_msg = JoystickInterface().joystick_cb(joy_msg)
assert wrench_msg.force.x == -100.0
assert wrench_msg.force.y == -100.0
assert wrench_msg.force.x == -50.0
assert wrench_msg.force.y == -50.0
assert wrench_msg.torque.z == 0.0
rclpy.shutdown()

#When the killswitch button is activated in the buttons list, it should output a wrench msg with only zeros
def test_killswitch_button(self):
rclpy.init()
joystick = JoystickInterface()
joystick.state = states.XBOX_MODE
joystick.state_ = States.XBOX_MODE
joy_msg = Joy()
joy_msg.axes = [-1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
joy_msg.buttons = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Expand All @@ -64,12 +64,12 @@ def test_killswitch_button(self):
def test_moving_in_of_xbox_mode(self):
rclpy.init()
joystick = JoystickInterface()
joystick.state = states.XBOX_MODE
joystick.state_ = States.XBOX_MODE
joy_msg = Joy()
joy_msg.axes = [-1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
joy_msg.buttons = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
wrench_msg = joystick.joystick_cb(joy_msg)
assert wrench_msg.force.x == -100.0
assert wrench_msg.force.y == -100.0
assert wrench_msg.force.x == -50.0
assert wrench_msg.force.y == -50.0
assert wrench_msg.torque.z == 0.0
rclpy.shutdown()

0 comments on commit c744344

Please sign in to comment.