How can I continue simulating a motion with changing parameters in Dymola? - modelica

I am building a model of an elevator and want to simulate its motion from the start point to a settled destination in Dymola. After each simulation, e.g. the elevator has reached one destination. I would like to continue the motion to next position from the previous. In my model a PID-controller has been used, which has two inputs(position of destination and current position). I copy each time the "dsfinal" output file and define it as the "dsin" input file as starting conditions for next time. But the signal of the input, which receives the defined destination position, remembers always the one in the first simulation. It means, the defined value out of PID-controller has been changed, but the value, which eventually goes into the PID-controller remains unchanged. Could someone give a tip, how to solve this problem? Thanks.
PID-controller

I think I didn't fully understand the question, but would it be possible to change from the const block to a block with a non-constant output? From your description I think it would make most sense to use a Modelica.Blocks.Sources.TimeTable and specify the destination position over time.
This way you would not have to start a new simulation and you could get rid the file-copying etc. by just increasing the simulation time and specifying the desired trajectory.

Related

track agent movement in anylogic

I am running a pedestrian simulation in Anylogic and want greater granularity in the agent position information that I get at the end of my model. Currently, I have it set up to show a heat map of traffic density, but I would like to trace the actual position of each agent through its time in the model, like a line or trail.
model visualization at the end of a simulation
[1]: https://i.stack.imgur.com/RwCVo.png
Add a cyclic event into your Pedestrian agent type (you cannot use the default pedestrians but must create your own agent type).
Then, every second (or whatever resolution you need), write the pedestrian coordinates (getX and getY) into a dbase table along with its index.
Then, you can do any post-processing that you need.
PS: typically, this is not really necessary, so make sure you really need this ;)

How to transfer water from cylinder to tank in Dymola?

I've created a Dymola model. It has an empty tank, which is connected to the output of sweptVolume component via a static pipe. Input to the sweptVolume is a constant force, with the help of which I would like to transport water from the hydraulic cylinder to the tank.
I've assumed the cross sectional area of the piston. I've calculated the force that is needed to displace the water in the cylinder assuming the pressure to be atmospheric (101.325kPa). But, somehow I see the water is not getting displaced and the volume is remaining constant without filling the tank.
Please suggest, what type of input should be given for the sweptVolume element (position,move etc.), in case the given input constant force is wrong.
I would like to thank you for your time and interest.
the way to setup initial conditions it is only a matter of GUI, just add "flange(s(start=1, fixed=true))" in add modifiers tab of the sweptVolume parameter dialog in Dymola. To get your model work just invert the sign of the force, the sign convention for the force block is displayed by the arrow, so to compress the piston and fill the tank have to set the const value to minus something. Check the fluid volumes since you will get the model to stop when tank overflows or when piston stroke reaches the end (negative value of s). So you have to setup correctly the forces, or the tank and piston volumes or place some kind of stop to the mechanic part of the piston. The model can work fine even without masses added to the piston.
Hope this helps,
Marco

vpython) How to simulate kepler's 2nd law?

I'm very new to python but I need to simulate kepler's second law through vpython! I've got the orbit going so far but I don't know how to code the sweeping motion and how to code the r, theta etc. Can anyone help?
http://en.wikipedia.org/wiki/File:Kepler-second-law.gif
this is the kind of thing I want to make! Thank you for your help!
I would define an area variable before the loop along with a time interval (bigger than the dt from the loop's iteration). During the loop, add the small bit of area accumulated during that pass through the loop to the area variable (treat it like a triangle or a circular segment) and wait until the time is evenly divisible by the time interval. At that point, print the area, reset the area variable, and keep going. You should get a list of area values, all close to each other. Vary the time interval to take "bigger chunks" of the orbit, which should also all agree with each other.

how to take the feedback for vision based lane keeping control system

I am working on vision based lane detection. My problem is that if we consider this block diagram:
I have done with each block individually but I am confused while connecting them.
Consider for an image, image is taken values are measured by the sensor, error is calculated between reference value and value from sensor then given to pid and then to space state, but according to second block diagram:
The value from space state is taken as feed back and error is calculated. Now I am confused where to take feed back to.
Any help would be highly appreciated.
Judging from your image, the feedback should be input for the PID controller during the next cycle. Either directly or through some function that merges the feedback with the reference.

Implementing a saved ghost for each level in a game

I'm developing a video game for the iPhone. I want each level to save a "ghost" of the best run, just like in Mario Kart.
I've already implemented it, but I used a brute force approach that stores (x, y, rotation) values each frame (60 per second). Needless to say this is very expensive, especially for a mobile device.
I guess I could store the data less often and interpolate when rendering the ghost, but I'm not 100% sure how to do this and if it will look good.
Has anyone done this before? How would you implement it? Is there a standard approach?
Linear interpolation is very easy, if that's what you want. But if the objects you want to interpolate can have non-linear trajectories (from ballistic or lateral accelleration effects) the thing gets more complicated.
The simplest approach would be for you to record the initial position for an object and its movement vector (x,y,z speed, as offsets per time unit). You won't have to record it again for that object until it changes its speed and/or its direction. Then you just record the elapsed time, the new position and the new movement vector (theoretically you don't have to record the position again, just the vectors, but I'd recommend doing so to have a check value - after the program is debugged you can discard it).
Then to playback you place the object at the original position and, for each time frame, add the movement offset to it until it reaches the time for the next recorded position. And so on.