-
Notifications
You must be signed in to change notification settings - Fork 2
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
Sample MATLAB Script (test_rplidar.m) works with A3 but crashes with S1 #3
Comments
In the current state, Step 2 might cause problems if you did not rebuild I just added a GitHub release with some updates and which provides the source code with binaries without For the S1, can you confirm that with |
First of all, thank you again for getting back at this so quick and so thorough. If you have the account, I can buy you a coffee with https://www.buymeacoffee.com/. I just tried the code with the updated binaries ( "the source code with binaries without ENABLE_MAVLINK_SUPPORT, ENABLE_SBG_SDK_SUPPORT, ENABLE_RPLIDAR_SDK_SUPPORT options"). This is what I got from it: S1
Also, is there any way you can explain what the So I tested the various ScanModes in
For the S1 these are the scan modes I have available on windows using |
Thank you for this detailed report. From your screen capture, it seems now logical that only what I call Without If you use the binaries with About the |
I see. Thanks for the explanation. I will try the SDK functionality as well. In the mean time. I was trying to build the repo code with some of the changes we had in the old code (basically a slow and systematic git merge). So after the changes were in place, I did the following:
Looked up the project properties in for linkers and saw there is a I also tried removing the references to the SBG Systems in the Project settings but that didn't do it, it was still looking for that library file. Do you know what I'm doing wrong here to build that project. |
Never mind. It looks like you left a |
The instructions to rebuild should be now in 3rd_support/ReadMe.txt (note that I renamed the folder, previously it was |
Ok I think I got it to work with our code additions/changes merged into your most recent commit of this repo, and in turn running everything using your So the trickiest part for me was to build everything with
In addition, getting MAVLINK and SBG in its right places in the repo gave me some issues, but in the end it seemed like a stupid path issue on my part. |
Hey so here is something I documented for us here to get going with your repo code in Windows x64. As of now this works, but I'm sure there are some things in here that may be unnecessary or even wrong. I'm just adding this here in case someone needs to get going with building this code or making minor changes, and they may not have the greatest knowledge of C/C++ development. How to Build RPLIDAR MATLAB Interface Library on Windows 64-bit SystemSetting up the project
Building
|
Thank you very much for this detailed guide. |
Hey, so I'm having two questions here. I compiled this repo with our slight changes in it, with the pRPLIDAR = CreateRPLIDAR();
[connect_result] = ConnectRPLIDAR(pRPLIDAR, 'RPLIDAR0.txt')
[start_request_result] = StartOtherScanRequestRPLIDAR(pRPLIDAR, 0)
I tried changing function [result] = StartOtherScanRequestRPLIDAR(pRPLIDAR, scanmode)
scanmode_out = libpointer('int32', scanmode)
result = calllib('hardwarex', 'StartOtherScanRequestRPLIDARx', pRPLIDAR, scanmode_out);
end But that didn't seem to make a difference. Another thing. Do you think these are exposable from /// Get all scan modes that supported by lidar
virtual u_result getAllSupportedScanModes(std::vector < RplidarScanMode > &outModes, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
/// Get typical scan mode of lidar
virtual u_result getTypicalScanMode(_u16& outMode, _u32 timeoutInMs = DEFAULT_TIMEOUT) = 0;
/// Start scan
///
/// \param force Force the core system to output scan data regardless whether the scanning motor is rotating or not.
/// \param useTypicalScan Use lidar's typical scan mode or use the compatibility mode (2k sps)
/// \param options Scan options (please use 0)
/// \param outUsedScanMode The scan mode selected by lidar
virtual u_result startScan(bool force, bool useTypicalScan, _u32 options = 0, RplidarScanMode* outUsedScanMode = NULL) = 0; My C++ is not really that good, so I am not sure how to exactly add the Do you think I can use |
About pRPLIDAR = CreateRPLIDAR();
[result] = ConnectRPLIDAR(pRPLIDAR, 'RPLIDAR0.txt')
[result, distances, angles, bNewScan] = GetOtherScanDataResponseRPLIDAR(pRPLIDAR);
str = sprintf('Distance at %f deg = %f m\n', angles(1)*180.0/pi, distances(1));
disp(str);
[result] = DisconnectRPLIDAR(pRPLIDAR)
DestroyRPLIDAR(pRPLIDAR); -> Correction : the previous code won't work without at least a If pRPLIDAR = CreateRPLIDAR();
[result] = ConnectRPLIDAR(pRPLIDAR, 'RPLIDAR0.txt')
% It should be possible to override ScanMode...
pRPLIDAR.value.ScanMode = 0; % or 1 for the S1, up to 4 for the A3...
[result] = GetStartupMessageRPLIDAR(pRPLIDAR)
[result] = StopRequestRPLIDAR(pRPLIDAR)
[result] = SetMotorPWMRequestRPLIDAR(pRPLIDAR, 660)
[result] = StartOtherScanRequestRPLIDAR(pRPLIDAR, pRPLIDAR.value.ScanMode)
pause(2)
[result, distances, angles, bNewScan] = GetOtherScanDataResponseRPLIDAR(pRPLIDAR);
str = sprintf('Distance at %f deg = %f m\n', angles(1)*180.0/pi, distances(1));
disp(str);
[result] = DisconnectRPLIDAR(pRPLIDAR)
DestroyRPLIDAR(pRPLIDAR); About the functions to expose, one of the main difficulty is that they are C++ with classes, which probably cannot be directly exported, however in what I did the C++ is encapsulated in C structures and functions and in the end, the functionalities provided by |
Hey thanks again for the swift response. Very helpful. So I gave the two things you outlined a try and I got the second block of code to work (with the override of scan mode). So it seems to work with the The interesting part is if I set the Scan Mode to 0 in the The only thing that that gives me a return value of 1 is |
Indeed, I expect I just realize that the first block of code (with If the I just made an updated release with an attempt to implement |
So as of now with the One of the things we are adding though is the setting of the Thank you very much for updating the code, exposing those two new functions. I think that will come in very handy here. Again, all this work you are doing is more than appreciated! |
Just to give you an update here. I rebuild the repo and build Everything seems to be working with the S1, the data is coming in with Both I'll go ahead and try it with two S1 lidars and will let you know. |
About the Also, in case you did not know, if you launch MATLAB from Windows command prompt you should see additional debug messages from hardwarex.dll. |
Oh I see. Makes sense now. Thank you for clarifying and pointing it out in the rplidar sdk. I was not paying attention to the spin rate, however it did seem slower than what we usually set it as at Hey thank you for the debugging tip! So we were using that information on linux, where we were starting matlab through the terminal, but honestly I didn't think of doing the same one windows with powershell of command prompt. So on windows we never got those messages from the lidar library. But interestingly enough I did have a @echo off
cls
:: Ensure that any changed variables aren't persistent after restart
setlocal EnableDelayedExpansion
:: Change window title and color
title LIDAR
COLOR 0a
echo [LIDAR START] : Start script
:: Variables
set SCRIPT_DIR=<path to lidar start script directory>
set SCRIPT_M_FILE=<name of the startup script file without the '.m'>
:: Change working directory
echo [LIDAR START] : Changing the working directory to %SCRIPT_DIR% ...
chdir /d %SCRIPT_DIR%
:: Open MATLAB and move on without waiting
echo [LIDAR START] : Starting MATLAB with stript '%SCRIPT_M_FILE%' ...
start matlab -nosplash -nodesktop -r %SCRIPT_M_FILE%
echo [LIDAR START] : This window will close in 15 seconds ...
echo.
timeout 15
exit |
Indeed, I realized that the messages do not appear, so maybe I got them only when testing the Python interface or on another OS. |
Hey thanks again for updating the code. This feature is very useful I think. I'll try to run and test it soon. |
This is the step by step what I did:
Cloned repo
Ran
hardwarex_setup.m
, which generated the proto and thunk filesChanged the provided
RPLIDAR0.txt
configuration file with the settings belowConnected A3 model RPLIDAR. (connected on
COM3
)Using MATLAB, executed
test.rplidar.m
ESC
to close figure and stop the programDisconnect A3 model lidar
Connect S1 model lidar (connected again on
COM3
)Using MATLAB executed
test.rplidar.m
[result, distance, angle, bNewScan, quality] = GetScanDataResponseRPLIDAR(pRPLIDAR)
calllib()
line:result = calllib('hardwarex', 'GetScanDataResponseRPLIDARx', pRPLIDAR, pDistance, pAngle, pbNewScan, Quality)
RPLIDAR0.txt
MATLAB Crash Report:
The text was updated successfully, but these errors were encountered: