Main Page
Namespaces
Classes
Files
File List
File Members
test
test_joint_trajectory_controller.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
# -*- coding: utf-8 -*-
3
import
math
4
import
sys
5
import
actionlib
6
from
control_msgs.msg
import
(
7
FollowJointTrajectoryAction,
8
FollowJointTrajectoryActionGoal)
9
import
rospy
10
import
rostest
11
import
rosnode
12
from
sensor_msgs.msg
import
JointState
13
from
trajectory_msgs.msg
import
JointTrajectory
14
import
time
15
import
unittest
16
17
18
class
TestJointTrajectoryController
(unittest.TestCase):
19
@classmethod
20
def
setUpClass
(cls):
21
rospy.init_node(
'test_joint_trajectory_controller_node'
)
22
23
def
setUp
(self):
24
self.
joint_states_list
= []
25
26
rospy.Subscriber(
'joint_states'
,
27
JointState, self.
cb_joint_states
, queue_size=10)
28
29
self.
pub
= rospy.Publisher(
30
'joint_trajectory_controller/command'
,
31
JointTrajectory,
32
queue_size=10)
33
34
self.
client
=
actionlib.SimpleActionClient
(
35
'joint_trajectory_controller/follow_joint_trajectory'
,
36
FollowJointTrajectoryAction)
37
self.client.wait_for_server()
38
39
def
cb_joint_states
(self, msg):
40
self.joint_states_list.append(msg)
41
42
def
test_joint_states
(self):
43
# try for 30 s
44
for
i
in
range(30):
45
if
not
self.
joint_states_list
:
46
time.sleep(1.0)
47
self.assertTrue(self.
joint_states_list
)
48
49
if
__name__ ==
'__main__'
:
50
rostest.rosrun(
'melfa_driver'
,
51
'test_joint_trajectory_controller'
,
52
TestJointTrajectoryController)
test_joint_trajectory_controller.TestJointTrajectoryController.cb_joint_states
def cb_joint_states(self, msg)
Definition:
test_joint_trajectory_controller.py:39
test_joint_trajectory_controller.TestJointTrajectoryController.joint_states_list
joint_states_list
Definition:
test_joint_trajectory_controller.py:24
test_joint_trajectory_controller.TestJointTrajectoryController.pub
pub
Definition:
test_joint_trajectory_controller.py:29
test_joint_trajectory_controller.TestJointTrajectoryController.client
client
Definition:
test_joint_trajectory_controller.py:34
test_joint_trajectory_controller.TestJointTrajectoryController.setUpClass
def setUpClass(cls)
Definition:
test_joint_trajectory_controller.py:20
actionlib::SimpleActionClient
test_joint_trajectory_controller.TestJointTrajectoryController.test_joint_states
def test_joint_states(self)
Definition:
test_joint_trajectory_controller.py:42
test_joint_trajectory_controller.TestJointTrajectoryController
Definition:
test_joint_trajectory_controller.py:18
test_joint_trajectory_controller.TestJointTrajectoryController.setUp
def setUp(self)
Definition:
test_joint_trajectory_controller.py:23
melfa_driver
Author(s): Ryosuke Tajima
autogenerated on Mon Jun 10 2019 14:04:51