Skip to content

Commit

Permalink
fix(components): add missing test case (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
domire8 authored Dec 9, 2024
1 parent dec18cd commit b378d9a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Release Versions:
- feat(controllers): add TF broadcaster in BaseControllerInterface (#170)
- test(controllers): add TF listener and broadcaster tests (#172)
- feat(components): get clproto message type from attribute (#175)
- fix(components): add missing test case (#181)

## 5.0.2

Expand Down
3 changes: 2 additions & 1 deletion source/modulo_components/test/python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def publish(self):

component = component_type("minimal_sensor_output")
component._output = random_sensor
component.add_output("sensor_state", "_output", JointState, default_topic=topic, publish_on_step=publish_on_step)
component.add_output("sensor_state", "_output", JointState,
default_topic=topic, publish_on_step=publish_on_step)
component.publish = publish.__get__(component)
return component

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ def test_input_output_manual(ros_exec, make_lifecycle_change_client, random_pose
assert random_pose.dist(minimal_cartesian_input.input) < 1e-3


@pytest.mark.parametrize("minimal_sensor_input", [[LifecycleComponent, "/topic"]], indirect=True)
@pytest.mark.parametrize("minimal_sensor_output", [[LifecycleComponent, "/topic", False]], indirect=True)
def test_input_output_manual_sensor(
ros_exec, make_lifecycle_change_client, random_sensor, minimal_sensor_output, minimal_sensor_input):
input_change_client = make_lifecycle_change_client("minimal_sensor_input")
output_change_client = make_lifecycle_change_client("minimal_sensor_output")
ros_exec.add_node(input_change_client)
ros_exec.add_node(output_change_client)
ros_exec.add_node(minimal_sensor_input)
ros_exec.add_node(minimal_sensor_output)
input_change_client.configure(ros_exec)
output_change_client.configure(ros_exec)
input_change_client.activate(ros_exec)
output_change_client.activate(ros_exec)
ros_exec.spin_until_future_complete(minimal_sensor_input.received_future, timeout_sec=0.5)
assert not minimal_sensor_input.received_future.done()
minimal_sensor_output.publish()
ros_exec.spin_until_future_complete(minimal_sensor_input.received_future, timeout_sec=0.5)
assert minimal_sensor_input.received_future.done() and minimal_sensor_input.received_future.result()
for key in random_sensor.get_fields_and_field_types().keys():
assert getattr(random_sensor, key) == getattr(minimal_sensor_input.input, key)


@pytest.mark.parametrize("minimal_cartesian_input", [[LifecycleComponent, "/topic"]], indirect=True)
@pytest.mark.parametrize("minimal_joint_output", [[LifecycleComponent, "/topic", True]], indirect=True)
def test_input_output_invalid_type(ros_exec, minimal_joint_output, minimal_cartesian_input):
Expand Down
1 change: 0 additions & 1 deletion source/modulo_controllers/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

<depend>controller_interface</depend>
<depend>hardware_interface</depend>
<depend>kdl_parser</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
Expand Down

0 comments on commit b378d9a

Please sign in to comment.