What is the unit of delta parameter of update() function in cocos2d?
Is it second?
I can't seem to find a doc that says anything about delta.
If you check the API and the documention the delta time is in second.
Related
I am working on a locomotion system for the Aldebaran Nao. I noticed that my robot's motions are very disjoint as compared to those on other robots - a problem that I am pretty sure is code related.
I am updating my robots motions using code similar to Aldebaran's fast get set DCM.
(http://doc.aldebaran.com/1-14/dev/cpp/examples/sensors/fastgetsetdcm/fastgetsetexample.html).
I am updating the joint angles every 10 ms (the fastest possible update rate). However, it is clear that the motors move to the newly commanded angle very quickly and are motionless for the majority of the 10 ms. Is there any way to control the velocity of the motors during this 10ms update period?
There's many way to send order to joints using DCM or ALMotion.
The easiest way is using ALMotion, with that you can use
angleInterpolationWithSpeed, where you'll specify a ratio of speed.
angleInterpolation, where you'll specify a time. In this example 0.01 sec.
Using the DCM, you just have to ask for the movement to finish 10ms later.
The ALMotion and DCM documentation are well wrotten, you should have a look...
I'm implementing FPS style mouselook and keyboard controls.
Using delta-time to mult stuff. And i can choose between delta and raw delta.
What is the difference? About non-raw delta DOCS say, "Might be smoothed over n frames vs raw".
What will i do to my code/game if i choose to use non smooth over smooth?
Since the docs say "Might be smoothed"... now thats not fun, that means a bunch of questions.
I'm looking at differend ways to "smooth" the transforms.
EDIT: I think the real question is that, if smoothed delta is a type of calculation based on raw delta. And while i find some people saying that smooth delta is giving them weird results. Then would i be better of writing my own calculation using raw delta...
What you are asking is not clear.Smoothed delta means that the current delta time is not the real difference from the beginning of the frame to the end but it has be smoothed and its the average delta of say the last 100 frames.
Smoothed delta is preferred if you want to avoid "cracks" in movement when for some reason the delta of a frame is way higher than the previews frames.
An easy way to calculate the Smoothed delta is this:
smoothedDelta= rawDelta * 0.01f + smoothedDelta * 0.99f;
How can I set a suitable fps number in pygame for any kind of monitor running my game? I know I can set fps using pygame.time.Clock().tick(fps) but how can I set suitable fps?
Please post example python code along with answer.
I'm not entirely sure that I understand the question being asked, but I think you will just have to experiment with different numbers and find out what works for you. I find that around 50-100 is a good range.
If what you are trying to do is make game events only update a certain number of times per second while rendering happens as fast as the computer is able to handle it, this is a very complex process and probably not very easily done in pygame.
The trick I've figured out is not limiting the frame rate, but calculating based on time. The pygame.time.Clock.tick() returns time in milliseconds, which you can then pass to other parts of the program to calculate events or animation updates.
For example, I currently use a pair of variable in my Player object to store the center point of the player's character multiplied by 1000 to be able to update it as an int from tick(). I think update it each loop, after solving which direction the player is moving, with the following code:
self.x += self.speed * time * xmove
self.y += self.speed * time * ymove
self.rect.centerx = self.x / 1000
self.rect.centery = self.y / 1000
Additionally, I use that same time variable as part of the Spawner class to determine when new enemies should be spawned to the map, and for the movement of the enemies and bullets in the game.
This method has the bonus of keeping game play more or less the same across multiple frame rates.
Is there any way in Box2D to get the impulse of a collision without registering a contact listener?
Ie, I can get a list of all contacts for a body using GetContactList() and contact->GetManifold()->localNorm, but this returns a unit vector.
I couldn't seem to find any way of getting the impulse information from the b2Contact class.
No, there may be more than one impulse per time step. Use a listener.
gyroscopes which measure rate of rotation of angles when integrated produce angles right?
my question is how do i do this? what im doing so far is just adding all the angles ive detected and that seems to be very wrong
AngleIntegrated = GyroDegPersec * (1/GyroBandWidth);
suggestions are very welcome. thanks
You need to integrate with respect to time. So ideally you should sample the gyroscope at regular (fixed) time intervals, T, and then incorporate that sampling interval, T, into your integral calculation.
Note that T needs to be small enough to satisfy the Nyquist criterion.
You can integrate in discrete domain. Suppose the angular rate is da, it's time integral is a.
k is the discrete step number.
a(k) = a(k-1) + T*0.5*(da(k) + da(k-1))
For example, da(k) is current angular rate reading. da(k-1) is previoud angular rate reading. a(k-1) is the previous step's integration value(rotation angle). T is sampling rate. If the sensor outputs in every 1 millisecond, T becomes 0.001.
You can use this formula when k>0. The initial value, a(0), must be given.
Knowing that of course you can't count on having a correct value in the long run (by integration your error window will always increase over time) what I would do is reading the gyroscope, interpolating the current read and previous few ones to get a smooth curve (e.g. a parabola using current read and previous two) and then computing the integral of that parabola from last read time and current time.