Skip to content

Commit 16f0c21

Browse files
committed
fixed oscillations
1 parent 42e7409 commit 16f0c21

3 files changed

Lines changed: 40 additions & 4 deletions

File tree

param/tasks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ max_translation_speed: 1.0
66
# maximum z velocity
77
max_z_velocity: 2.0
88
# planner lag, in seconds
9-
planning_lag: .35
9+
planning_lag: .100
1010
# timeout for time to get a plan
1111
planning_timeout: .5
1212
# distance from goal to stop replanning

src/iarc7_motion/iarc_tasks/xyztranslation_task.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import rospy
33
import tf2_ros
44
import threading
5+
import cPickle as pickle
56

67
from .abstract_task import AbstractTask
78
from iarc_tasks.task_states import (TaskRunning,
@@ -35,6 +36,9 @@ def __init__(self, task_request):
3536

3637
self._starting_motion_point = None
3738

39+
# self._list_info = []
40+
# self._request_list = []
41+
3842
self._lock = threading.RLock()
3943

4044
self._linear_gen = self.topic_buffer.get_linear_motion_profile_generator()
@@ -66,12 +70,16 @@ def get_desired_command(self):
6670

6771
if self._state == XYZTranslationTaskState.COMPLETING:
6872
if (rospy.Time.now() + rospy.Duration(.10)) >= self._complete_time:
73+
# name = '/home/andrew/data.bin'
74+
# file = open(name, 'wb')
75+
# pickle.dump(self._list_info, file)
76+
# file.close()
77+
# self._linear_gen.dump_info()
6978
return (TaskDone(),)
7079
else:
7180
return (TaskRunning(), NopCommand())
7281

7382
expected_time = rospy.Time.now() + self._PLANNING_LAG
74-
7583
self._starting_motion_point = self._linear_gen.expected_point_at_time(expected_time).motion_point
7684

7785
_starting_pose = self._starting_motion_point.pose.position
@@ -129,6 +137,8 @@ def _generate_request(self, expected_time, reset_timer=True):
129137
goal.motion_point.pose.position.y = self._goal_y
130138
goal.motion_point.pose.position.z = self._goal_z
131139

140+
self._request_list = [start, goal, None]
141+
132142
request.start = start
133143
request.goal = goal
134144

@@ -141,6 +151,8 @@ def _feedback_callback(self, status, msg):
141151
with self._lock:
142152
self._feedback = msg
143153
self._plan = msg.plan
154+
# self._request_list[2] = msg.plan
155+
# self._list_info.append(self._request_list)
144156
self._state = XYZTranslationTaskState.PLAN_RECEIVED
145157

146158
def cancel(self):

src/iarc7_motion/linear_motion_profile_generator.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from nav_msgs.msg import Path
99

1010
from iarc7_msgs.msg import MotionPointStamped, MotionPointStampedArray
11-
11+
import cPickle as pickle
1212

1313
# Convert a 3 element numpy array to a Vector3 message
1414
def np_to_msg(array, msg):
@@ -94,6 +94,8 @@ def __init__(self, start_motion_point):
9494
self._override_start_position = None
9595
self._override_start_velocity = None
9696

97+
# self._info = []
98+
9799
linear_motion_profile_generator = None
98100

99101
@staticmethod
@@ -103,8 +105,30 @@ def get_linear_motion_profile_generator():
103105
MotionPointStamped())
104106
return LinearMotionProfileGenerator.linear_motion_profile_generator
105107

108+
# def dump_info(self):
109+
# name = '/home/andrew/new_data.bin'
110+
# file = open(name, 'wb')
111+
# pickle.dump(self._info, file)
112+
# file.close()
113+
106114
def set_global_plan(self, plan):
107-
self._last_motion_plan = plan
115+
if len(self._last_motion_plan.motion_points) == 0:
116+
# self._info.append((self._last_motion_plan, plan))
117+
self._last_motion_plan = plan
118+
else:
119+
new_plan = MotionPointStampedArray()
120+
new_point_stamp = plan.motion_points[0].header.stamp
121+
122+
for i in range(0, len(self._last_motion_plan.motion_points)):
123+
current_stamp = self._last_motion_plan.motion_points[i].header.stamp
124+
if current_stamp > new_point_stamp:
125+
new_plan.motion_points = self._last_motion_plan.motion_points[:i]
126+
break
127+
128+
new_plan.motion_points.extend(plan.motion_points)
129+
# self._info.append((self._last_motion_plan, plan))
130+
131+
self._last_motion_plan = new_plan
108132

109133
# Get a starting motion point for a given time
110134
def _get_start_point(self,

0 commit comments

Comments
 (0)