Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions control/gravity_compasation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 Enactic, Inc.
// Copyright 2025-2026 Enactic, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,7 +72,9 @@ int main(int argc, char** argv) {
(arm_side == "left_arm") ? "openarm_left_hand" : "openarm_right_hand";

Dynamics arm_dynamics(urdf_path, root_link, leaf_link);
arm_dynamics.Init();
if (!arm_dynamics.Init()) {
return 1;
}

std::cout << "=== Initializing Leader OpenArm ===" << std::endl;
openarm::can::socket::OpenArm* openarm =
Expand Down
10 changes: 7 additions & 3 deletions control/openarm_bilateral_control.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 Enactic, Inc.
// Copyright 2025-2026 Enactic, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -227,10 +227,14 @@ int main(int argc, char **argv) {
std::vector<double> follower_Fo = follower_loader.get_vector("FollowerArmParam", "Fo");

Dynamics *leader_arm_dynamics = new Dynamics(leader_urdf_path, root_link, leaf_link);
leader_arm_dynamics->Init();
if (!leader_arm_dynamics->Init()) {
return 1;
}

Dynamics *follower_arm_dynamics = new Dynamics(follower_urdf_path, root_link, leaf_link);
follower_arm_dynamics->Init();
if (!follower_arm_dynamics->Init()) {
return 1;
}

std::cout << "=== Initializing Leader OpenArm ===" << std::endl;
openarm::can::socket::OpenArm *leader_openarm =
Expand Down
10 changes: 7 additions & 3 deletions control/openarm_unilateral_control.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 Enactic, Inc.
// Copyright 2025-2026 Enactic, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -228,10 +228,14 @@ int main(int argc, char **argv) {
std::vector<double> follower_Fo = follower_loader.get_vector("FollowerArmParam", "Fo");

Dynamics *leader_arm_dynamics = new Dynamics(leader_urdf_path, root_link, leaf_link);
leader_arm_dynamics->Init();
if (!leader_arm_dynamics->Init()) {
return 1;
}

Dynamics *follower_arm_dynamics = new Dynamics(follower_urdf_path, root_link, leaf_link);
follower_arm_dynamics->Init();
if (!follower_arm_dynamics->Init()) {
return 1;
}

std::cout << "=== Initializing Leader OpenArm ===" << std::endl;
openarm::can::socket::OpenArm *leader_openarm =
Expand Down
5 changes: 3 additions & 2 deletions src/controller/dynamics.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 Enactic, Inc.
// Copyright 2025-2026 Enactic, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,8 @@ bool Dynamics::Init() {
}

if (!kdl_tree.getChain(start_link, end_link, kdl_chain)) {
fprintf(stderr, "Failed to get KDL chain\n");
fprintf(stderr, "Failed to get KDL chain: %s: %s -> %s\n", urdf_path.c_str(),
start_link.c_str(), end_link.c_str());
return false;
}

Expand Down
36 changes: 35 additions & 1 deletion test/control/test_dynamics_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,57 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# The executables must set up the dynamics from the given URDF.
# The executables must stop before they touch any motor when they
# can't set up the dynamics from the given URDF.

# A CAN interface that doesn't exist. An executable that passed the
# dynamics setup fails with CAN_ERROR instead of touching a real one.
CAN_INTERFACE = "openarm-none"
CAN_ERROR = "Failed to initialize socket for interface"


def chain_error(urdf, side):
return (f"Failed to get KDL chain: {urdf}: "
f"openarm_body_link0 -> openarm_{side}_hand")


def test_gravity_comp(run_gravity_comp, write_urdf):
urdf = write_urdf("openarm.urdf", "hand")
result = run_gravity_comp("right_arm", CAN_INTERFACE, urdf)
assert "Failed to get KDL chain" not in result.stdout
assert CAN_ERROR in result.stdout


def test_gravity_comp_no_leaf_link(run_gravity_comp, write_urdf):
urdf = write_urdf("openarm.urdf", "ee_base_link")
result = run_gravity_comp("right_arm", CAN_INTERFACE, urdf)
assert result.returncode == 1
assert chain_error(urdf, "right") in result.stdout
assert CAN_ERROR not in result.stdout


def test_teleop(run_teleop, write_urdf):
urdf = write_urdf("openarm.urdf", "hand")
result = run_teleop(urdf, urdf, "left_arm", CAN_INTERFACE, CAN_INTERFACE)
assert "Failed to get KDL chain" not in result.stdout
assert CAN_ERROR in result.stdout


def test_teleop_no_leader_leaf_link(run_teleop, write_urdf):
leader_urdf = write_urdf("leader.urdf", "ee_base_link")
follower_urdf = write_urdf("follower.urdf", "hand")
result = run_teleop(leader_urdf, follower_urdf, "left_arm",
CAN_INTERFACE, CAN_INTERFACE)
assert result.returncode == 1
assert chain_error(leader_urdf, "left") in result.stdout
assert CAN_ERROR not in result.stdout


def test_teleop_no_follower_leaf_link(run_teleop, write_urdf):
leader_urdf = write_urdf("leader.urdf", "hand")
follower_urdf = write_urdf("follower.urdf", "ee_base_link")
result = run_teleop(leader_urdf, follower_urdf, "left_arm",
CAN_INTERFACE, CAN_INTERFACE)
assert result.returncode == 1
assert chain_error(follower_urdf, "left") in result.stdout
assert CAN_ERROR not in result.stdout
Loading