-
Notifications
You must be signed in to change notification settings - Fork 12
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/publish encoder data #334
base: main
Are you sure you want to change the base?
Conversation
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.
Review part 1 (28/39 files viewed)...
uint16_t encoder_1_read_buffer; | ||
raw_processing::read<uint16_t>(ss, encoder_1_read_buffer); | ||
|
||
uint16_t encoder_2_read_buffer; | ||
raw_processing::read<uint16_t>(ss, encoder_2_read_buffer); | ||
|
||
encoder::EncoderData encoder_data; | ||
encoder_data.encoder_1 = toEncoder(encoder_1_read_buffer); | ||
encoder_data.encoder_2 = toEncoder(encoder_2_read_buffer); |
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.
Consider moving those lines to a small function deserializeEncoderData()
, analoguous to IOs/diagnostics.
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 just read in the protocol that the encoder values are sent in reversed byte order (big endian). If I am correct then we have to further convert the values (swap the bytes like e.g. https://stackoverflow.com/questions/3823921/convert-big-endian-to-little-endian-when-reading-from-a-binary-file/3824338#3824338)
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.
Many thanks for the great example, I believe I hit it. Check it carefully and let me know your opinion. See 842f074
standalone/src/data_conversion_layer/start_request_serialization.cpp
Outdated
Show resolved
Hide resolved
standalone/test/include/psen_scan_v2_standalone/util/integrationtest_helper.h
Outdated
Show resolved
Hide resolved
@@ -148,6 +149,7 @@ ScannerConfiguration ScannerAPITests::generateScannerConfig(const std::string& h | |||
.scanRange(DEFAULT_SCAN_RANGE) | |||
.scanResolution(DEFAULT_SCAN_RESOLUTION) | |||
.enableIntensities() | |||
.enableEncoder(ENCODER_ENABLED) |
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 need to include the encoder states in the ScanDataEqual
matcher in matcher_and_actions.h
else they are ignored by the integrationtest_scanner_api
tests.
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.
Solved. Code modified to add the encoder states at ScanDataEqual
. See commit 55257b0
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.
Review part 2
I hope you do not get overwhelmed by my comments. Most of them are minor things.
- Currently one test is failing:
MonitoringFrameDeserializationTest.shouldDeserializeMonitoringFrameCorrectly
. In order to make it work we have to extendWithIntensitiesAndDiagnostics
inudp_frame_dumps.h
with encoder data. - We should also enable the encoders in the test
crcWithIntensities
inunittest_start_request.cpp
, where we need then to find out the newexpected_crc
via wireshark.
...one/include/psen_scan_v2_standalone/data_conversion_layer/monitoring_frame_deserialization.h
Outdated
Show resolved
Hide resolved
uint16_t encoder_1_read_buffer; | ||
raw_processing::read<uint16_t>(ss, encoder_1_read_buffer); | ||
|
||
uint16_t encoder_2_read_buffer; | ||
raw_processing::read<uint16_t>(ss, encoder_2_read_buffer); | ||
|
||
encoder::EncoderData encoder_data; | ||
encoder_data.encoder_1 = toEncoder(encoder_1_read_buffer); | ||
encoder_data.encoder_2 = toEncoder(encoder_2_read_buffer); |
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 just read in the protocol that the encoder values are sent in reversed byte order (big endian). If I am correct then we have to further convert the values (swap the bytes like e.g. https://stackoverflow.com/questions/3823921/convert-big-endian-to-little-endian-when-reading-from-a-binary-file/3824338#3824338)
uint16_t encoder_1_payload = static_cast<uint16_t>(msg.encoderData().encoder_1); | ||
raw_processing::write(os, encoder_1_payload); | ||
|
||
uint16_t encoder_2_payload = static_cast<uint16_t>(msg.encoderData().encoder_2); | ||
raw_processing::write(os, encoder_2_payload); |
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.
Above comment about the byte order also applies here.
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.
Same as #334 (comment). See 842f074
standalone/test/unit_tests/data_conversion_layer/unittest_monitoring_frame_msg.cpp
Show resolved
Hide resolved
standalone/test/unit_tests/data_conversion_layer/unittest_monitoring_frame_msg_stamped.cpp
Show resolved
Hide resolved
|
||
EXPECT_NO_THROW(psen_scan_v2::EncoderState ros_message = toEncoderStateMsg(encoder_state, "some_frame")); | ||
} | ||
|
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.
Please add tests for:
- the ros_message header is set correctly
- the encoder_* fields are set correctly
- an exception is thrown if the supplied time is negative
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 requested three tests added
I agree. Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
…er/encoder_data.h Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
…er/encoder_data.h Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
…on.cpp Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
…er/monitoring_frame_deserialization.h Co-authored-by: Immanuel Martini <35950815+martiniil@users.noreply.github.com>
inline void endswap(T *objp) | ||
{ | ||
unsigned char *memp = reinterpret_cast<unsigned char*>(objp); | ||
std::reverse(memp, memp + sizeof(T)); | ||
} |
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.
- Using a reference instead of a pointer would align better with the rest of the code. Of course you need to change the invocations, too. E.g.
raw_processing::endswap(&encoder_1_read_buffer)
getsraw_processing::endswap(encoder_1_read_buffer)
- We don't abbreviate the names that much, but that is only a suggestion
inline void endswap(T *objp) | |
{ | |
unsigned char *memp = reinterpret_cast<unsigned char*>(objp); | |
std::reverse(memp, memp + sizeof(T)); | |
} | |
inline void endianSwap(T& data) | |
{ | |
unsigned char *dataPtr = reinterpret_cast<unsigned char*>(&data); | |
std::reverse(dataPtr, dataPtr + sizeof(T)); | |
} |
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.
Agree totally, modified and commited in 6f7cfba
Description
These changes Fix # | allow the user to | improve | ...
PR Checklist
Things to add, update or check by the maintainers before this PR can be merged.
Review Checklist
Release planning (please answer)
Hardware tests
Unstrike the text below to enable automatic hardware tests if available. Otherwise use this as a request for the reviewer.
Perform hardware tests