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

Add GPS semantic component #2000

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Wiktor-99
Copy link
Contributor

Adding initial version of GPSSensor semantic components. I decided to add two with covariance interface and w/o interface.

It'll be followed by GPS broadcaster in ros2_controllers.

I'm open too all suggestions.

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.34%. Comparing base (f8c03cc) to head (b4a1ee7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2000      +/-   ##
==========================================
- Coverage   89.35%   89.34%   -0.01%     
==========================================
  Files         130      132       +2     
  Lines       14576    14666      +90     
  Branches     1258     1258              
==========================================
+ Hits        13024    13104      +80     
- Misses       1088     1094       +6     
- Partials      464      468       +4     
Flag Coverage Δ
unittests 89.34% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...terface/include/semantic_components/gps_sensor.hpp 100.00% <100.00%> (ø)
controller_interface/test/test_gps_sensor.cpp 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

public:
explicit GPSSensorWithCovariance(const std::string & name) : GPSSensor(name)
{
interface_names_.emplace_back(name + "/" + "latitude_covariance");
Copy link
Member

@Maverobot Maverobot Jan 13, 2025

Choose a reason for hiding this comment

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

A general question:

Does it make sense to store hard-coded strings in member variables to prevent users from duplicating those strings in their code? Or is this a intended design decision?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was designed that way. It provides the user (e.g., the controller) with an interface ready to use. The member functions of the semantic components are tightly coupled with those strings.

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

The tests look very good. Good job @Wiktor-99

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

I never used GPS in the context of ROS. But having a look at the message definition, shouldn't we add also NavSatStatus to the component?

int8 status
uint16 service

I think this can be useful and every receiver has this as output, but is maybe depending on the used protocol like NMEA, ubx, ..

@Wiktor-99
Copy link
Contributor Author

The status is already there. I'm not sure about service. I don't know if it can be dynamically updated, I'll check it.

@Wiktor-99
Copy link
Contributor Author

@christophfroehlich I added service filling in the PR

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

saikishor
saikishor previously approved these changes Jan 14, 2025
Copy link
Member

@saikishor saikishor 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 going through all the changes. This is good work

LGTM

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

LGTM


#include <array>
#include <string>
#include <vector>
Copy link
Member

@Maverobot Maverobot Jan 16, 2025

Choose a reason for hiding this comment

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

#include <vector> seems to be unused.

#include "hardware_interface/handle.hpp"
#include "hardware_interface/loaned_state_interface.hpp"
#include "semantic_components/gps_sensor.hpp"
#include "sensor_msgs/msg/nav_sat_fix.hpp"
Copy link
Member

@Maverobot Maverobot Jan 16, 2025

Choose a reason for hiding this comment

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

#include <vector> should be added as std::vector is used in this file.

*
* \return Status
*/
int8_t get_status() const { return static_cast<int8_t>(state_interfaces_[0].get().get_value()); }
Copy link
Member

Choose a reason for hiding this comment

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

It would IMHO make sense to add [[nodiscard]] for all those getters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right but then I believe we should add [[nodiscard]] to each semantic component's getters.
Maybe I'll align it the next PR, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Sure. Sounds good.

namespace semantic_components
{

template <bool use_covariance>
Copy link
Member

@Maverobot Maverobot Jan 16, 2025

Choose a reason for hiding this comment

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

I'm not vary familiar with GPS Sensor in general. Are both cases equally often used? If one of them is used more often, you may consider giving use_covariance a default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It really depends, I would leave it as it is.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @Wiktor-99, It is better to leave it as it is. This way the user is conscious about the type is choosing

Copy link
Member

Choose a reason for hiding this comment

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

Fine by me.

namespace semantic_components
{

template <bool use_covariance>
Copy link
Member

@Maverobot Maverobot Jan 17, 2025

Choose a reason for hiding this comment

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

[minor] GPSSensor<true> or GPSSensor<false> is not very good in terms of readability for me personally. You can choose use enum class instead of bool to allow usages like:

  • GPSSensor<GPSSensorOption::kWithCovariance> and GPSSensor<GPSSensorOption::kWithoutCovariance>

Feel free to use better class and enum names.

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.

5 participants