Learning notes of the dynamic simulation engine ODE, C # demonstration (1 ),

Source: Internet
Author: User

Learning notes of the dynamic simulation engine ODE, C # demonstration (1 ),

®Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

 

1. Introduction to ODE and platform building.

 

The author came into contact with the dynamic simulation engine because a PLC simulation software required 3D simulation. what I need to achieve is to build common components in the industrial control industry in 3D mode, such as sensors, cylinders, robots, and tension bands. these components are placed in a user combination in the scenario. After relevant attributes are set, the input and output of my PLC simulator program can interact with them to generate 3D simulation results of machine actions.

For example:

The manipulator places the product on the pull belt. The PLC output signal allows the pull belt to rotate in the square direction, and the pull Belt Drives the product to move. If the product type is NG, the PLC will output the signal at the specified position to push the cylinder, push the product to the NG box. if the product is OK, the product goes to the tail of the pull belt and falls into the OK box freely.

 

I refer to some 3d simulation software. When dealing with the above scenario, I use a fixed algorithm to process the interaction between products and machine mechanisms. That is to say, it is not based on real physical simulation. in this way, programming is easier. The disadvantage is that fixed interactive code should be written in every scenario. if you need to add new scenarios, you must write the matching scenario interaction code, which is less universal.

The effect I imagined should be like the configuration software. Each component can set its own attributes and events, or even script code. you only need to combine these components to generate the desired scenario, and then use the PLC program to control the scenario. only the components of the configuration software I have seen are 2D, not the 3D effect I have imagined. in fact, the effect I imagined is actually a 3D effect configuration software.

If these 3D elements can interact with each other after any combination, a dynamic simulation engine must be introduced. return to the scenario I imagined above. the product is placed in the pull belt by the machine hand, which is a joint movement. the product follows the pull belt, which can be achieved by applying a fixed force to the product. the product does not sink in the pull belt because the product and the pull belt are rigid bodies and they interact with each other. the product should go to the end of the pull belt and fall down in a free-body manner. when it falls into the OK product box, because the box is a concave rigid container, the two will collide, the product will not penetrate the box sink.

 

The dynamic simulation Engine is well known as the ODE (Open Dynamics Engine). It looks like a Japanese Open-source and free simulation Engine. I heard that several games also use it for physical simulation.

Of course, this is not the main reason why I pay attention to it. because the development language used by the author is C #, And the OPENGL framework of C # has an ODE library in taoframework. therefore, I decided to start studying ODE. Other dynamic engines won't be taken into consideration.

The applications of OpenGL and dynamic simulation are not really good for C #. Baidu's materials in this field are all in the C ++ world, basically, there is not much C # code for reference. What you can do is to convert C ++ into something. For me, c ++ is a nightmare. I am a software engineer engaged in the industrial control industry. In the past few years, I had a laser thickness gauge code in my hand. Because it was a product of the former engineer, I maintained it for a few years and encountered problems constantly. poor, because it ran countless times to the factory in Zhuhai and dreamed of cursing the broken code. It was tears.

For the industrial control industry, compared with many languages, c # development efficiency is good, so that you can play happily. Another important thing is that it can install B, because it is a language with elegant syntax. pai_^

I plan to write the ODE research results into a series of tutorials, and I feel like I have made a small contribution to my friends who use C # To do the same job.

 

Next, let's talk about how to build the Platform:

First download the latest ode address: http://ode.org/download.html

Decompress the file and open the build folder under the oderoot Directory, which contains premake4.exe.

Open the command line, open the build folder in the command line, and enter: premake4 -- help to view some optional parameters of premake4,

Here I only need to compile with demo, So input premake4 -- with-demos vs2010

In this way, a folder named vs2005 is generated under the build folder. Open the vs2010 folder, and the demo project file and solution file are generated. Open ode. sln and compile it.

There are 40 generated demo routines, but they are all written in C ++. Make sure that your vs2010 has C ++ installed.

It doesn't matter if you don't want to read c ++ code, because my main task is to make the code run in C #. The C # comrades can easily inherit.

I ran a few demos to give you an appreciation. It was a little excited to see the effect. It reminds me of rector in 3dsmax (reactor dynamics ).

This is a rigid-body collision. The ball falls down randomly. Because of the different quality, the force between the ball and the ball is different when the ball falls down. there is friction on the floor, so the ball will eventually rest.

 

A three-wheeled car can also turn and climb. this reminds me of the toyCar in rector in 3dsmax, both of which simulate a car that can run. I remember what I like most at that time was to let the car climb and hit the wall, or pull the root line on its tail, and bind a teapot to drag and run.

 

To be continued .....

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.