Skip to content

Commit

Permalink
Change default joint_state names for single-group
Browse files Browse the repository at this point in the history
Omit the "group_1" part of the message if it is a single group.
  • Loading branch information
jimmy-mcelwain committed Dec 6, 2024
1 parent 0075ad8 commit 59475bd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,12 @@ follow_joint_trajectory:
type: FollowJointTrajectory
default: true
joints:
- group_1/joint_1
- group_1/joint_2
- group_1/joint_3
- group_1/joint_4
- group_1/joint_5
- group_1/joint_6
- joint_1
- joint_2
- joint_3
- joint_4
- joint_5
- joint_6

...
```
Expand Down
6 changes: 4 additions & 2 deletions config/motoros2_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@ namespace_tf: true
# When using a 7 axis robot arm with an elbow joint (E) in the middle of the
# arm, the elbow axis should be listed last (SLURBTE).
#
# DEFAULT: "group_x/joint_y"
# DEFAULT:
# - Single-group: "joint_y"
# - Multi-group: "group_x/joint_y"
#joint_names:
#- [group_1/joint_1, group_1/joint_2, group_1/joint_3, group_1/joint_4, group_1/joint_5, group_1/joint_6]
#- [joint_1, joint_2, joint_3, joint_4, joint_5, joint_6]

#-----------------------------------------------------------------------------
# Logging settings
Expand Down
2 changes: 1 addition & 1 deletion doc/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Refer to [No support for asynchronous motion](../README.md#no-support-for-asynch

## Can names of joints be changed?

The names used by MotoROS2 for joints (in `JointState` messages for instance) by default follow a generic naming scheme: `group_N/joint_M` (with `N` and `M` ∈ ℕ⁺: 1, 2, 3, 4, ...).
The names used by MotoROS2 for joints (in `JointState` messages for instance) by default follow the naming scheme `joint_M` for single-group and `group_N/joint_M` for multi-group (with `N` and `M` ∈ ℕ⁺: 1, 2, 3, 4, ...).

Custom joint names can be configured through the configuration file, specifically the `joint_names` key.
This key is a list-of-lists, with each top-level list corresponding to a group, and each entry inside each list corresponding to the joint in that group.
Expand Down
3 changes: 2 additions & 1 deletion src/ConfigFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

// NOTE: We do not prefix joints by the "motoman Grp ID" here, but use the generic
// group & joint names instead to avoid the OEM-specific names.
#define DEFAULT_JOINT_NAME_FMT "group_%d/joint_%d"
#define DEFAULT_JOINT_NAME_FMT_SINGLE "joint_%d"
#define DEFAULT_JOINT_NAME_FMT_MULTI "group_%d/joint_%d"

#define DEFAULT_LOG_TO_STDOUT FALSE

Expand Down
9 changes: 8 additions & 1 deletion src/ControllerStatusIO.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ BOOL Ros_Controller_Initialize()
{
for (int jointIndex = 0; jointIndex < g_Ros_Controller.ctrlGroups[groupIndex]->numAxes; jointIndex += 1)
{
sprintf(g_nodeConfigSettings.joint_names[(groupIndex * MP_GRP_AXES_NUM) + jointIndex], DEFAULT_JOINT_NAME_FMT, groupIndex + 1, jointIndex + 1);
if (g_Ros_Controller.numGroup == 1)
{
sprintf(g_nodeConfigSettings.joint_names[(groupIndex * MP_GRP_AXES_NUM) + jointIndex], DEFAULT_JOINT_NAME_FMT_SINGLE, jointIndex + 1);
}
else
{
sprintf(g_nodeConfigSettings.joint_names[(groupIndex * MP_GRP_AXES_NUM) + jointIndex], DEFAULT_JOINT_NAME_FMT_MULTI, groupIndex + 1, jointIndex + 1);
}
}
}

Expand Down

0 comments on commit 59475bd

Please sign in to comment.