-
Notifications
You must be signed in to change notification settings - Fork 13
Conversion of DQ_SerialManipulator to an abstract class #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updated the file with last Bruno's recommendations.
…pdated the constructor of the class.
…pdated the constructor.
…g the n_links property.
…ing the n_links property.
…an abstract method and defined its concrete version.
…e_jacobian_derivative.
…ing the modified DH convention.
[DQ_SerialManipulator.m] the Fixed error message of the constructor.
[DQ_SerialManipulator.m] Added comments in some lines.
[DQ_SerialManipulatorDH.m] Protected the methods get_w and dh2dq, as in C++.
[DQ_SerialManipulatorDH.m] Added minimal changes in the dh2dq method.
[DQ_SerialManipulator.m] Updated the year of the copyright
[DQ_SerialManipulatorDH.m] Updated the copyright.
|
@dqrobotics/developers Hi @mmmarinho and @bvadorno, Assuming I'm not missing anything, this is the UML design proposed by Murilo. Best regards, Juancho |
|
Hi @bvadorno and @mmmarinho Following our previous discussion, I have a proposal to modify the constructor of the subclasses. Instead of using a cell, we could have two arguments: a 4xn DH matrix and the type of joints. For instance: dh_matrix = [theta; d; a; alpha];
types = repmat(DQ_JointType.REVOLUTE, 1,5); % No casting to double
robot = DQ_SerialManipulatorDH(dh_matrix, types); The key justification is that while a cell might be simple to create in Matlab or (pure) Python, it might be challenging to do so in C++ without using a struct, and, looks like that somethings as structs or raw pointers (raw pointers are being replaced by smart pointers) are not being used in the current implementation of the library in C++, at least for public functions or methods. (@mmmarinho please correct me if I'm wrong). To ensure compatibility with previous versions, the constructor could be (this is a very raw beta implementation) function obj = DQ_SerialManipulatorDH(A, types)
obj.n_links = size(A,2);
str_new = ['DQ_SerialManipulatorDH(A, types), where ' ...
'A = [theta1 ... thetan; ' ...
' d1 ... dn; ' ...
' a1 ... an; ' ...
' alpha1 ... alphan;] ' ...
' ' ...
'types = [DQ_JointType.REVOLUTE ... DQ_JointType.PRISMATIC]'];
switch nargin
case 0
error(['Input: matrix whose columns contain the DH parameters' ...
' and type of joints. Example: ' str_new])
case 1
warning(['DQ_SerialManipulatorDH(A) is deprecated.' ...
' Please use DQ_SerialManipulatorDH(A, types) instead. Example: ' str_new]);
if(size(A,1) ~= 5)
error('Input: Invalid DH matrix. It must have 5 rows.')
end
obj.theta = A(1,:);
obj.d = A(2,:);
obj.a = A(3,:);
obj.alpha = A(4,:);
obj.type = A(5,:);
case 2
if isa( types, 'char') % ex: types = 'standard'
warning(['DQ_SerialManipulatorDH(A, convention) is deprecated.' ...
' Please use DQ_SerialManipulatorDH(A, types) instead. Example: ' str_new]);
if(size(A,1) ~= 5)
error('Input: Invalid DH matrix. It must have 5 rows.')
end
obj.theta = A(1,:);
obj.d = A(2,:);
obj.a = A(3,:);
obj.alpha = A(4,:);
obj.type = A(5,:);
elseif strcmp(class(convention), 'DQ_JointType')
if(size(A,1) ~= 4)
error('Input: Invalid DH matrix. It must have 4 rows.')
end
obj.theta = A(1,:);
obj.d = A(2,:);
obj.a = A(3,:);
obj.alpha = A(4,:);
obj.type = types;
elseif isa(obj.type, 'double')
warning(['bla bla bla. Use DQ_JoinType instead.'])
if(size(A,1) ~= 4)
error('Input: Invalid DH matrix. It must have 4 rows.')
end
obj.theta = A(1,:);
obj.d = A(2,:);
obj.a = A(3,:);
obj.alpha = A(4,:);
obj.type = types;
end
end
end
endCases:
types = double(repmat(DQ_JointType.REVOLUTE, 1,5));
dh_matrix = [theta; d; a; alpha, types];
robot = DQ_SerialManipulatorDH(dh_matrix, 'standard');
types = double(repmat(DQ_JointType.REVOLUTE, 1,5));
dh_matrix = [theta; d; a; alpha, types];
robot = DQ_SerialManipulatorDH(dh_matrix);
dh_matrix = [theta; d; a; alpha];
types = [1 ... 1];
robot = DQ_SerialManipulatorDH(dh_matrix, types);
dh_matrix = [theta; d; a; alpha];
types = repmat(DQ_JointType.REVOLUTE, 1,5); % No casting to double
robot = DQ_SerialManipulatorDH(dh_matrix, types); I think this could be easily implemented in C++/Python. For instance, we could have something like DQ_SerialManipulatorDH(const MatrixXd& dh_matrix, const std::vector<DQ_JointTypes>& types);This proposal make sense or could be useful? what do you think? Best regards, Juancho |
Hi @mmmarinho, It's a sensible strategy. Let's proceed with it. Best wishes, |
Hi @juancho, Let's defer this because we need to focus on @mmmarinho's suggestion. Your solution works, but we need to see if it's necessary, given your motivations, because cells in MATLAB are just a mechanism to store data. Therefore, it suffices to use a container in C++, which is pretty standard, to provide the same functionality as cells. For example, see how to use lists. |
… of abstract ones.
|
No comment on the applicability of the code for now, but a little bit of advice in making it less verbose, if applicable. function obj = DQ_SerialManipulatorDH(A, types)
obj.n_links = size(A,2);
% Maybe explain what this switch aims to achieve and some information about which is legacy
switch nargin
case 0 % No empty constructor
error(['Input: matrix whose columns contain the DH parameters' ...
' and type of joints.'])
case 1 % One argument initialization is deprecated from 23.04
warning(['DQ_SerialManipulatorDH(A) is deprecated.' ...
' Please use DQ_SerialManipulatorDH(A, types) instead.']);
if(size(A,1) ~= 5)
error('Input: Invalid DH matrix. It must have 5 rows.')
end
obj.type = A(5,:);
case 2 % String convention is deprecated since (?)
if isa( types, 'char') % ex: types = 'standard'
warning(['DQ_SerialManipulatorDH(A, convention) is deprecated.' ...
' Please use DQ_SerialManipulatorDH(A, types) instead. Example: ' str_new]);
if(size(A,1) ~= 5)
error('Input: Invalid DH matrix. It must have 5 rows.')
end
obj.type = A(5,:);
elseif strcmp(class(types), 'DQ_JointType')
if(size(A,1) ~= 4)
error('Input: Invalid DH matrix. It must have 4 rows.')
end
obj.type = types;
elseif isa(types, 'double')
warning(['TODO warning. Use DQ_JoinType instead.'])
if(size(A,1) ~= 4)
error('Input: Invalid DH matrix. It must have 4 rows.')
end
obj.type = types;
end
end
obj.theta = A(1,:);
obj.d = A(2,:);
obj.a = A(3,:);
obj.alpha = A(4,:);
end
end |
…pose_jacobian, and raw_pose_jacobian_derivative
…sign proposed by Murilo.
|
Hi @bvadorno, thank you for your feedback. I implemented the new design proposed by @mmmarinho. |
Hi @mmmarinho, thank you for your feedback. Your suggestion is really welcome. The code is less verbose! |
|
@bvadorno I realized that I forgot to update the header of DQ_SerialManipulator, specifically the part describing raw_fkm, raw_pose_jacobian, and raw_pose_jacobian_derivative as abstract methods. |
Hi @juanjqo, Yes, you can. I won't be able to work on this review in the next few hours. Best wishes, |
@bvadorno thanks. I implemented the modifications. The PR is ready to your review. |
[DQ_Kinematics.m] Added the dim_configuration_space protected property. [DQ_SerialManipulatorDH] Added the properties theta,a, d, alpha and updated the constructor of the class. [DQ_SerialManipulatorDH.m] Updated the documentation. [DQ_SerialManipulator.m] Defined the class as an abstract class and updated the constructor. [DQ_SerialManipulator.m] Defined abstract methods. Removed raw_fkm. [DQ_SerialManipulatorDH.m] Removed fkm, which is now in DQ_SerialManipulator. [DQ_SerialManipulator.m] Removed raw_pose_jacobian_derivative. [DQ_SerialManipulator.m] Removed raw_pose_jacobian_derivative. [DQ_SerialManipulatorDH.m] Added the pose_jacobian_derivative. [DQ_Kinematics.m] Removed changes in DQ_Kinematics [DQ_SerialManipulator.m] Removed dim_configuration_space to keep using the n_links property. [DQ_SerialManipulatorDH.m] Removed dim_configuration_space to keep using the n_links property. [ComauSmartSixRobot.m] Updated the robot definition. [DQ_SerialManipulator.m] Defined the raw_pose_jacobian_derivative as an abstract method and defined its concrete version. [DQ_SerialManipulatorDH.m] Modified the name of the method to raw_pose_jacobian_derivative. [DQ_SerialManipulatorMDH.m] Added a concrete class to model robots using the modified DH convention. [CONTRIBUTING.md] Updated the file. Updated the file with last Bruno's recommendations. [DQ_Kinematics.h] Fixed missing semi-colon. [DQ_SerialManipulator.m] the Fixed error message of the constructor. [DQ_SerialManipulator.m] Added comments in some lines. [DQ_SerialManipulatorDH.m] Protected the methods get_w and dh2dq, as in C++. [DQ_SerialManipulatorDH.m] Added minimal changes in the dh2dq method. [DQ_SerialManipulator.m] Removed the convention property and some comments. [DQ_SerialManipulator.m] Updated the year of the copyright [DQ_SerialManipulatorDH.m] Updated the copyright. [DQ_SerialManipulatorMDH] Removed the class. I will add it in a future PR. [DQ_SerialManipulator.m] Updated the documentation. Update CONTRIBUTING.md - Fixed grammar problems across the file. - Added more information about longer commits. [CONTRIBUTING.md] Fixed typos pointed out by Bruno in the contributing diagram [CONTRIBUTING.md] Fixed typos pointed out by Bruno in the contributing diagram [DQ_Kinematics.m] Updated the copyright and the Bruno's email. [DQ_SerialManipulator.m] Removed TODO comments and updated the Bruno's email. [DQ_SerialManipulator.m] Fixed comment according to Bruno's suggestion [DQ_SerialManipulator.m] Fixed comment according to Bruno's suggestion. [DQ_SerialManipulatorDH.m] Fixed error message according to Bruno's suggestion. [DQ_SerialManipulatorDH.m] Added modifications according to Bruno's suggestion [DQ_SerialManipulator.m] Added the dh2dq as an abstract method. [DQ_SerialManipulatorDH.m] Updated the documentation of dh2dq [JointType.m] Created a enumeration class containing type of joints. [DQ_JointType] Implemented the Bruno's suggestions. [DQ_JointType.m] Updated the contributors section according to Murilo's suggestion [DQ_SerialManipulatorDH.m] Updated the header as discussed in #75 [DQ_SerialManipulator.m] Removed the argument of the constructor, as suggested by Bruno. [DQ_SerialManipulatorDH.m] Updated the constructor of the class taking into account the modifications in the superclass. [DQ_SerialManipulatorDH.m] Added the date of some commits. [DQ_SerialManipulatorDH.m] Modified the class to use DQ_JointType [ComauSmartSixRobot.m] Updated the class to use DQ_JointType [ComauSmartSixRobot.m] Updated the website, Bruno's email and the copyright. [ComauSmartSixRobot.m] Fixed the robot definition using the MDH class for serial manipulators. [DQ_SerialManiplator.m] Updated the comments of pose_jacobian and pose_jacobian_derivative according to Bruno's suggestion. [DQ_SerialManipulator.m] Updated the condition of pose_jacobian_derivative. If ith==n_links the effector is not taken into account anymore [DQ_SerialManipulator.m] Modified the if condition in pose_jacobian() Now, when ith==n_links the effector is not taken into account. Revert "[DQ_SerialManipulator.m] Modified the if condition in pose_jacobian()" This reverts commit 4ee9ebd. [DQ_SerialManipulator.m] Removed the abstract method dq2dh(). [CONTRIBUTING.md] Fixed type of font and the color of two words. [DQ_SerialManipulator.m] Removed some lines in the header as requested by Bruno [DQ_SerialManipulator.m] Updated the pose_jacobian_derivative method to match pose_jacobian, as discussed in #75 [DQ_SerialManipulatorDH.m] Fixed the number of the PR to which I contributed. [DQ_SerialManipulatorMDH.m] Added the class to model robots using the MDH parameters. [DQ_SerialManipulatorMDH.m] Updated the header. [DQ_SerialManipulatorMDH.m] Updated the header according to Bruno's suggestion. [DQ_SerialManipulatorMDH.m] Improved the design of the class as requested by Bruno. [DQ_SerialManipulator.m] Added get_w and get_link2dq as protected abstract methods. [DQ_SerialManipulator.m] The raw methods are concrete methods instead of abstract ones. [DQ_SerialManipulatorDH.m] Removed the concrete methods raw_fkm, raw_pose_jacobian, and raw_pose_jacobian_derivative [DQ_SerialManipulatorDH.m] Renamed the method dh2dq. [DQ_SerialManipulatorMDH.m] Updated the class according to the new design proposed by Murilo. [DQ_SerialManipulator.m] Updated the header. [DQ_SerialManipulatorDH.m] Updated the header. [DQ_SerialManipulatorMDH.m] Updated the header. [DQ_SerialManipulator.m] Modified the documentation of raw_fkm as suggested by Bruno. Author: juancho <juanjqogm@gmail.com> Date: Sat Dec 3 16:51:55 2022 +0900

@dqrobotics/developers
Hi @bvadorno,
this PR modifies the classes DQ_SerialManipulator and DQ_SerialManipulatorDH. The following changes are proposed:
DQ_SerialManipulatoris an abstract class now.raw_fkm(),raw_pose_jacobian()andraw_pose_jacobian_derivative()are defined as abstract methods inDQ_SerialManipulatorand they are defined as concrete ones inDQ_SerialManipulatorDH.fkm(),pose_jacobian()andpose_jacobian_derivative()are defined only inDQ_SerialManipulator.Update
Requirements:
DQ_SerialManipulatorMDH()and therefore it is required this modification in matlab-examples.UML diagram:
Blue background with bold text represents modifications or new things.
Final design (proposed by @mmmarinho)
Tasks:
The main goal is to update/sincronize the current version of dqrobotics-matlab with respecto to the C++ version. A lot of things are not sincronized between them yet, but this is the first step.
Best regards,
Juancho