35 from nav_msgs.msg
import Odometry
36 from std_srvs.srv
import Empty
37 from tf.transformations
import euler_from_quaternion
38 from control_msgs.msg
import FollowJointTrajectoryAction, FollowJointTrajectoryGoal
39 from trajectory_msgs.msg
import JointTrajectoryPoint
46 parser = argparse.ArgumentParser(description=
'Check gundam robot.')
47 parser.add_argument(
'--pos', dest=
'pos', default=[0, 0, 0], nargs=3, type=float,
48 help=
'target position')
49 parser.add_argument(
'--rot', dest=
'rot', default=[0, 0, 0], nargs=3, type=float,
50 help=
'target orientation')
51 parser.add_argument(
'filename', type=str, nargs=
'?',
52 help=
'filename for trajectory pattern csv')
53 args, unknown = parser.parse_known_args()
58 print(
"Initializing node... ")
59 rospy.init_node(
'test_walk_pose', anonymous=
True)
66 goal = FollowJointTrajectoryGoal()
67 goal.goal_time_tolerance = rospy.Time(1)
69 rospy.loginfo(
"Opening {}".format(self.
filename))
71 reader = csv.reader(f, skipinitialspace=
True)
75 goal.trajectory.joint_names = row[1:]
78 point = JointTrajectoryPoint()
79 point.positions = [float(n)
for n
in row[1:]]
80 point.time_from_start = rospy.Duration(float(row[0]))
81 goal.trajectory.points.append(point)
83 '/fullbody_controller/follow_joint_trajectory',
84 FollowJointTrajectoryAction,
87 if not self.client.wait_for_server(timeout=rospy.Duration(10)):
88 rospy.logerr(
"Timed out waiting for Action Server")
89 rospy.signal_shutdown(
"Timed out waiting for Action Server")
93 goal.trajectory.header.stamp = rospy.Time.now()
94 self.client.send_goal(goal)
97 p = msg.pose.pose.position
98 r = msg.pose.pose.orientation
100 rot = euler_from_quaternion([r.x, r.y, r.z, r.w])
105 rospy.loginfo(
"pos: {:6.3f} {:6.3f} {:6.3f} - ".format(pos[0], pos[1], pos[2]) +
106 "rot: {:6.3f} {:6.3f} {:6.3f} < ".format(rot[0], rot[1], rot[2]) +
107 "pos: {:6.3f} {:6.3f} {:6.3f} - ".format(diff_pos[0], diff_pos[1], diff_pos[2]) +
108 "rot: {:6.3f} {:6.3f} {:6.3f}".format(diff_rot[0], diff_rot[1], diff_rot[2]))
111 if (diff_pos[0] < 0.5
and diff_pos[1] < 0.5
and diff_pos[2] < 0.5
and 112 diff_rot[0] < 0.1
and diff_rot[1] < 0.1
and diff_rot[2] < 0.1):
116 rospy.Subscriber(
"/base_link_ground_truth", Odometry, self.
base_link_cb)
117 timeout_t = rospy.Time.now() + rospy.Duration(40)
118 while not rospy.is_shutdown()
and not self.
base_success and rospy.Time.now() < timeout_t:
119 rospy.sleep(rospy.Duration(1.0))
123 if __name__ ==
'__main__':
125 rostest.rosrun(
'gundam_rx78_gazebo',
'test_walk_pose', TestWalkPose)
def base_link_cb(self, msg)