Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ros publishers #103

Merged
merged 19 commits into from
Oct 10, 2019
Merged

Feature/ros publishers #103

merged 19 commits into from
Oct 10, 2019

Conversation

rikba
Copy link
Collaborator

@rikba rikba commented Oct 9, 2019

Towards cpp driver #102 .

Goal of this PR is to simplify creation of new callbacks and differentiate between GPS receivers.

This PR introduces

  • factories for receiver types (base station, position, attitude)
  • factories for sbp callbacks (e.g. heartbeat)

A receiver owns a hardware device and multiple sbp callbacks.

The ROS node now (auto) creates and processes all receivers.

@rikba rikba requested a review from michaelpantic October 9, 2019 05:48
@rikba rikba requested a review from marco-tranzatto as a code owner October 9, 2019 05:48
Copy link
Member

@michaelpantic michaelpantic left a comment

Choose a reason for hiding this comment

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

Hmm, I think a few anti-patterns creeped in :-), see comments.

Maybe we should have a look at what type of output we actually have, so that we know how to group these callbacks - I already have an idea how to make it easy to use, let's discuss today


// This class handles the callback creation for the different piksi message
// types.
class Callback {
Copy link
Member

Choose a reason for hiding this comment

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

Hm there's a few problems with this class. Callback is quite a non-ideal name, as it is not immediately clear what it does (breaks principle of least surprise).

Also I think it is a bit overkill to create a inherited Callback type for each different message. I would rather group them into one class, e.g.having a PositionCallbackHandler that contains all callbacks and publishers to output positions (I think there are quite a few of this). Then maybe a DebugCallbackHandler that contains all callbacks with system states, satelite count etc. and so on.
And then depending on the receiver type, it will contain more or less of these grouped handlers. I think that would make it a bit more readable

Copy link
Collaborator Author

@rikba rikba Oct 9, 2019

Choose a reason for hiding this comment

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

I will address this issue in a separate PR as discussed. We will keep the sbp callback handler base class but
a) Try to allow multiple callbacks per message such that individual callback handlers can be defined for the same sbp callback
b) Create inherited superclasses that summarize behavior of similar callbacks, e.g., position callbacks.
c) Template the callback handlers such that they can automatically process
d) Create a RelayCallback class that handles the simple case of relaying a message and has a 1to1 mapping between sbp_msg_type and callback handler.

piksi_multi_cpp/include/piksi_multi_cpp/device.h Outdated Show resolved Hide resolved
reference receiver and broadcasting the moving baseline (also referred to as
heading). */
enum Type {
kBaseStationReceiver = 0,
Copy link
Member

Choose a reason for hiding this comment

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

Here there is also quite some ambiguity - we have an enum for this, and a class hierarchy. I would do away with the enum and use the class hierarchy only. Any other class using these types doesn't need to know which it is, otherwise it breaks the some separation-of-concern principles

const Type type) {
switch (type) {
case Type::kBaseStationReceiver:
return std::shared_ptr<Receiver>(new ReceiverBaseStation(nh, device));
Copy link
Member

Choose a reason for hiding this comment

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

Hm, this creates a sort of circular dependency, as Receiver needs to know all its child types, and the child types need to know Receiver for inheritance

@rikba rikba mentioned this pull request Oct 9, 2019
23 tasks
@rikba rikba merged commit 2a5f82b into master Oct 10, 2019
@rikba rikba deleted the feature/ros_publishers branch October 10, 2019 07:19
This was referenced Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants