Skip to content

RSDK-13899 - Construct new kinematics on module startup from calibrated DH parameters for ur20 model#206

Open
nfranczak wants to merge 14 commits intoviam-modules:mainfrom
nfranczak:20260428-dh-params-kinematics
Open

RSDK-13899 - Construct new kinematics on module startup from calibrated DH parameters for ur20 model#206
nfranczak wants to merge 14 commits intoviam-modules:mainfrom
nfranczak:20260428-dh-params-kinematics

Conversation

@nfranczak
Copy link
Copy Markdown
Contributor

@nfranczak nfranczak commented May 1, 2026

There is a discrepancy between the TCP pose given to use through GetEndPosition and performing forward kinematics.
We close this discrepancy for the UR20 model.
On module startup we query the arm's controller for the the calibrated DH parameters and construct a brand new kinematics file (SVA type) on the fly which is then served through the GetKinematics endpoint.

TODO:

  • once approved test in lab then in factory again to make sure everything works as expected.


// Per-model static tables. To register a new UR model, add an entry here.
const std::map<std::string, ModelTables>& model_tables() {
static const std::map<std::string, ModelTables> tables = [] {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this PR. Any way we can extract these from know kinematics files?

@nfranczak nfranczak changed the title Construct new kinematics on module startup from calibrated DH parameters RSDK-13899 - Construct new kinematics on module startup from calibrated DH parameters for ur20 model May 5, 2026
@nfranczak nfranczak marked this pull request as ready for review May 5, 2026 19:00
@nfranczak nfranczak requested a review from npmenard May 5, 2026 19:03
Copy link
Copy Markdown
Contributor

@npmenard npmenard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM i think this is good. just ask John/andrew a quick glance about the state machine changes if you haven't done so already
Left a couple of comments but nothing major

const std::shared_lock rlock{config_mutex_};
check_configured_(rlock);

if (!dh_kinematics_json_.empty()) {
Copy link
Copy Markdown
Contributor

@npmenard npmenard May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What i am concerned about is if the arm first sends the default kinematic file and then later the updated one then what happens?
Since we read it during the config phase i think we can't get into this scenario but wanted to check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UR does not change its calibrated DH on the fly, so the kinematics that we build on module startup is valid.

Comment thread src/viam/ur/module/ur_arm.cpp Outdated

if (model_ == URArm::model("ur20")) {
VIAM_SDK_LOG(info) << "Fetching calibrated DH parameters from controller for ur20";
auto kin_info = current_state_->fetch_kinematics_info_();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew is there a chance the configuration is attempted when a connection to the client was not established?

Comment thread src/viam/ur/module/ur_arm.cpp Outdated
}
resp.emplace(k_get_state_description, cached_controlled_info->description);
} else if (kv.first == k_get_calibrated_dh_params) {
auto kin_info = current_state_->fetch_kinematics_info_();
Copy link
Copy Markdown
Contributor

@npmenard npmenard May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should cache the value, they are not expected to change right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will cache

Comment thread src/viam/ur/module/ur_arm_state.cpp Outdated
}
auto kin = primary->getKinematicsInfo();
if (!kin) {
throw std::runtime_error("controller has not delivered KinematicsInfo yet");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it fails transiently?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not but made it bullet proof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants