Have a gander here[^]. Pay particular attention to #11.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
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.
Last Visit: 9-Dec-19 21:48 Last Update: 9-Dec-19 21:48