Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Minor updates for release 2.1: fixes for Python 3, added Matlab examp…
Browse files Browse the repository at this point in the history
…le for `while handle.is_busy()`
  • Loading branch information
adeguet1 committed Aug 6, 2021
1 parent 656f86c commit 36dfc29
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 8 deletions.
88 changes: 88 additions & 0 deletions dvrk_matlab/examples/test_move_wait.m
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
6 changes: 3 additions & 3 deletions dvrk_python/scripts/dvrk_move_wait_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@
handle = arm.move_jp(goal)
while handle.is_busy():
counter = counter + 1
sys.stdout.write('\r-- Loop counter: %d' % (counter))
sys.stdout.write('\r---> Loop counter: %d' % (counter))
sys.stdout.flush()

# second motion
goal[0] = initial_joint_position[0] - amplitude
handle = arm.move_jp(goal)
while handle.is_busy():
counter = counter + 1
sys.stdout.write('\r-- Loop counter: %d' % (counter))
sys.stdout.write('\r---> Loop counter: %d' % (counter))
sys.stdout.flush()

# back to initial position
Expand All @@ -104,4 +104,4 @@
print('')
print('--> Time for the full trajectory: %f seconds' % (time.time() - start_time))

print('--> You can change the trajectory velocity in the GUI using "arm", "Direct control" and lower the "100%%" factor. Then re-run this program.')
print('--> You can change the trajectory velocity in the GUI using "%s", "Direct control" and lower the "100%%" factor. Then re-run this program.' % (args.arm))
4 changes: 2 additions & 2 deletions dvrk_robot/scripts/dvrk_calibrate_potentiometers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Authors: Nick Eusman, Anton Deguet
# Date: 2015-09-24
# Copyright JHU 2015-2020
# Copyright JHU 2015-2021

import time
import rospy
Expand Down Expand Up @@ -254,7 +254,7 @@ def run(self, calibrate, filename):
if arm_type == "PSM":
print("For a PSM, you need to hold at least the last 4 joints in zero position. If you don't have a way to constrain the first 3 joints, you can still just calibrate the last 4. This program will ask you later if you want to save all PSM joint offsets");
input("Press [enter] to continue\n")
nb_samples = 5 * nb_samples_per_position
nb_samples = 2 * nb_samples_per_position
for sample in range(nb_samples):
for axis in range(nb_axis):
average_offsets[axis].append(self._last_potentiometers[axis] * r2d)
Expand Down
6 changes: 3 additions & 3 deletions dvrk_ros.rosinstall
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- git:
local-name: cisst-saw/cisst-ros
uri: https://github.com/jhu-cisst/cisst-ros
version: 2.0.0
version: devel
- git:
local-name: cisst-saw/sawRobotIO1394
uri: https://github.com/jhu-saw/sawRobotIO1394
Expand All @@ -33,11 +33,11 @@
- git:
local-name: crtk/crtk_python_client
uri: https://github.com/collaborative-robotics/crtk_python_client
version: devel
version: 1.0.1
- git:
local-name: crtk/crtk_matlab_client
uri: https://github.com/collaborative-robotics/crtk_matlab_client
version: 1.0.0
version: 1.0.1
- git:
local-name: cisst-saw/sawIntuitiveResearchKit
uri: https://github.com/jhu-dvrk/sawIntuitiveResearchKit
Expand Down

0 comments on commit 36dfc29

Please sign in to comment.