Skip to content

Commit 2bab046

Browse files
urfeexurrsk
andauthored
Add more information about acceleration/velocity parametrization in trajectory examples (#251)
The examples were mainly using either time parametrization or implicit acc/vel parametrization using the default values. This adds more explicit acc/vel parametrized motions to the examples with some explaining comments. --------- Co-authored-by: Rune Søe-Knudsen <[email protected]>
1 parent 798b55b commit 2bab046

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

examples/instruction_executor.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ int main(int argc, char* argv[])
115115
std::vector<std::shared_ptr<urcl::control::MotionPrimitive>> motion_sequence{
116116
std::make_shared<urcl::control::MoveJPrimitive>(urcl::vector6d_t{ -1.57, -1.57, 0, 0, 0, 0 }, 0.1,
117117
std::chrono::seconds(5)),
118+
// This point uses acceleration / velocity parametrization
118119
std::make_shared<urcl::control::MoveJPrimitive>(urcl::vector6d_t{ -1.57, -1.6, 1.6, -0.7, 0.7, 0.2 }, 0.1,
119-
std::chrono::seconds(5)),
120+
std::chrono::seconds(0), 1.4, 2.0),
120121

121122
std::make_shared<urcl::control::MoveLPrimitive>(urcl::Pose(-0.203, 0.263, 0.559, 0.68, -1.083, -2.076), 0.1,
122123
std::chrono::seconds(2)),
@@ -125,10 +126,16 @@ int main(int argc, char* argv[])
125126
};
126127
instruction_executor->executeMotion(motion_sequence);
127128

128-
instruction_executor->moveJ({ -1.57, -1.57, 0, 0, 0, 0 });
129-
instruction_executor->moveJ({ -1.57, -1.6, 1.6, -0.7, 0.7, 0.2 });
130-
instruction_executor->moveL({ -0.203, 0.263, 0.559, 0.68, -1.083, -2.076 });
131-
instruction_executor->moveL({ -0.203, 0.463, 0.559, 0.68, -1.083, -2.076 });
129+
double goal_time_sec = 2.0;
130+
131+
// acceleration / velocity parametrization
132+
instruction_executor->moveJ({ -1.57, -1.57, 0, 0, 0, 0 }, 2.0, 2.0);
133+
// goal time parametrization -- acceleration and velocity will be ignored
134+
instruction_executor->moveJ({ -1.57, -1.6, 1.6, -0.7, 0.7, 0.2 }, 0.1, 0.1, goal_time_sec);
135+
// acceleration / velocity parametrization
136+
instruction_executor->moveL({ -0.203, 0.263, 0.559, 0.68, -1.083, -2.076 }, 1.5, 1.5);
137+
// goal time parametrization -- acceleration and velocity will be ignored
138+
instruction_executor->moveL({ -0.203, 0.463, 0.559, 0.68, -1.083, -2.076 }, 0.1, 0.1, goal_time_sec);
132139

133140
g_my_driver->stopControl();
134141
return 0;

examples/trajectory_point_interface.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ void handleRobotProgramState(bool program_running)
5858

5959
void trajDoneCallback(const urcl::control::TrajectoryResult& result)
6060
{
61-
URCL_LOG_INFO("Trajectory done with result %d", result);
62-
;
61+
URCL_LOG_INFO("Trajectory done with result %s", urcl::control::trajectoryResultToString(result).c_str());
6362
g_trajectory_done = true;
6463
}
6564

@@ -126,6 +125,8 @@ int main(int argc, char* argv[])
126125
// Trajectory definition
127126
std::vector<urcl::vector6d_t> points{ { -1.57, -1.57, 0, 0, 0, 0 }, { -1.57, -1.6, 1.6, -0.7, 0.7, 0.2 } };
128127
std::vector<double> motion_durations{ 5.0, 2.0 };
128+
std::vector<double> velocities{ 2.0, 2.3 };
129+
std::vector<double> accelerations{ 2.5, 2.5 };
129130
std::vector<double> blend_radii{ 0.1, 0.1 };
130131

131132
// Trajectory execution
@@ -140,7 +141,8 @@ int main(int argc, char* argv[])
140141
motion_durations = { 0.0, 0.0 };
141142
for (size_t i = 0; i < points.size(); i++)
142143
{
143-
g_my_driver->writeTrajectoryPoint(points[i], 2.0, 2.0, false, motion_durations[i], blend_radii[i]);
144+
g_my_driver->writeTrajectoryPoint(points[i], accelerations[i], velocities[i], false, motion_durations[i],
145+
blend_radii[i]);
144146
}
145147

146148
while (!g_trajectory_done)
@@ -159,17 +161,27 @@ int main(int argc, char* argv[])
159161
std::vector<urcl::vector6d_t> points{ { -0.203, 0.263, 0.559, 0.68, -1.083, -2.076 },
160162
{ -0.203, 0.463, 0.559, 0.68, -1.083, -2.076 } };
161163
std::vector<double> motion_durations{ 5.0, 5.0 };
164+
std::vector<double> velocities{ 2.0, 2.3 };
165+
std::vector<double> accelerations{ 2.5, 2.5 };
162166
std::vector<double> blend_radii{ 0.0, 0.0 };
163167

164-
// Trajectory execution
168+
// Trajectory execution of the path that goes through the points twice.
165169
g_my_driver->writeTrajectoryControlMessage(urcl::control::TrajectoryControlMessage::TRAJECTORY_START,
166-
points.size());
170+
points.size() * 2);
167171
for (size_t i = 0; i < points.size(); i++)
168172
{
169173
// setting the cartesian parameter makes it interpret the 6d vector as a pose and use movel
170174
g_my_driver->writeTrajectoryPoint(points[i], true, motion_durations[i], blend_radii[i]);
171175
}
172176

177+
// Same motion, but parametrized with acceleration and velocity
178+
motion_durations = { 0.0, 0.0 };
179+
for (size_t i = 0; i < points.size(); i++)
180+
{
181+
g_my_driver->writeTrajectoryPoint(points[i], accelerations[i], velocities[i], true, motion_durations[i],
182+
blend_radii[i]);
183+
}
184+
173185
while (!g_trajectory_done)
174186
{
175187
std::this_thread::sleep_for(std::chrono::milliseconds(100));

0 commit comments

Comments
 (0)