Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c9e84a7
[DQ_JointType] Added a new class to represent the joint types.
juanjqo May 14, 2025
f05192d
[DQ_JointType.h] Updated the class to support switch and boolean comp…
juanjqo May 14, 2025
edfa46d
[DQ_SerialManipulator.{h,cpp}] Added the _check_joint_types(), and {s…
juanjqo May 14, 2025
69e96ef
[DQ_SerialManipulatorDenso] Added the get_supported_joint_types() method
juanjqo May 15, 2025
4f37b32
[DQ_SerialManipulatorDH.{h,cpp}] Added the get_supported_joint_types(…
juanjqo May 15, 2025
451e7e5
[DQ_SerialManipulatorMDH.{h,cpp}] Added the get_supported_joint_types…
juanjqo May 15, 2025
d08f8b7
[DQ_JointType] Added a new constructor with integer arguments
juanjqo May 15, 2025
5a022bd
[DQ_SerialManipulator.h,cpp] Added a overloaded method for set_joint_…
juanjqo May 15, 2025
b16a05b
[DQ_SerialManipulatorDH.cpp] Updated the constructor to set the joint…
juanjqo May 15, 2025
0e9f452
[DQ_SerialManipulatorMDH.cpp] Updated the constructor to set the join…
juanjqo May 15, 2025
b37dc6a
[DQ_SerialManipulator.cpp] Fixed typo in _check_joint_types()
juanjqo May 16, 2025
4c53d8d
[DQ_SerialManipulatorDenso.cpp] Updated the constructor to set the jo…
juanjqo May 16, 2025
43648c2
[DQ_JoinType.h] Fixed typo in the documentation
juanjqo May 16, 2025
e6cbc37
Merge branch 'dqrobotics:master' into joint_type
juanjqo May 16, 2025
e42603c
[DQ_SerialManipulatorDenso.h] Added missing space in the method defin…
juanjqo May 16, 2025
5f316b2
[DQ_JointType.h] Updated the documentation of the constructors includ…
juanjqo May 16, 2025
9480c65
[DQ_SerialManipulator.h] include the vector header to check if it sol…
juanjqo May 16, 2025
6d5e67f
[DQ_JointType.h, DQ_SerialManipulatorc.pp] Renamed the ToString metho…
juanjqo May 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions include/dqrobotics/robot_modeling/DQ_JointType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
(C) Copyright 2011-2025 DQ Robotics Developers

This file is part of DQ Robotics.

DQ Robotics is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

DQ Robotics is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with DQ Robotics. If not, see <http://www.gnu.org/licenses/>.

Contributors:
1. Juan Jose Quiroz Omana (juanjose.quirozomana@manchester.ac.uk)
- Responsible for the original implementation.
*/


#pragma once
#include <string>

namespace DQ_robotics
{
class DQ_JointType
{
public:
enum JOINT_TYPE{
REVOLUTE = 0,
PRISMATIC,
SPHERICAL,
CYLINDRICAL,
PLANAR,
SIX_DOF,
HELICAL
};
// This definition enables switch cases and comparisons.
constexpr operator JOINT_TYPE() const { return joint_type_; }
private:
JOINT_TYPE joint_type_;

public:
/**
* @brief DQ_JointType Default constructor method.
* This class is based on Table 1 of Silva, Quiroz-Omaña, and Adorno (2022).
* Dynamics of Mobile Manipulators Using Dual Quaternion Algebra.
*/
DQ_JointType() = default;

/**
* @brief DQ_JointType Constructor method.
* This class is based on Table 1 of Silva, Quiroz-Omaña, and Adorno (2022).
* Dynamics of Mobile Manipulators Using Dual Quaternion Algebra.
* @param joint_type The joint type. Example: REVOLUTE, PRISMATIC,
* SPHERICAL, CYLINDRICAL, PLANAR, SIX_DOF, or HELICAL.
*/
DQ_JointType(const JOINT_TYPE& joint_type): joint_type_{joint_type}{};

/**
* @brief DQ_JointType Constructor method that allows integer arguments.
* This class is based on Table 1 of Silva, Quiroz-Omaña, and Adorno (2022).
* Dynamics of Mobile Manipulators Using Dual Quaternion Algebra
* @param joint_type The joint type.
*/
DQ_JointType(const int& joint_type){
switch (joint_type) {
case 0:
joint_type_ = REVOLUTE;
break;
case 1:
joint_type_ = PRISMATIC;
break;
case 2:
joint_type_ = SPHERICAL;
break;
case 3:
joint_type_ = CYLINDRICAL;
break;
case 4:
joint_type_ = PLANAR;
break;
case 5:
joint_type_ = SIX_DOF;
break;
case 6:
joint_type_ = HELICAL;
break;
default:
throw std::runtime_error("Invalid joint type");
}
}

/**
* @brief to_string() converts the DQ_JointType to string.
* @return A string that corresponds to the joint type.
*/
std::string to_string() const {
switch (joint_type_) {

case REVOLUTE:
return std::string("REVOLUTE");
case PRISMATIC:
return std::string("PRISMATIC");
case SPHERICAL:
return std::string("SPHERICAL");
case CYLINDRICAL:
return std::string("CYLINDRICAL");
case PLANAR:
return std::string("PLANAR");
case SIX_DOF:
return std::string("SIX_DOF");
case HELICAL:
return std::string("HELICAL");
default:
throw std::runtime_error("Invalid joint type");
}
}
};

}
17 changes: 15 additions & 2 deletions include/dqrobotics/robot_modeling/DQ_SerialManipulator.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
/**
(C) Copyright 2011-2022 DQ Robotics Developers
(C) Copyright 2011-2025 DQ Robotics Developers

This file is part of DQ Robotics.

Expand All @@ -20,9 +20,15 @@ This file is part of DQ Robotics.
Contributors:
1. Murilo M. Marinho (murilomarinho@ieee.org)
2. Mateus Rodrigues Martins (martinsrmateus@gmail.com)

3. Juan Jose Quiroz Omana (juanjose.quirozomana@manchester.ac.uk)
- Added the joint_types member, and the following methods:
_check_joint_types(), and {set,get}_joint_{type, types}.
*/

#include <dqrobotics/robot_modeling/DQ_Kinematics.h>
#include <dqrobotics/robot_modeling/DQ_JointType.h>
#include <vector>

namespace DQ_robotics
{
Expand All @@ -31,8 +37,9 @@ class DQ_SerialManipulator: public DQ_Kinematics
{
protected:
DQ curr_effector_;

std::vector<DQ_JointType> joint_types_;
DQ_SerialManipulator(const int& dofs);
void _check_joint_types() const;
public:
DQ get_effector() const;
DQ set_effector(const DQ& new_effector);
Expand All @@ -46,6 +53,11 @@ class DQ_SerialManipulator: public DQ_Kinematics
VectorXd get_upper_q_dot_limit() const;
void set_upper_q_dot_limit(const VectorXd &upper_q_dot_limit);

DQ_JointType get_joint_type(const int& ith_joint) const;
std::vector<DQ_JointType> get_joint_types() const;
void set_joint_type(const DQ_JointType& joint_type, const int& ith_joint);
void set_joint_types(const std::vector<DQ_JointType>& joint_types);
void set_joint_types(const VectorXd& joint_types);

//Virtual
virtual MatrixXd raw_pose_jacobian(const VectorXd& q_vec) const;
Expand All @@ -56,6 +68,7 @@ class DQ_SerialManipulator: public DQ_Kinematics
virtual MatrixXd raw_pose_jacobian(const VectorXd& q_vec, const int& to_ith_link) const = 0;
virtual MatrixXd raw_pose_jacobian_derivative(const VectorXd& q, const VectorXd& q_dot, const int& to_ith_link) const = 0;
virtual DQ raw_fkm(const VectorXd& q_vec, const int& to_ith_link) const = 0;
virtual std::vector<DQ_JointType> get_supported_joint_types() const = 0;

//Overrides from DQ_Kinematics
virtual DQ fkm(const VectorXd& q_vec) const override; //Override from DQ_Kinematics
Expand Down
16 changes: 10 additions & 6 deletions include/dqrobotics/robot_modeling/DQ_SerialManipulatorDH.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This file is part of DQ Robotics.

2. Juan Jose Quiroz Omana (juanjqogm@gmail.com)
- Added methods to get and set the DH parameters.
- Added the get_supported_joint_types() method.
*/


Expand All @@ -49,13 +50,16 @@ class DQ_SerialManipulatorDH: public DQ_SerialManipulator
const int& to_ith_link,
const double& parameter);

std::vector<DQ_JointType> get_supported_joint_types()const override;

// Deprecated on 22.04, will be removed on the next release.
enum [[deprecated("Use ? instead.")]] JOINT_TYPES{ JOINT_ROTATIONAL=0, JOINT_PRISMATIC };
[[deprecated("Use ? instead.")]] VectorXd get_thetas() const;
[[deprecated("Use ? instead.")]] VectorXd get_ds() const;
[[deprecated("Use ? instead.")]] VectorXd get_as() const;
[[deprecated("Use ? instead.")]] VectorXd get_alphas() const;
[[deprecated("Use ? instead.")]] VectorXd get_types() const;
enum [[deprecated("Use DQ_JointType instead.")]] JOINT_TYPES{ JOINT_ROTATIONAL=0, JOINT_PRISMATIC };

[[deprecated("Use get_parameters(DQ_ParameterDH::THETA) instead.")]] VectorXd get_thetas() const;
[[deprecated("Use get_parameters(DQ_ParameterDH::D) instead.")]] VectorXd get_ds() const;
[[deprecated("Use get_parameters(DQ_ParameterDH::A) instead.")]] VectorXd get_as() const;
[[deprecated("Use get_parameters(DQ_ParameterDH::ALPHA) instead.")]] VectorXd get_alphas() const;
[[deprecated("Use get_joint_types() instead.")]] VectorXd get_types() const;

DQ_SerialManipulatorDH()=delete;
DQ_SerialManipulatorDH(const MatrixXd& dh_matrix);
Expand Down
10 changes: 8 additions & 2 deletions include/dqrobotics/robot_modeling/DQ_SerialManipulatorDenso.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
/**
(C) Copyright 2021-2022 DQ Robotics Developers
(C) Copyright 2011-2025 DQ Robotics Developers

This file is part of DQ Robotics.

Expand All @@ -17,8 +17,13 @@ This file is part of DQ Robotics.
You should have received a copy of the GNU Lesser General Public License
along with DQ Robotics. If not, see <http://www.gnu.org/licenses/>.


Contributors:
- Murilo M. Marinho (murilomarinho@ieee.org)
1. Murilo M. Marinho (murilomarinho@ieee.org)
- Responsible for the original implementation.

2. Juan Jose Quiroz Omana (juanjose.quirozomana@manchester.ac.uk)
- Added the get_supported_joint_types() method.
*/

#include <dqrobotics/robot_modeling/DQ_SerialManipulator.h>
Expand All @@ -33,6 +38,7 @@ class DQ_SerialManipulatorDenso: public DQ_SerialManipulator

DQ _denso2dh(const double& q, const int& ith) const;
public:
std::vector<DQ_JointType> get_supported_joint_types() const override;

// Deprecated on 22.04, will be removed on the next release.
[[deprecated("Use ? instead.")]] VectorXd get_as() const;
Expand Down
16 changes: 10 additions & 6 deletions include/dqrobotics/robot_modeling/DQ_SerialManipulatorMDH.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This file is part of DQ Robotics.

2. Juan Jose Quiroz Omana (juanjqogm@gmail.com)
- Added methods to get and set the DH parameters.
- Added the get_supported_joint_types() method.
*/

#include <dqrobotics/robot_modeling/DQ_SerialManipulator.h>
Expand All @@ -48,13 +49,16 @@ class DQ_SerialManipulatorMDH: public DQ_SerialManipulator
const int& to_ith_link,
const double& parameter);

std::vector<DQ_JointType> get_supported_joint_types()const override;

// Deprecated on 22.04, will be removed on the next release.
enum [[deprecated("Use ? instead.")]] JOINT_TYPES{ JOINT_ROTATIONAL=0, JOINT_PRISMATIC };
[[deprecated("Use ? instead.")]] VectorXd get_thetas() const;
[[deprecated("Use ? instead.")]] VectorXd get_ds() const;
[[deprecated("Use ? instead.")]] VectorXd get_as() const;
[[deprecated("Use ? instead.")]] VectorXd get_alphas() const;
[[deprecated("Use ? instead.")]] VectorXd get_types() const;
enum [[deprecated("Use DQ_JointType instead.")]] JOINT_TYPES{ JOINT_ROTATIONAL=0, JOINT_PRISMATIC };

[[deprecated("Use get_parameters(DQ_ParameterDH::THETA) instead.")]] VectorXd get_thetas() const;
[[deprecated("Use get_parameters(DQ_ParameterDH::D) instead.")]] VectorXd get_ds() const;
[[deprecated("Use get_parameters(DQ_ParameterDH::A) instead.")]] VectorXd get_as() const;
[[deprecated("Use get_parameters(DQ_ParameterDH::ALPHA) instead.")]] VectorXd get_alphas() const;
[[deprecated("Use get_joint_types() instead.")]] VectorXd get_types() const;

DQ_SerialManipulatorMDH()=delete;
DQ_SerialManipulatorMDH(const MatrixXd& mdh_matrix);
Expand Down
99 changes: 99 additions & 0 deletions src/robot_modeling/DQ_SerialManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ This file is part of DQ Robotics.

Contributors:
1. Murilo M. Marinho (murilomarinho@ieee.org)

2. Mateus Rodrigues Martins (martinsrmateus@gmail.com)

3. Juan Jose Quiroz Omana (juanjose.quirozomana@manchester.ac.uk)
- Added the joint_types member, and the following methods:
_check_joint_types(), and {set,get}_joint_{type, types}.
*/

#include <dqrobotics/robot_modeling/DQ_SerialManipulator.h>
Expand All @@ -40,6 +45,47 @@ DQ_SerialManipulator::DQ_SerialManipulator(const int &dim_configuration_space):
dim_configuration_space_ = dim_configuration_space;
}

/**
* @brief DQ_SerialManipulator::_check_joint_types throws an exception if the joint types are
* different from the supported joints.
*/
void DQ_SerialManipulator::_check_joint_types() const
{
std::vector<DQ_JointType> types = get_joint_types();
std::vector<DQ_JointType> supported_types = get_supported_joint_types();
std::string msg = "Unsupported joint types. Use valid joint types: ";
std::string msg_type;
std::string ps;
size_t k = supported_types.size();
size_t n = types.size();
for (size_t i=0;i<k;i++)
{
msg_type = std::string("DQ_JointType::"+supported_types.at(i).to_string());
if (i==k-1)
ps = std::string(". ");
else
ps = std::string(", ");

msg += msg_type + ps;
}


for (size_t i=0;i<n;i++)
{
bool match = false;
for (size_t j=0;j<k;j++)
{
if (types.at(i) == supported_types.at(j))
{
match = true;
break;
}
}
if (match == false)
throw std::runtime_error(msg);
}
}


int DQ_SerialManipulator::get_dim_configuration_space() const
{
Expand Down Expand Up @@ -97,6 +143,59 @@ void DQ_SerialManipulator::set_upper_q_dot_limit(const VectorXd &upper_q_dot_lim
upper_q_dot_limit_ = upper_q_dot_limit;
}

/**
* @brief DQ_SerialManipulator::get_joint_type returns the joint type of the ith joint.
* @param ith_joint The index to a joint.
* @return The desired ith joint type.
*/
DQ_JointType DQ_SerialManipulator::get_joint_type(const int &ith_joint) const
{
_check_to_ith_link(ith_joint);
return joint_types_.at(ith_joint);
}

/**
* @brief DQ_SerialManipulator::get_joint_types returns a vector containing the joint types.
* @return The desired joint types.
*/
std::vector<DQ_JointType> DQ_SerialManipulator::get_joint_types() const
{
return joint_types_;
}

/**
* @brief DQ_SerialManipulator::set_joint_type sets the joint type of the ith joint
* @param joint_type The joint_type.
* @param ith_joint The index to a joint.
*/
void DQ_SerialManipulator::set_joint_type(const DQ_JointType &joint_type, const int &ith_joint)
{
_check_to_ith_link(ith_joint);
joint_types_.at(ith_joint) = joint_type;
_check_joint_types();
}

/**
* @brief DQ_SerialManipulator::set_joint_types sets the joint types.
* @param joint_types A vector containing the joint types.
*/
void DQ_SerialManipulator::set_joint_types(const std::vector<DQ_JointType> &joint_types)
{
joint_types_ = joint_types;
_check_joint_types();
}

/**
* @brief DQ_SerialManipulator::set_joint_types sets the joint types.
* @param joint_types A vector containing the joint types.
*/
void DQ_SerialManipulator::set_joint_types(const VectorXd &joint_types)
{
for (int i=0;i<joint_types.size();i++)
joint_types_.push_back(DQ_JointType(joint_types(i)));
_check_joint_types();
}

DQ DQ_SerialManipulator::raw_fkm(const VectorXd& q_vec) const
{
_check_q_vec(q_vec);
Expand Down
Loading
Loading