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):
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 
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)


melfa_driver
Author(s): Ryosuke Tajima
autogenerated on Mon Jun 10 2019 14:04:51