Skip to content

Conversation

@guilyx
Copy link
Contributor

@guilyx guilyx commented Apr 9, 2022

Purpose

Tired of rewriting code, would probably make it easier on everyone to have something like this ?
Not sure if I'm going in the right direction but it seems to be a nice start for testing ROS2 packages.

Approach

Basically created 4 helper classes:

  • Basic Subscriber
  • Basic Publisher
  • Service Client
  • Action Client

They're all minimal and the purpose is just to test whatever we use them for.

Ex:

  • I create a node that publishes stuff and I want to test it. I just use that common subscriber class and bind it with the right topic name, message type, and I test if the messages received are the one I am sending
  • ... same for the others

Open Questions and Pre-Merge TODOs

  • Fix reference errors
  • Ask @jcmonteiro and @cmraaron if it looks nice
  • Implement feedback callback for action client
  • Add License
  • Add Readme
  • Tests for Action Clients
  • Tests for Service Clients

Dependencies

None

Disclaimers

  • This project should grow from a steady base, if you guys have implementation advice please tell me now so that I don't dive too deep into something that doesn't feel right for everyone 🗡️
  • I still don't know if it makes sense to have Action and Service Servers classes for tests ? EDIT: it does
  • It should probably have Lifecycle Publisher / Subscriber / Services / Actions in there somewhere, but not now.
  • I don't know how this happened tbh, I was writing unit tests for other things and basically copy pasting other unit tests from last week, it triggered me, and now it's midnight on a Saturday 🤪.

Learning

  • Template Classes are painful, but.. I like it ?
  • When creating a Basic****Test object and spinning it, rclcpp needs some time before calling shutdown - which is why there's an ugly sleep after all spins. (wondering if I should put the sleep in the spin_thread method?)

Blog Posts

Erwin Lejeune added 2 commits April 10, 2022 00:49
Disclamer: still have linking errors with undefined references
Copy link
Contributor

@cmraaron cmraaron left a comment

Choose a reason for hiding this comment

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

I'd be interested to see dogfooding of these to see how much complexity they removed from any tests where we'd have to do something similar

Copy link
Contributor Author

@guilyx guilyx left a comment

Choose a reason for hiding this comment

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

There's something I'm unsure about here, I'll test this later.

Copy link
Contributor

@SomaGallai SomaGallai left a comment

Choose a reason for hiding this comment

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

Really cool, could you please a README file just for what is the purpose of the repo and how to properly use it even though it is pretty straight forward.

@guilyx
Copy link
Contributor Author

guilyx commented Apr 14, 2022

Okay, I'm satisfied now with where this is at.

We have wrappers for basic subscribers, publishers, action/service client/server and all of them are tested in the package. I have implemented some of this already in footprint_updater_server and the integration was fairly easy and really simplifying things.

@guilyx guilyx requested a review from cmraaron April 14, 2022 13:57
Copy link
Contributor

@cmraaron cmraaron left a comment

Choose a reason for hiding this comment

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

thanks for you patience!

@guilyx guilyx merged commit 9689314 into galactic_devel Apr 19, 2022
@guilyx guilyx deleted the feature/add-basic-classes branch April 19, 2022 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants