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

Adapt to attached sensor independently of device_family value #27

Merged
merged 14 commits into from
Jan 20, 2025

Conversation

kawk
Copy link
Contributor

@kawk kawk commented Jan 9, 2025

With these changes, the driver can adapt to the attached sensor product variant without making assumptions based just on some numeric value of device_family. It allows to talk to future variants with new, yet unknown device_family values, as long as they support the same commands.

PointCloud and /r2300_header output for R2400-4-layer is enabled based on the presence and value of sensor's layer_count and nonzero layer_inclination parameters. This may be made a user choice in the future. It was based on device_family value before.

This implements and fixes #22

else if (parameter.get_name() == "packet_type")
{
std::string packet_type = parameter.as_string();
if (packet_type == "A" || packet_type == "B" || packet_type == "C" || packet_type == "C1")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it may be necessary to check which packet types a device supports? For example, if an R2000 is connected and C1 arrives here, even though packet type C1 is only supported by the R2300.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PFSDP does not provide information about supported values or ranges. "Checking what a device supports" would require hardcoded knowledge in the driver. It is the purpose of the changes in this branch to eliminate this requirement wherever possible. I'd rather try to improve the forwarding of existing verbose sensor error messages (e.g. "unsupported packet type") to the user instead of duplicating the checks in the driver.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe "Base" should be removed in the name of PFSDPBase (filename, classname) as it is no longer a base class (pfsdp_2000.cpp/h and pfsdp_2300.cpp/h have been removed)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, however, it's not wrong just because there are no derived classes. It the implementation of "base" PFSDP functionality anyway.. I'm afraid that maybe derivatives will be needed again at some time in the future

@@ -8,6 +8,8 @@ struct ScanParameters
bool apply_correction = true;
int sampling_rate_max = 252000;
int scan_time_factor = 1;
int layer_count = 1;
int inclination_count = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is inclination_count really needed? As I understand it, layer_count and inclination_count are always 4 on a R2300. Maybe inclination_count can be omitted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

inclination_count is just a local variable that indicates whether all layer_inclination values are equal (inclination_count=1) or not (inclination_count==layer_count), to decide whether a (3D) PointCloud topic should be published or just (2D) LaserScans. Previously, that decision was made based on device_family value.

I consider this a temporary solution to provide similar behaviour as before, but suggest to rather make PointCloud output user-configurable independently of all device_family, layer_count etc.

@kawk
Copy link
Contributor Author

kawk commented Jan 17, 2025

I've updated the branch so it can be pulled into main as of today (c024981). BTW it also implicitly fixes an issue with the radial_range_max not being updated with info from the sensor because get_scan_params() wasn't called anymore since d3d38b5, which lead to all data appearing invalid

@JnsHndr JnsHndr merged commit 7237089 into PepperlFuchs:main Jan 20, 2025
6 checks passed
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.

Make set driver less dependent on numeric "device_family" and product strings, query protocol info instead
2 participants