-
Notifications
You must be signed in to change notification settings - Fork 471
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
Simulink integration #445
Simulink integration #445
Conversation
Including interface files and S-function files to be able to run JSBSim from Simulink. The setup files JSBSimSImulinkCompile and clearSF are also included. A short readme files includes instructions on how to run it in Simulink.
Thanks for the PR @sthelia 👍 As per our discussion I have just pushed a commit (sthelia/jsbsim@d0cf1e2) to your PR to trigger the build of the S-Function by our CI/CD workflow (GitHub Actions). This commit also allows the S-Function to be built along with the JSBSim C++ library: for that you need to pass |
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 your contribution.
There are a number of minor modifications which need to be addressed before merging this PR. Most of them are related to the fact that C++ uses true
and false
for booleans (not 0
and 1
).
If you agree with a suggestion, just press the button Commit suggestion
and GitHub will take care of updating your code on your branch.
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
Co-authored-by: Bertrand Coconnier <[email protected]>
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.
@sthelia I have initiated a new review regarding the problem you have reported about the S-Function not cleaning up after itself.
If you feel more comfortable with a commit review, I have compiled all the changes I am suggesting in bcoconni/jsbsim@0d1410b. Unfortunately, I don't have access to Matlab so you'll have to check yourself whether or not the changes I have suggested allow avoiding calling clearSF.m
after each Simulink run. All I could check with gitHub Actions was that the code compiles successfully and that the example ex737cruise.slx
runs successfully as well.
I might also push the changes directly to your PR: if you prefer so, just let me know.
//fdmExec = 0L; | ||
//JSBSim::~FGFDMExec(); | ||
//delete ic; | ||
delete fdmExec; |
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.
Once you have made FGFDMExec
a member of JSBSimInterface
, you can call delete
on fdmExec
@sthelia Also please include an open source license to all files in this PR otherwise we won't be able to pull them to JSBSim. |
@bcoconni Do someone of us admins have to "Squash and merge" this PR? |
I am currently on vacation and will not have access to my computer until next week - hope to test everything you have suggested then! |
@sthelia No rush 😄 JSBSim has been lacking an S-Function for years, it can still wait for a few more days/weeks ! |
@agodemar If you are eager to test the S-Function code, you can pull the complete code from my fork: bcoconni/jsbsim@0d1410b (branch |
Co-authored-by: Bertrand Coconnier <[email protected]>
What should be included? Is it the copyright text mentioning GNU that is added on top on the other source files? |
Cleaning up some unused functions and implementing suggested changes.
Thank you @bcoconni for the help with the C++ sillyness fixes, I am more than happy to not have to understand why they happen :D I also appreciate the comments to improve and cleanup the code, I am definitely learning a lot from this. |
Well, you've entered the realm of licenses which is always a joy when dealing with a mixture of open source (JSBSim and your code) and proprietary (Matlab) licenses. From what I could gather, you stood on the shoulder of giants 😉 to write this code so we need to give them proper credits:
We also need to ask @podhrmic (Michal Podhradsky) for permission to use his code under the license above since you explicitly mentioned Michal's code as a reference. Finally, Brian Mills also mentioned @agodemar's work (Agostino De Marco) as the source for his original code but I guess this permission should be quite easy to get 😉 @podhrmic and @agodemar, just drop a message below in this PR and I guess this would do as an evidence. Once we've got due permission, you can copy the license term at the top of each file in this PR: /*
Copyright (c) 2009, Brian Mills
All rights reserved.
Copyright (c) 2021, Agostino De Marco, Michal Podhradsky, Tilda Sikström
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ |
Regarding the files that need a license term, I'd say that you can limit yourself to the following non trivial files:
The other files are either build files or trivial files so you can save yourself the trouble of putting a license in them. |
Oh I just saw that @podhrmic gave credit to @EliaTarasov in his repo then we also need Elia's permission. |
You have my permission. All this effort, up to this PR by @sthelia began from my original code back in 2009. |
Feel free to use it, @bcoconni :) |
Hi @bcoconni - you have my permission to use my code:-) |
Alright, the license term is added. Thanks again everyone who developed the code I based this on, I would not have been able to present this pull request without it! |
The PR is merged ! JSBSim now has its official interface with Matlab. |
Simulink integration (JSBSim-Team#445)
This is great news. Thank you @sthelia for your effort! |
Including interface files and S-function files to be able to run JSBSim from Simulink. The setup files JSBSimSImulinkCompile and clearSF are also included. A short readme files includes instructions on how to run it in Simulink. Co-authored-by: Agostino De Marco <[email protected]> Co-authored-by: Elia Tarasov <[email protected]> Co-authored-by: Michal Podhradsky <[email protected]>
I've been working on improving an S-function to be able to integrate JSBSim with Simulink.
I included an example Simulink file of running one of the 737 Scripts. It should work for both Windows and Linux users.