Skip to content

Commit

Permalink
Merge pull request #52 from dqrobotics/issue51
Browse files Browse the repository at this point in the history
Renames VrepInterface to DQ_VrepInterface and fixes issue #51
  • Loading branch information
bvadorno authored Oct 13, 2019
2 parents ad38f5b + 746c64e commit 6378b71
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
28 changes: 12 additions & 16 deletions interfaces/VrepInterface.m → interfaces/DQ_VrepInterface.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% CLASS VrepInterface - Communicate with V-REP using dual quaternions.
% CLASS DQ_VrepInterface - Communicate with V-REP using dual quaternions.
%
% Installation:
% 1) Enable V-REP's remote API on the Server Side:
Expand All @@ -19,7 +19,7 @@
% simulation:
% 1) Open V-REP with the default scene
% 2) Run
% >> vi = VrepInterface();
% >> vi = DQ_VrepInterface();
% >> vi.connect('127.0.0.1',19997);
% >> vi.start_simulation();
% >> pause(1);
Expand All @@ -30,7 +30,7 @@
% helpful to fully understand the documentation.
% http://www.coppeliarobotics.com/helpFiles/en/legacyRemoteApiOverview.htm
%
% VrepInterface Methods:
% DQ_VrepInterface Methods:
% connect - Connects to a V-REP Remote API Server
% disconnect - Disconnects from currently connected server
% disconnect_all - Flushes all Remote API connections
Expand All @@ -49,7 +49,7 @@
% robot
% get_joint_positions - Get the joint positions of a robot
%
% VrepInterface Methods (For advanced users)
% DQ_VrepInterface Methods (For advanced users)
% get_handle - Get the handle of a V-REP object
% get_handles - Get the handles for multiple V-REP objects
%
Expand All @@ -76,14 +76,14 @@
% Contributors to this file:
% Murilo Marques Marinho - [email protected]

classdef VrepInterface < handle
classdef DQ_VrepInterface < handle

properties (Access = private)
% the V-REP remote API instance used by this interface
vrep;
% the client ID of this remote API connection
clientID;
% a map between V-REP object names and VrepInterfaceMapElements
% a map between V-REP object names and DQ_VrepInterfaceMapElements
handles_map;
end

Expand All @@ -107,7 +107,7 @@
handle = obj.handles_map(name).handle;
else
handle = obj.get_handle(name);
obj.handles_map(name) = VrepInterfaceMapElement(handle);
obj.handles_map(name) = DQ_VrepInterfaceMapElement(handle);
end

else
Expand All @@ -123,11 +123,11 @@

methods

function obj = VrepInterface()
function obj = DQ_VrepInterface()
obj.vrep=remApi('remoteApi');
obj.handles_map = containers.Map;
obj.clientID = -1;
disp(['This version of DQ Robotics VrepInterface is compatible'...
disp(['This version of DQ Robotics DQ_VrepInterface is compatible'...
' with VREP 3.5.0']);
end

Expand Down Expand Up @@ -190,7 +190,7 @@ function stop_simulation(obj)
%% >> t = vi.get_object_translation('DefaultCamera');

% First approach to the auto-management using
% VrepInterfaceMapElements. If the user does not specify the
% DQ_VrepInterfaceMapElements. If the user does not specify the
% opmode, it is chosen first as STREAMING and then as BUFFER,
% as specified by the remote API documentation
if nargin <= 2
Expand Down Expand Up @@ -236,7 +236,7 @@ function set_object_translation(obj,handle,t,relative_to_handle,opmode)


% First approach to the auto-management using
% VrepInterfaceMapElements. If the user does not specify the
% DQ_VrepInterfaceMapElements. If the user does not specify the
% opmode, it is chosen first as STREAMING and then as BUFFER,
% as specified by the remote API documentation
if nargin <= 2
Expand Down Expand Up @@ -342,7 +342,6 @@ function set_joint_target_positions(obj,handles,thetas,opmode)
%% >> vi.set_joint_target_positions(joint_names,[0 pi/2 0 pi/2 0 pi/2 0]);

if nargin == 3
obj.vrep.simxPauseCommunication(obj.clientID,1)
for joint_index=1:length(handles)
if isa(handles,'cell')
obj.vrep.simxSetJointTargetPosition(obj.clientID,obj.handle_from_string_or_handle(handles{joint_index}),thetas(joint_index),obj.OP_ONESHOT);
Expand All @@ -351,13 +350,10 @@ function set_joint_target_positions(obj,handles,thetas,opmode)
end

end
obj.vrep.simxPauseCommunication(obj.clientID,0)
else
obj.vrep.simxPauseCommunication(obj.clientID,1)
for joint_index=1:length(handles)
obj.vrep.simxSetJointTargetPosition(obj.clientID,obj.handle_from_string_or_handle(handles{joint_index}),thetas(joint_index),opmode);
end
obj.vrep.simxPauseCommunication(obj.clientID,0)
end
end

Expand All @@ -370,7 +366,7 @@ function set_joint_target_positions(obj,handles,thetas,opmode)
thetas = zeros(length(handles),1);
for joint_index=1:length(handles)
% First approach to the auto-management using
% VrepInterfaceMapElements. If the user does not specify the
% DQ_VrepInterfaceMapElements. If the user does not specify the
% opmode, it is chosen first as STREAMING and then as BUFFER,
% as specified by the remote API documentation
if nargin <= 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
% Contributors to this file:
% Murilo Marques Marinho - [email protected]

classdef VrepInterfaceMapElement
classdef DQ_VrepInterfaceMapElement
properties
% For VREP's remote API, the first call to any "get" function should be OP_STREAMING and the following calls should be
% OP_BUFFER, so we need to track the states of each of them using
Expand All @@ -30,7 +30,7 @@
end
methods
%% Constructor
function obj = VrepInterfaceMapElement(handle)
function obj = DQ_VrepInterfaceMapElement(handle)
obj.set_states_map = containers.Map;
obj.handle = handle;
end
Expand Down
12 changes: 9 additions & 3 deletions robot_control/DQ_PseudoinverseController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@
task_variable = controller.get_task_variable(q);
% get the Jacobian according to the control objective
J = controller.get_jacobian(q);

% calculate the Euclidean error
task_error = task_variable - task_reference;
% compute the control signal
u = pinv(J)*(-controller.gain*task_error + ...
feedforward);
if(controller.damping == 0.0)
u = pinv(J)*(-controller.gain*task_error + ...
feedforward);
else
u = inv(J'*J+controller.damping^2* ...
eye(length(q)))*J'*...
(-controller.gain*task_error + feedforward);
end

% verify if the closed-loop system has reached a stable
% region and update the appropriate flags accordingly.
Expand Down

0 comments on commit 6378b71

Please sign in to comment.