MRPT / GSoC2017-discussions

See README
1 stars 0 forks source link

MVSim development (Borys Tymchenko) #2

Closed jlblancoc closed 6 years ago

jlblancoc commented 7 years ago

Initial description:

Many contemporary robotic applications need precise simulation and prognosing of system dynamics. Making a lightweight application that is tailored to analysis of vehicle dynamics and accurate simulation of typical robot will allow developers simple workflow with simulated robotics systems.

See attached PDF. 4899176547614720_1491160723_GSoCMultiplevehiclesimulator.pdf

Code results:

spsancti commented 6 years ago

Hi, all. I wasted two days with problems of mrpt-matlab binding and matlab's shared libraries. When I try to generate cmake with BUILD_MATLAB flag, I'm getting into a lot of warnings about implicit directories: https://pastebin.com/0fpGQWkY . However, configuration step is fine.

If I ignore it, it results to undefined references on build. I tried clean install of mrpt and matlab and also some advice from internet. When I try to pass matlab libs to make with LD_LIBRARY_PATH it seems to build but wit a lot of warnings and finally crashes: https://pastebin.com/LqjzPUD6

The only possibly working solution I found is to remove system copy of libraries and use matlab's ones. But this will ruin my other projects because of different versions.

Is there any proven solution for this issue?

spsancti commented 6 years ago

Well, I wasted 1.5 days more with no solution. I even tried to install it to completely clear OS with the same result. For now, I'll abandon this for some time and continue with physical model and logs in order to test it altogether when there will be a solution.

spsancti commented 6 years ago

@jlblancoc @torresmoreno @FranciscoJManasAlvarez Don't you have any notion?

torresmoreno commented 6 years ago

We have been exploring the possibility of using the ROS toolkit for Matlab in Ubuntu OS. As soon as we have any news on this regard, we will let you know. In the meanwhile, it would be nice if you define an experiment, export the dataset and compare with the planar model which we talk about from the Matlab tutorials.

jlblancoc commented 6 years ago

@spsancti I'm sorry to see all the problems you are having with MRPT-MATLAB bindings !! I'm installing it in Linux so I can try to reproduce the problem. @jbriales was the main author of the MEX bindings. @jbriales, don't waste more than 2 minutes on this but: did you remember having problems compiling & linking like these ones?? Any quick advice?

For now, I'll abandon this for some time and continue with physical model and logs in order to test it altogether when there will be a solution.

Great. Having accurately timestamped logs will be a great start to do some plots and think about whether the simulated forces/velocities/... make sense.

jlblancoc commented 6 years ago

@spsancti It's far from ideal but... could you give it a try with MRPT built a static libs instead of shared libs? Turn BUILD_SHARED_LIBS off in CMake.

jbriales commented 6 years ago

Hi there! Well, about the bindings, the kind of problems I'm seeing here don't look unfamiliar at all. Unfortunately it's been a while since the last time I worked with them but, the main issues I remember in general with compiling with support for Matlab were:

Then, in general, I would say interfacing with Matlab at this low-level gets really messy :S From my point of view, the worst part is the code is closed, and you have no way to know what's failing in there. The official support if you write to them is fairly good, but still not enough. Debugging this can get tiresome.

Then, I would ask: How important is it binding with Matlab within this project? If it's essential, I would consider the ROS toolbox. I haven't tried it myself, but I think that should be the most Matlab-native way to interface with MRPT nowadays, through ROS. Otherwise, I got my solution to work in the day... I have often wondered if there are cleaner approaches. For example, there are Matlab bindings for OpenCV and I think those work OK... So they should be a good reference. Lastly, if you want to keep trying with the current bindings I developed (unfortunately, I would discourage this if you have a tight timetable), I might try and look for some notes I might have written down when facing those issues you mention. On the other hand I'm about to take a plane and will be out for two weeks, so my availability will be quite reduced.

Final remark: Comments above are general about the bindings. Then, looking with more detail onto your compilation logs, I would say I would try substituting the conflicting libraries in Matlab bin by symlinks to your system libraries. If that doesn't break Matlab, it might work. It's not very elegant, but I remember having done this.

jbriales commented 6 years ago

I looked into my notes, and looking at your errors, I confirm the problem must be in conflicts between system and Matlab libraries. As I said, this is not elegant and maybe someone comes up with a better solution but my approach which seemed to work:

Let me know if you have doubts regarding this approach, and best of luck!

jlblancoc commented 6 years ago

Thanks @jbriales !! :+1:

@spsancti I have confirmed that building with BUILD_SHARED_LIBS=ON works (despite the warnings about the nasty duplicated libs that come with MATLAB... sigh). I also had to make small changes to the master branch to fix compilation, so please remember updating your local copy of MRPT. By the way, if you have not done it until now, this will be the first time mvsim is built against MRPT 2.0 (1.9.9 actually for now), so please read this on how to port the code. It's easy, but come back if you have doubts.

Give MEX a try for 1-2 more days to see if you can get it to work: 1st, the simplest example, an empty MEX class that just prints a message to console or something alike. When that works, just creating an mrpt object and testing that it works; then creating an mrtp::gui::CDisplayWindow to see if windows open without problems. If all that work, there are chances that we're finally on the right track.

Othewise, we might have to forget about MEX and focus on a simpler ROS-based interface between mvsim and matlab. But I would prefer a direct MEX interface not to force users to launch an entire ROS system (and think of Windows users!) just to use one simulator...

Cheers.

spsancti commented 6 years ago

Hi all, I was able to compile MRPT with matlab using dirty hacks with libraries. I substituted Matlab's opencv with mine one (also, in cmake I set system opencv_DIR instead of Matlab), and some additional things too. It looks not that reliable but at least it compiles.

Also, fixed improper namespace and std::thread usage in mex/apps/mex-test/mex_test.cpp @jbriales @jlblancoc Don't you have any quick start guide how to add this into matlab? I tried (not so long) to run mexgrabber example and got this: https://pastebin.com/ansZJvKA Will go further at weekend.

spsancti commented 6 years ago

Hi all! Made mex-grabber to launch, got crashes and freezes at every time I launch script.

Spent some time and got achievement unlocked: "Make matlab spit out log before crash"! And it has another linking problems: https://pastebin.com/PU6atDhy It is (likely) caused by my libraries substitution. It looks like matlab is not that compatible with my system libraries. I also tried to install the same version of opencv as matlab's and recompile everything but with the same result in matlab.

@jbriales @jlblancoc As to me, we'd better switch to the matlab ROS node. I hope, there wouldn't be so many problems.

I am going to port mvsim to the new MRPT version, expecting to spend 1-2 days here.

spsancti commented 6 years ago

@raghavendersahdev , why did you reference this issue?

raghavendersahdev commented 6 years ago

sorry i wanted to write # 2 in my comments and wrote it without space so by mistake I referenced it unknowingly, my bad..!!

jbriales commented 6 years ago

Hi! Well, I understand the frustration here. I remember I got a lot of freezings and crash-ups until I got it work. Then, I agree with jlblancoc it would be preferable to avoid ROS as a bridge, if MEX works. But then, I'm also afraid that unless we come into a clearer understanding of why it fails, and how to make it work in a straightforward way (without tampering with the libraries), this is not very appropriate for off-the-shelf usage.

Unfortunately I cannot do much more as I'm still in a conference, until 4th of August.

Best, Jesus

On 24 July 2017 at 22:39, Borys Tymchenko notifications@github.com wrote:

Hi all! Made mex-grabber to launch, got crashes and freezes at every time I launch script.

Spent some time and got achievement unlocked: "Make matlab spit out log before crash"! And it has another linking problems: https://pastebin.com/PU6atDhy It is (likely) caused by my libraries substitution. It looks like matlab is not that compatible with my system libraries. I also tried to install the same version of opencv as matlab's and recompile everything but with the same result in matlab.

@jbriales https://github.com/jbriales @jlblancoc https://github.com/jlblancoc As to me, we'd better switch to the matlab ROS node. I hope, there wouldn't be so many problems.

I am going to port mvsim to the new MRPT version, expecting to spend 1-2 days here.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MRPT/GSoC2017-discussions/issues/2#issuecomment-317547267, or mute the thread https://github.com/notifications/unsubscribe-auth/AGiHrm0A5nV7xbmj9xgfIoLN2ENHh7Iqks5sRQDkgaJpZM4NRWUc .

--

Jesus Briales

PhD Student in Computer Vision Mapir-UMA group http://mapir.isa.uma.es University of Malaga Malaga, Spain

http://mapir.isa.uma.es/jbriales

spsancti commented 6 years ago

Hi, Nothing special happened, just porting mvsim...

@jbriales Let's cooperate to investigate the matlab troubles when you will have time.

Sincerely, Borys.

jlblancoc commented 6 years ago

@spsancti Thanks for your time spent debugging that ugly, underneath world, of MATLAB and its entire copy of all system libraries... (screw good practices, yeah!!) (sigh).

Ok. Let's be practical: let's move to MATLAB's ROS toolkit to interface mvsim from matlab. The bright side is... that will enforce the current ROS API. Probably you'll need to add tons of new topics, add ROS services, etc.

BTW: Any progress with generating the text log files to do some plots of wheel forces? (In the standalone version of the app, I mean).

Keep up the hard work!

spsancti commented 6 years ago

Hi, @jlblancoc I will finish posrting mvsim to new mrpt and the go digging into ROS. Hope, It will be more simple than Matlab :D

Text loger works, here is a basic usage example with QtiPlot: image

jlblancoc commented 6 years ago

Hi,

Text loger works, here is a basic usage example with QtiPlot:

Good! Could you please add details on how to generate those logs, and the meaning of each variable, to the LaTeX document? Also, are forces being logged as well? (I think I can't see them in this particular screenshot...)

We also have quickly reviewed the rest that document and have more comments on it. Will write them directly as GH comments on your fork, you'll receive notifications on them.

Cheers,

jlblancoc commented 6 years ago

Well, I would better let you know here the comments on the "user_manual":

All for now!

spsancti commented 6 years ago

Hi, @jlblancoc Thanks for your review of documentation. I will fix it today evening. Also, I'll add info about loggers there. About my notes nothing interesting here - I'm writing them with regard to the current code. When I write something, I'll update it.

spsancti commented 6 years ago

Hi @jlblancoc ,

I finished porting mvsim to the new MRPT. BTW, I ported mrpt-navigation (that was easier).

This took so long because I fell under the spell of the impostor syndrome thinking that only my code can be a failure. However, there is a problem in MRPT related to fail in initializing of graphical system (freeze on startup) and segmentation fault on click into window. I spent 4 days debugging this issue thinking that I did something wrong. After it, I noticed the commit "b8583fb ("workaround to wx crash", 2017-07-30)" and checked out to "fc9d4d0 ("BUGFIX: fix incorrect evaluation of "ASSERT" formulas in CMultiObjectiveMotionOptimizerBase", 2017-07-27)" where everything works properly.

Tomorrow I will recompile MRPT to get details and create an issue dedicated to this problem. Also, I updated documentation as you asked.

Sincerely, Borys.

jlblancoc commented 6 years ago

Your changes to port mvsim to MRPT 2.0 have been merged (thanks!!); I also added the corresponding link to the top comment on this page, with the idea of leaving this ticket as the URL you can submit as "the result page" in final GSoC forms.

spsancti commented 6 years ago

Hi @jlblancoc ! I ported mrpt-navigation to check model, please, check out my PR. I also screwed a bit with freezing bug in master, nothing suitable found. I will base my work on fc9d4d0 now so not to waste time anymore.

jlblancoc commented 6 years ago

Hi @spsancti ! How are you doing?

I wondered if you made progress with the points raised in these two past comments:

Cheers

spsancti commented 6 years ago

Hi, @jlblancoc ! I'm fine, the work is going. I've rewritten loggers because previously I selected somewhat wrong architecture. Previous design had sufficient flaw when some loggers couldn't be triggered to write from GUI. Fixed documentation is at branch f-documentation, I'll add info on new loggers today.

I'm a bit out of schedule with Ackermann differential but I hope, I'll finish it till Friday.

Sincerely, Borys.

spsancti commented 6 years ago

Hi, @jlblancoc ! I realized that I totally forgot to create pull requests for my features :confused: Please, review them and merge if possible.

BTW, what will be the format of my GSoC summary? Are there any guidelines to do it in MRPT?

Sincerely, Borys.

spsancti commented 6 years ago

Hi, @jlblancoc ! Here is my implementation of open and Torsen differentials for Ackermann steered robots.

It supports front, rear and 4WD with configurable split and bias settings.

It doesn't include the engine model and influence of tire forces on the engine - so it doesn't support engine braking yet.

I also changed PID controller to velocity form with anti-windup to reduce integral lag if the robot was stalled and then changed direction.

Tomorrow I'll prettify code, shape up docs and write my final summary.

Sincerely, Borys.

jlblancoc commented 6 years ago

Hi,

we'll review your PRs asap.

For your final submission, normally we recommend students to submit this very same page URL as the "link" Google asks you for, since it reflects all your work during this time.

I normally edit the first comment to list your code contributions via a list of pull-requests. Let me know if I miss some of them....

jlblancoc commented 6 years ago

I would prefer that, instead of 3 PRs, you could please do the following:

spsancti commented 6 years ago

Hi, @jlblancoc ! Here is my compound pull request for mvsim. There is some mess with commits dates because I needed to rewrite history a bit :confused:

Could you please also add my contribution to mrpt-navigation to the header comment?

At the moment, can I already complete my evaluation with a link to this page?

P.S. I tried my Torsen drive with elevation mesh and there is really great difference in robot's climbing ability. Maybe, I should create a video of it? Sincerely, Borys.

jlblancoc commented 6 years ago

Great! Yes, you can use this page as summary link. I'll update the first comment.

jlblancoc commented 6 years ago

@spsancti I added the 3 PRs to the header. Let me know if I missed anything else...

spsancti commented 6 years ago

Hi, @jlblancoc ! The final countdown is on its way, just wanted to say that it was a good time of coding for me.

BTW, I started to implement 8x8 truck scheme as this one, it must be an elevation-map-king!

Sincerely, Borys.

jlblancoc commented 6 years ago

Hi @spsancti ! We just finished your final evaluation in GSoC... it was a pleasure to count with your participation in this project 👍

There were some things we tried and wasn't successful, but I know you tried it really hard, so it's ok. Hope you will be willing to keep collaborating after the GSoC period... feel free of opening new PRs ;-) I will also mention you (in the main project repo) if I find new issues related to your contribution so you can provide feedback on them, ok?

Cheers!