Skip to content

Commit

Permalink
refactor: rename function in modulo translators (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
domire8 authored May 6, 2024
1 parent 4094597 commit dbd3977
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Release Versions:
- feat: improve logging in parameter translators (#65)
- fix(component-interface): make python subscriptions type safe (#71)
- build: change base workspace image version
- refactor: rename function in modulo translators (#77)

## 4.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ inline void safe_spatial_state_conversion(
*/
// FIXME(#77): rename this upon modulo 5.0
template<typename StateT, typename NewStateT>
inline void safe_joint_state_conversion(
inline void safe_state_with_names_conversion(
std::shared_ptr<state_representation::State>& state, std::shared_ptr<state_representation::State>& new_state,
std::function<void(StateT&, const NewStateT&)> conversion_callback = {}
) {
Expand Down Expand Up @@ -296,7 +296,7 @@ inline void read_message(std::shared_ptr<state_representation::State>& state, co
}
case StateType::DIGITAL_IO_STATE: {
if (new_state->get_type() == StateType::DIGITAL_IO_STATE) {
safe_joint_state_conversion<DigitalIOState, DigitalIOState>(
safe_state_with_names_conversion<DigitalIOState, DigitalIOState>(
state, new_state, [](DigitalIOState& a, const DigitalIOState& b) {
a.set_data(b.data());
});
Expand All @@ -307,7 +307,7 @@ inline void read_message(std::shared_ptr<state_representation::State>& state, co
}
case StateType::ANALOG_IO_STATE: {
if (new_state->get_type() == StateType::ANALOG_IO_STATE) {
safe_joint_state_conversion<AnalogIOState, AnalogIOState>(
safe_state_with_names_conversion<AnalogIOState, AnalogIOState>(
state, new_state, [](AnalogIOState& a, const AnalogIOState& b) {
a.set_data(b.data());
});
Expand Down Expand Up @@ -401,22 +401,22 @@ inline void read_message(std::shared_ptr<state_representation::State>& state, co
case StateType::JOINT_STATE: {
auto derived_state = safe_dynamic_pointer_cast<JointState>(state);
if (new_state->get_type() == StateType::JOINT_POSITIONS) {
safe_joint_state_conversion<JointState, JointPositions>(
safe_state_with_names_conversion<JointState, JointPositions>(
state, new_state, [](JointState& a, const JointPositions& b) {
a.set_positions(b.get_positions());
});
} else if (new_state->get_type() == StateType::JOINT_VELOCITIES) {
safe_joint_state_conversion<JointState, JointVelocities>(
safe_state_with_names_conversion<JointState, JointVelocities>(
state, new_state, [](JointState& a, const JointVelocities& b) {
a.set_velocities(b.get_velocities());
});
} else if (new_state->get_type() == StateType::JOINT_ACCELERATIONS) {
safe_joint_state_conversion<JointState, JointAccelerations>(
safe_state_with_names_conversion<JointState, JointAccelerations>(
state, new_state, [](JointState& a, const JointAccelerations& b) {
a.set_accelerations(b.get_accelerations());
});
} else if (new_state->get_type() == StateType::JOINT_TORQUES) {
safe_joint_state_conversion<JointState, JointTorques>(
safe_state_with_names_conversion<JointState, JointTorques>(
state, new_state, [](JointState& a, const JointTorques& b) {
a.set_torques(b.get_torques());
});
Expand All @@ -427,7 +427,7 @@ inline void read_message(std::shared_ptr<state_representation::State>& state, co
}
case StateType::JOINT_POSITIONS: {
if (new_state->get_type() == StateType::JOINT_STATE) {
safe_joint_state_conversion<JointPositions, JointState>(
safe_state_with_names_conversion<JointPositions, JointState>(
state, new_state, [](JointPositions& a, const JointState& b) {
a.set_positions(b.get_positions());
});
Expand All @@ -438,7 +438,7 @@ inline void read_message(std::shared_ptr<state_representation::State>& state, co
}
case StateType::JOINT_VELOCITIES: {
if (new_state->get_type() == StateType::JOINT_STATE) {
safe_joint_state_conversion<JointVelocities, JointState>(
safe_state_with_names_conversion<JointVelocities, JointState>(
state, new_state, [](JointVelocities& a, const JointState& b) {
a.set_velocities(b.get_velocities());
});
Expand All @@ -449,7 +449,7 @@ inline void read_message(std::shared_ptr<state_representation::State>& state, co
}
case StateType::JOINT_ACCELERATIONS: {
if (new_state->get_type() == StateType::JOINT_STATE) {
safe_joint_state_conversion<JointAccelerations, JointState>(
safe_state_with_names_conversion<JointAccelerations, JointState>(
state, new_state, [](JointAccelerations& a, const JointState& b) {
a.set_accelerations(b.get_accelerations());
});
Expand All @@ -460,7 +460,7 @@ inline void read_message(std::shared_ptr<state_representation::State>& state, co
}
case StateType::JOINT_TORQUES: {
if (new_state->get_type() == StateType::JOINT_STATE) {
safe_joint_state_conversion<JointTorques, JointState>(
safe_state_with_names_conversion<JointTorques, JointState>(
state, new_state, [](JointTorques& a, const JointState& b) {
a.set_torques(b.get_torques());
});
Expand Down

0 comments on commit dbd3977

Please sign in to comment.