This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor updates for release 2.1: fixes for Python 3, added Matlab examp…
…le for `while handle.is_busy()`
- Loading branch information
Showing
4 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
% call methods to make sure they exist and don't trigger syntax errors | ||
% this test program will make the arm move! | ||
function test_move_wait(arm_name) | ||
try | ||
rosnode list; | ||
catch | ||
rosinit; | ||
end | ||
r = dvrk.arm(arm_name); | ||
disp('---- Enabling (waiting up to 30s)'); | ||
if ~r.enable(30.0) | ||
error('Unable to enable arm'); | ||
end | ||
disp('---- Homing (waiting up to 30s)'); | ||
if ~r.home(30.0) | ||
error('Unable to home arm'); | ||
end | ||
|
||
% amplitude of motion | ||
amplitude = deg2rad(10.0); | ||
goal = r.setpoint_js(); | ||
initial_position = goal(1); | ||
|
||
% move_jp | ||
disp('--> Testing the trajectory with wait()'); | ||
|
||
tic; | ||
|
||
% first motion | ||
goal(1) = initial_position + amplitude; | ||
r.move_jp(goal).wait(); | ||
|
||
% second motion | ||
goal(1) = initial_position - amplitude; | ||
r.move_jp(goal).wait(); | ||
|
||
% third motion | ||
goal(1) = initial_position; | ||
r.move_jp(goal).wait(); | ||
|
||
fprintf('--> Time for the full trajectory: '); | ||
toc | ||
|
||
% now with "busy" loop | ||
disp('--> Testing the trajectory with busy loop') | ||
|
||
counter = 0; | ||
|
||
tic; | ||
|
||
% first motion | ||
goal(1) = initial_position + amplitude; | ||
handle = r.move_jp(goal); | ||
while handle.is_busy() | ||
counter = counter + 1; | ||
fprintf('%g ', counter); | ||
end | ||
|
||
% second motion | ||
goal(1) = initial_position - amplitude; | ||
handle = r.move_jp(goal); | ||
fprintf('\n'); | ||
while handle.is_busy() | ||
counter = counter + 1; | ||
fprintf('%g ', counter); | ||
end | ||
|
||
% third motion | ||
goal(1) = initial_position; | ||
handle = r.move_jp(goal); | ||
fprintf('\n'); | ||
while handle.is_busy() | ||
counter = counter + 1; | ||
fprintf('%g ', counter); | ||
end | ||
|
||
fprintf('\n'); | ||
|
||
fprintf('--> Time for the full trajectory: '); | ||
toc | ||
|
||
fprintf('--> You can change the trajectory velocity in the GUI using "%s", "Direct control" and lower the "100%%" factor. Then re-run this program.\n', ... | ||
arm_name) | ||
|
||
% don't forget to cleanup | ||
disp('---- Delete arm class'); | ||
delete(r); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters