@@ -15,6 +15,12 @@ def __init__(self):
15
15
16
16
params = rospy .get_param ('~' )
17
17
self .joint_names = params ['joint_names' ]
18
+ # fixed frequency to control the granularity of the sampling resolution
19
+ self .sample_rate_hz = rospy .get_param ("~sample_rate_hz" , 10 )
20
+ # duration from one sample to the next
21
+ self .sample_rate_dur_secs = (1.0 / float (self .sample_rate_hz ))
22
+ # rospy loop rate
23
+ self .sample_rate = rospy .Rate (self .sample_rate_hz )
18
24
19
25
action_name = "joint_trajectory_controller/follow_joint_trajectory"
20
26
@@ -83,12 +89,6 @@ def fjta_cb(self, goal):
83
89
# linear interpolation of the given trajectory samples is used
84
90
# to compute smooth intermediate joints positions at a fixed resolution
85
91
86
- # fixed frequency to control the granularity of the sampling resolution
87
- sample_rate_hz = 10
88
- # duration from one sample to the next
89
- sample_rate_dur_secs = (1.0 / float (sample_rate_hz ))
90
- # rospy loop rate
91
- sample_rate = rospy .Rate (sample_rate_hz ) # 10Hz for now
92
92
# upper bound of local duration segment
93
93
t1 = point .time_from_start - time_since_start_of_previous_point
94
94
# compute velocity as the fraction of distance from prev point to next point in trajectory
@@ -124,9 +124,9 @@ def fjta_cb(self, goal):
124
124
self .joint_states .position = interpolated_positions
125
125
126
126
# sleep until next sample update
127
- sample_rate .sleep ()
127
+ self . sample_rate .sleep ()
128
128
# increment passed time
129
- latest_time_from_start += rospy .Duration (sample_rate_dur_secs )
129
+ latest_time_from_start += rospy .Duration (self . sample_rate_dur_secs )
130
130
131
131
# ensure that the goal and time point is always exactly reached
132
132
latest_time_from_start = point .time_from_start
0 commit comments