Skip to content

Commit e034509

Browse files
committed
get additional multirotor tests running
1 parent 453be55 commit e034509

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

roboticstoolbox/blocks/test_blocks.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -344,46 +344,48 @@ class State:
344344
block.start(state=s)
345345
block.step(state=s)
346346

347-
@unittest.skip
348347
def test_quadrotor(self):
349348

350349
block = MultiRotor(quadrotor)
351350
print(block.D)
352351
z = np.r_[0, 0, 0, 0]
353-
block.inputs = [z]
352+
block.test_inputs = [z]
354353
block.setstate(block.getstate0())
355354
nt.assert_equal(block.getstate0(), np.zeros((12,)))
356355
block.setstate(block.getstate0())
357356

358357
block._x[2] = -100 # set altitude
359-
block.inputs[0] = 100 * np.r_[1, -1, 1, -1]
358+
u = [100 * np.r_[1, -1, 1, -1]]
360359

361360
# check outputs
362-
out = block.output()
361+
out = block.T_output(u)
363362
self.assertIsInstance(out, list)
364-
self.assertEqual(len(out), 2)
365-
self.assertIsInstance(out[0], np.ndarray)
366-
self.assertEqual(out[0].shape, (12,))
367-
self.assertIsInstance(out[1], dict)
368-
self.assertEqual(len(out[1]), 2)
369-
self.assertEqual(out[0][2], -100)
363+
self.assertEqual(len(out), 1)
364+
365+
self.assertIsInstance(out[0], dict)
370366

371367
# check deriv, checked against MATLAB version 20200621
372-
block.inputs[0] = 800 * np.r_[1, -1, 1, -1] # too little thrust, falling
373-
d = block.deriv()
368+
u = [800 * np.r_[1, -1, 1, -1]] # too little thrust, falling
369+
d = block.T_deriv(u)
374370
self.assertIsInstance(d, np.ndarray)
375371
self.assertEqual(d.shape, (12,))
376372
self.assertGreater(d[8], 0)
377373
nt.assert_array_almost_equal(np.delete(d, 8), np.zeros((11,))) # other derivs are zero
378374

379-
block.inputs[0] = 900 * np.r_[1, -1, 1, -1] # too much thrust, rising
380-
self.assertLess(block.deriv()[8], 0)
375+
u = [900 * np.r_[1, -1, 1, -1]] # too much thrust, rising
376+
self.assertLess(block.T_deriv(u)[8], 0)
377+
378+
u = [800 * np.r_[1.2, -1, 0.8, -1]] # + pitch
379+
self.assertGreater(block.T_deriv(u)[10], 20)
380+
381+
u = [800 * np.r_[0.8, -1, 1.2, -1]] # - pitch
382+
self.assertLess(block.T_deriv(u)[10], -20)
381383

382-
block.inputs[0] = 800 * np.r_[0.8, -1, 1.2, -1] # pitching
383-
self.assertGreater(block.deriv()[10], 20)
384+
u = [800 * np.r_[1, -0.8, 1, -1.2]] # + roll
385+
self.assertGreater(block.T_deriv(u)[9], 20)
384386

385-
block.inputs[0] = 800 * np.r_[1, -1.2, 1, -0.8] # rolling
386-
self.assertGreater(block.deriv()[9], 20)
387+
u = [800 * np.r_[1, -1.2, 1, -0.8]] # - roll
388+
self.assertLess(block.T_deriv(u)[9], -20)
387389

388390
@unittest.skip
389391
def test_quadrotorplot(self):

0 commit comments

Comments
 (0)