I'm developing a simple tracking game using two haptic devices as controllers.
Haptic rendering is executed in a high priority thread.
During the experiment, force experienced will depends on the position of each player, it's calculated as follows:
I have 100 trials of tracking tasks and I have to calculate the average interaction force during each trial. How it can be done? my issue is: this manipulation have to be done in a thread with execution rate of around 8KHz
Thank you!. I have already seen some implementation of moving average. But I'm not sure about how to implement for my application. Since it's in a thread which is executing at 8Khz, I'm wondering how to store forces trial by trial and to take avareage?
The fastest solution would be a ring buffer and a total sum variable (untested):
int items = 0;
int ndx = 0;
// May need floating point here when max. value * buffer_size >= INT_MAXint sum = 0;
int get_av(int val)
if (items >= buffer_size)
sum -= buffer[ndx];
sum += val;
buffer[ndx] = val;
if (++ndx >= buffer_size)
ndx = 0;
return sum / items;
You are allocating 4 bytes (on 32 bit platform) instead of approximatively 60 bytes.
The following line is also incorrect:
Since you are Inside a function, the pointer is passed by value and a change inside the function has no effect outside of it. You need to have a pointer to a pointer to be able to update the pointer at the caller location.
You don't initialized new list to NULL so first insertion might fails because the pointer is garbage.
I am trying to run a Legacy MFC application in Debug buil(earlier it was always built in Release Build (with debug info)). While loading resource using LoadToolBar() funtion ::FindResource fails while it succeeds in the Relase build. Can any body help me with this.
When it comes to resources, it could be any number of things... if you make the call within a dll and not the main application, you have to make sure to have the resources of the main application loaded and not the dll's resources.
In any case, hard to tell without more info and some code.
3 users are connected to one pc using 3 usb keypads. A record is shown and each user have to input a number like 7.7 or 600 or 7.5 then they will press ENTER. Done.
So as an example problem: user2 starts to type 7 and user1 starts typing 5. the computer is already getting 75. You can see the problem.
I need a utility/code to isolate the input.
I have seen it in an auction software and also using xbox playing games.
In the auction software 3 black boxes are seen in the PC. Once a user starts the black box associated with that user, turn gray. Same as the other users. When all users have pressed ENTER, All boxes are revealed with the entries.
Until now we only had to enter one digit per box, so 3 keypads were no problem. The system right now have the 3 boxes in the screen.
Last Visit: 13-Oct-19 10:11 Last Update: 13-Oct-19 10:11