22 * @file DataStructures.h
33 * @author Jon Woolfrey
445- * @date April 2025
6- * @version 1.0
5+ * @date July 2025
6+ * @version 1.1
77 * @brief Contains custom structs used in Control classes.
8- *
9- *
10- * @copyright Copyright (c) 2025 Jon Woolfrey
11- *
12- * @license GNU General Public License V3
13- *
14- * @see https://github.com/Woolfrey/software_robot_library for more information.
15- * @see https://github.com/Woolfrey/software_simple_qp for the optimisation algorithm used in the control.
8+ *
9+ * @copyright (c) 2025 Jon Woolfrey
10+ * @license OSCL - Free for non-commercial open-source use only.
11+ * Commercial use requires a license.
12+ 13+ *
14+ * @see https://github.com/Woolfrey/software_robot_library
15+ * @see https://github.com/Woolfrey/software_simple_qp
1616 */
1717
1818#ifndef CONTROL_DATA_STRUCTS_H
@@ -26,34 +26,68 @@ namespace RobotLibrary { namespace Control {
2626/* *
2727 * @brief A data structure for passing control parameters to the SerialLinkBase class in a single argument.
2828 */
29- struct Parameters
29+ struct SerialLinkParameters
3030{
31- // NOTE: These are for the control class itself:
32- Parameters () = default ; // /< This enables default options
31+ SerialLinkParameters () = default ; // /< This enables default options
3332
34- double controlFrequency = 100.0 ; // /< Rate at which control loop operates.
35- double jointPositionGain = 10.0 ; // /< Scales the position error feedback
36- double jointVelocityGain = 1.0 ; // /< Scales the velocity error feedback
37- double maxJointAcceleration = 10.0 ; // /< Limits joint acceleration
33+ double jointPositionGain = 100.0 ; // /< Scales the position error feedback
34+ double jointVelocityGain = 20.0 ; // /< Scales the velocity error feedback
35+ double maxJointAcceleration = 5.0 ; // /< Limits joint acceleration
3836 double minManipulability = 1e-04 ; // /< Threshold for singularity avoidance
3937
40- Eigen::Matrix<double ,6 ,6 > cartesianStiffness = (Eigen::MatrixXd(6 ,6 ) << 10.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ,
41- 0.0 , 10.0 , 0.0 , 0.0 , 0.0 , 0.0 ,
42- 0.0 , 0.0 , 10.0 , 0.0 , 0.0 , 0.0 ,
43- 0.0 , 0.0 , 0.0 , 2.0 , 0.0 , 0.0 ,
44- 0.0 , 0.0 , 0.0 , 0.0 , 2.0 , 0.0 ,
45- 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 2.0 ).finished(); // /< Scales pose error feedback
38+ unsigned int controlFrequency = 500 ; // /< Rate at which control loop operates.
39+
40+ Eigen::Matrix<double ,6 ,6 > cartesianPoseGain = (Eigen::MatrixXd(6 ,6 ) << 10.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ,
41+ 0.0 , 10.0 , 0.0 , 0.0 , 0.0 , 0.0 ,
42+ 0.0 , 0.0 , 10.0 , 0.0 , 0.0 , 0.0 ,
43+ 0.0 , 0.0 , 0.0 , 5.0 , 0.0 , 0.0 ,
44+ 0.0 , 0.0 , 0.0 , 0.0 , 5.0 , 0.0 ,
45+ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 5.0 ).finished(); // /< Scales pose error feedback
4646
47- Eigen::Matrix<double ,6 ,6 > cartesianDamping = (Eigen::MatrixXd(6 ,6 ) << 1 .0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ,
48- 0.0 , 1 .0 , 0.0 , 0.0 , 0.0 , 0.0 ,
49- 0.0 , 0.0 , 1 .0 , 0.0 , 0.0 , 0.0 ,
50- 0.0 , 0.0 , 0.0 , 0.2 , 0.0 , 0.0 ,
51- 0.0 , 0.0 , 0.0 , 0.0 , 0.2 , 0.0 ,
52- 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.2 ).finished(); // /< Scales twist error feedback
47+ Eigen::Matrix<double ,6 ,6 > cartesianVelocityGain = (Eigen::MatrixXd(6 ,6 ) << 20 .0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ,
48+ 0.0 , 20 .0 , 0.0 , 0.0 , 0.0 , 0.0 ,
49+ 0.0 , 0.0 , 20 .0 , 0.0 , 0.0 , 0.0 ,
50+ 0.0 , 0.0 , 0.0 , 2.0 , 0.0 , 0.0 ,
51+ 0.0 , 0.0 , 0.0 , 0.0 , 2.0 , 0.0 ,
52+ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 2.0 ).finished(); // /< Scales twist error feedback
5353
5454 SolverOptions<double > qpsolver = SolverOptions<double >(); // /< Parameters for the underlying QP solver
5555};
5656
57+ /* *
58+ * @brief A data structure for parameters in the feedback control class.
59+ */
60+ struct DifferentialDriveFeedbackParameters
61+ {
62+ DifferentialDriveFeedbackParameters () = default ;
63+
64+ double controlFrequency = 100.0 ; // /< Rate at which control is computed
65+ double minimumSafeDistance = 1.0 ; // /< Used in collision avoidance
66+ double orientationGain = 10.0 ; // /< Feedback gain on orientation error
67+ double xPositionGain = 5.0 ; // /< Feedback gain on x position error
68+ double yPositionGain = 25.0 ; // /< Feedback gain on y position error
69+ };
70+
71+ /* *
72+ * @brief A data structure containing parameters for model predictive control.
73+ */
74+ struct DifferentialDrivePredictiveParameters
75+ {
76+ DifferentialDrivePredictiveParameters () = default ;
77+
78+ double controlFrequency = 100.0 ; // /< Rate at which control is calculated / implemented
79+ double exponent = -0.1 ; // /< Scales the pose error weight across the horizon
80+ double maximumControlStepNorm = 1e-10 ; // /< Threshold for terminating optimisation
81+ double minimumSafeDistance = 1.0 ; // /< Used in collision avoidance
82+ unsigned int numberOfRecursions = 2 ; // /< Number of forward & backward passes to optimise control
83+ unsigned int predictionSteps = 10 ; // /< Length of prediction horizon
84+
85+ Eigen::Matrix3d poseErrorWeight
86+ = (Eigen::MatrixXd(3 ,3 ) << 200.0 , 0.00 , 0.00 ,
87+ 0.0 , 200.00 , -0.09 ,
88+ 0.0 , -0.09 , 0.10 ).finished();
89+ };
90+
5791} } // namespace
5892
5993#endif
0 commit comments