-
Notifications
You must be signed in to change notification settings - Fork 566
Adding New Kinematics
The supported kinematics are defined in files in folder src/Movement/Kinematics. It is organised as a class hierarchy. Each supported kinematics has its own class definition. For example, class LinearDeltaKinematics supports standard Delta motion kinematics. The class declaration is in file LinearDeltaKinematics.h and the implementation is in file LinearDeltaKinematics.cpp.
-
Use the forum to propose and agree a short name for the new kinematics. You can include hyphens and underscores in the name but they are not significant. You may not include spaces. The short name must be distinct from the name of any existing kinematics supported in any of the standard Duet3D configurations of RepRapFirmware.
-
Create .h and .cpp files to declare and implement the class for your kinematics. This should inherit one of the following base classes:
- If your machine has a conventional Z axis with one or more motors that only affect the Z coordinate, and you want to support bed levelling using multiple independent leadscrews, or the facility to assist users in determining corrections to make to manual bed levelling screws, then you should derive your kinematics class from class ZLeadscrewKinematics.
- Otherwise, if the kinematics dictates that the bed of the printer is normally round, derive it from RoundBedKinematics.
- Otherwise derive it directly from class Kinematics.
- In your kinematics class, declare and define a static Create function. In the class declaration in your .h file declare it like this:
static Kinematics *_ecv_from _ecv_null Create(const char *_ecv_array _ecv_null name, int legacyNumber) noexcept;
In your .cpp file:
/*static*/ Kinematics *_ecv_from _ecv_null MyKinematicsClassName::Create(const char *_ecv_array _ecv_null name, int legacyNumber) noexcept
{
if (ReducedStringEquals(name, "myKinematicsShortName"))
{
return new MyKinematicsClassName();
}
return nullptr;
}
Replace MyKinematicsClassName by your chosen class name and myKinematicsShortName by your agreed short name. Your kinematics will not have a legacy number, so don't worry about that parameter.
- In your kinematics class, declare a static member of type
KinematicsTypeDescriptorin theprivatesection of the class declaration in your .h file and define it in the .cpp file. It should be initialised with yourCreatefunction as parameter, like this:
In your .h file, inside the class declaration:
private:
static KinematicsTypeDescriptor myKinematicsDescriptor;
In your .cpp file:
Kinematics::KinematicsTypeDescriptor MyKinematicsClassName::myKinematicsDescriptor(MyKinematicsClassName::Create);
- In your kinematics class, override virtual functions as needed. See the comments in file Kinematics.h for a description of those functions. In particular you must override the
GetName()function to return the short name of your kinematics, so that it can be found and matched to the value of the M669 K parameter.
It's possible to support multiple different (but related) kinematics in a single kinematics class. If you wish to do that, you will need to change the Create function to recognise multiple short names, to store the actual kinematics being implemented in a class member variable, and to have the GetName function return the name of the kinematics being implemented.
Note: we won't be accepting a further requests to assign kinematics type numbers. Please add your kinematics to the 3.7 source code instead.
-
Tell me the name of your kinematics and ask me (dc42) to allocate a kinematics type number for it, via the Duet3d forum. The kinematics type number will be the K parameter in the M669 command.
-
Create .h and .cpp files to declare and implement the class for your kinematics. This should inherit one of the following base classes:
- If your machine has a conventional Z axis with one or more motors that only affect the Z coordinate, and you want to support bed levelling using multiple independent leadscrews, or the facility to assist users in determining corrections to make to manual bed levelling screws, then you should derive your kinematics class from class ZLeadscrewKinematics.
- Otherwise, if the kinematics dictates that the bed of the printer is normally round, derive it from RoundBedKinematics.
- Otherwise derive it directly from class Kinematics.
-
In your kinematics class, override virtual functions as needed. See the comments in file Kinematics.h for a description of those functions.
-
Modify file Kinematics.cpp by adding a #include directive to include the .h file that declares your new kinematics. Also modify function Create by adding a new case to create an instance of your new kinematics class when the appropriate kinematics type number is passed.
DC updated 2025-07-24.