-
Notifications
You must be signed in to change notification settings - Fork 312
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
base: master
Are you sure you want to change the base?
Add GPS semantic component #2000
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
public: | ||
explicit GPSSensorWithCovariance(const std::string & name) : GPSSensor(name) | ||
{ | ||
interface_names_.emplace_back(name + "/" + "latitude_covariance"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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, ..
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. |
@christophfroehlich I added service filling in the PR |
controller_interface/include/semantic_components/gps_sensor.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
There was a problem hiding this 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
165c3c3
There was a problem hiding this 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> |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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()); } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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>
andGPSSensor<GPSSensorOption::kWithoutCovariance>
Feel free to use better class and enum names.
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.