File size: 2,262 Bytes
cf8614b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import unittest
from tests.core import TestCore
from pyrep.const import JointType
from pyrep.robots.arms.panda import Panda
import numpy as np


# Pick one arm to test all of the joint group functionality.
# Simply checks for wiring mistakes between the joints.
class TestJointGroups(TestCore):

    def setUp(self):
        super().setUp()
        self.robot = Panda()
        self.num_joints = len(self.robot.joints)

    def test_get_joint_types(self):
        self.assertEqual(self.robot.get_joint_types(),
                         [JointType.REVOLUTE] * self.num_joints)

    def test_get_set_joint_positions(self):
        self.robot.set_joint_positions([0.1] * self.num_joints)
        self.assertEqual(len(self.robot.get_joint_positions()), self.num_joints)

    def test_get_set_joint_target_positions(self):
        self.robot.set_joint_target_positions([0.1] * self.num_joints)
        self.assertEqual(
            len(self.robot.get_joint_target_positions()), self.num_joints)

    def test_get_set_joint_target_velocities(self):
        self.robot.set_joint_target_velocities([0.1] * self.num_joints)
        self.assertEqual(
            len(self.robot.get_joint_target_velocities()), self.num_joints)

    def test_get_set_joint_forces(self):
        self.robot.set_joint_target_velocities([-999] * self.num_joints)
        self.robot.set_joint_forces([0.6] * self.num_joints)
        self.pyrep.step()
        self.assertEqual(len(self.robot.get_joint_forces()), self.num_joints)

    def test_get_velocities(self):
        self.assertEqual(
            len(self.robot.get_joint_velocities()), self.num_joints)

    def test_get_set_joint_intervals(self):
        self.robot.set_joint_intervals(
            [False] * self.num_joints, [[-2.0, 2.0]] * self.num_joints)
        cyclics, intervals = self.robot.get_joint_intervals()
        self.assertEqual(len(cyclics), self.num_joints)
        self.assertEqual(len(intervals), self.num_joints)

    def test_get_joint_upper_velocity_limits(self):
        self.assertEqual(
            len(self.robot.get_joint_upper_velocity_limits()), self.num_joints)

    def test_get_visuals(self):
        self.assertEqual(len(self.robot.get_visuals()), 10)


if __name__ == '__main__':
    unittest.main()