Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ev3dev2/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,7 @@ def on(self, x, y, radius=100.0):

# If joystick is in the middle stop the tank
if not x and not y:
MoveTank.off()
self.off()
return

vector_length = sqrt(x*x + y*y)
Expand Down
9 changes: 8 additions & 1 deletion tests/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def test_steering_large_value(self):
self.assertEqual(drive.right_motor.position_sp, 10 * 360)
self.assertEqual(drive.right_motor.speed_sp, 400)

def test_joystick_units(self):
def test_joystick(self):
clean_arena()
populate_arena([('large_motor', 0, 'outA'), ('large_motor', 1, 'outB')])

Expand All @@ -327,6 +327,13 @@ def test_joystick_units(self):
drive.on(0, 50)
self.assertEqual(drive.left_motor.speed_sp, 1050 / 2)
self.assertEqual(drive.right_motor.speed_sp, 1050 / 2)
self.assertEqual(drive.left_motor._get_attribute(None, 'command')[1], 'run-forever')
self.assertEqual(drive.right_motor._get_attribute(None, 'command')[1], 'run-forever')

# With the joystick centered, motors should both be stopped
drive.on(0, 0)
self.assertEqual(drive.left_motor._get_attribute(None, 'command')[1], 'stop')
self.assertEqual(drive.right_motor._get_attribute(None, 'command')[1], 'stop')

def test_units(self):
clean_arena()
Expand Down