4 from geometry_msgs.msg
import Pose
6 from test_moveit.core.robot_state
import RobotState
7 from test_moveit.core.robot_model
import RobotModel
15 dir_path = os.path.dirname(os.path.realpath(__file__))
16 URDF_FILE =
"{}/fixtures/panda.urdf".format(dir_path)
17 SRDF_FILE =
"{}/fixtures/panda.srdf".format(dir_path)
21 """Helper function that returns a RobotModel instance."""
22 return RobotModel(urdf_xml_path=URDF_FILE, srdf_xml_path=SRDF_FILE)
28 Test that RobotState can be initialized with a RobotModel
31 robot_state = RobotState(robot_model)
33 self.assertIsInstance(robot_state, RobotState)
37 Test that the robot_model property returns the correct RobotModel
40 robot_state = RobotState(robot_model)
42 self.assertEqual(robot_state.robot_model, robot_model)
46 Test that the frame transform is correct
49 robot_state = RobotState(robot_model)
51 frame_transform = robot_state.get_frame_transform(
"panda_link0")
53 self.assertIsInstance(frame_transform, np.ndarray)
58 Test that the pose is correct
61 robot_state = RobotState(robot_model)
63 pose = robot_state.get_pose(link_name=
"panda_link8")
65 self.assertIsInstance(pose, Pose)
70 Test that the jacobian is correct
73 robot_state = RobotState(robot_model)
75 jacobian = robot_state.get_jacobian(
76 joint_model_group_name=
"panda_arm",
77 reference_point_position=np.array([0.0, 0.0, 0.0]),
80 self.assertIsInstance(jacobian, np.ndarray)
85 Test that the jacobian is correct
88 robot_state = RobotState(robot_model)
90 jacobian = robot_state.get_jacobian(
91 joint_model_group_name=
"panda_arm",
92 link_name=
"panda_link6",
93 reference_point_position=np.array([0.0, 0.0, 0.0]),
96 self.assertIsInstance(jacobian, np.ndarray)
101 Test that the joint group positions can be set
104 robot_state = RobotState(robot_model)
106 joint_group_positions = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
107 robot_state.set_joint_group_positions(
108 joint_model_group_name=
"panda_arm", position_values=joint_group_positions
112 joint_group_positions.tolist(),
113 robot_state.get_joint_group_positions(
"panda_arm").tolist(),
118 Test that the joint group velocities can be set
121 robot_state = RobotState(robot_model)
123 joint_group_velocities = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
124 robot_state.set_joint_group_velocities(
125 joint_model_group_name=
"panda_arm", velocity_values=joint_group_velocities
129 joint_group_velocities.tolist(),
130 robot_state.get_joint_group_velocities(
"panda_arm").tolist(),
135 Test that the joint group accelerations can be set
138 robot_state = RobotState(robot_model)
140 joint_group_accelerations = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
141 robot_state.set_joint_group_accelerations(
142 joint_model_group_name=
"panda_arm",
143 acceleration_values=joint_group_accelerations,
147 joint_group_accelerations.tolist(),
148 robot_state.get_joint_group_accelerations(
"panda_arm").tolist(),
176 if __name__ ==
"__main__":
def test_get_jacobian_1(self)
def test_initialization(self)
def test_set_joint_group_positions(self)
def test_get_frame_transform(self)
def test_robot_model_property(self)
def test_set_joint_group_velocities(self)
def test_get_jacobian_2(self)
def test_set_joint_group_accelerations(self)