rifidi and motion detection?

The Forum for Non-Technical questions

Moderators: Matt, kyle, Moderators

nurban
Posts: 80
Joined: Mon Apr 21, 2014 10:33 am
Organization: PMRS, Inc.
Contact:

Re: rifidi and motion detection?

Post by nurban » Wed Sep 09, 2015 10:00 am

That is going to depend a lot on the tag you're using and what your environment is like. By far the most accurate method would be to collect RSSI values from the type of motion you're expecting, and then use this to derive your own algorithm.

I'm pretty sure the ALR-9900 also has a built-in speed filter you might be able to use.

zuzoovn
Posts: 9
Joined: Sun Aug 30, 2015 11:22 pm

Re: rifidi and motion detection?

Post by zuzoovn » Wed Sep 09, 2015 9:36 pm

What the relation ship between speed and RSSI?
Can i get RF Phase from rifidi?

I am thinking about collecting RSSI, RF phase, Doppler shift

nurban
Posts: 80
Joined: Mon Apr 21, 2014 10:33 am
Organization: PMRS, Inc.
Contact:

Re: rifidi and motion detection?

Post by nurban » Thu Sep 10, 2015 11:02 am

I know RSSI is easy enough to get from an Alien reader, but RF phase and doppler shift I'm not so sure about. I don't believe either of these are available as native Alien functions, so you will need to figure out how to retrieve this data before considering what you might be able to do with it in Rifidi.

zuzoovn
Posts: 9
Joined: Sun Aug 30, 2015 11:22 pm

Re: rifidi and motion detection?

Post by zuzoovn » Fri Oct 02, 2015 1:32 am

Finally, I found the Alientechnology's algorighm in their .NET sample code

ftp://ftp.alientechnology.com//pub/read ... 009-04.zip

In Alien dotNET SDK 2.3.0 2009-04/_NET/Alien Sample Apps (.NET 2)/Example 13 - ITR Singulation, here are their source code

The custom format

Code: Select all

id:%k t:${MSEC2} TIME2:${TIME2} a:%a vel:${SPEED} sig:${RSSI} freq:${FREQ}
The source code

Code: Select all

 void OnTagRead(string msg)
        {
            lock (moStreamMsgLock)
            {
                if (sbDisposing || !this.Created) return;
                if (msg == null) return;

                string[] tags = msg.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                string tag = msg.Trim();

                DataPoint datapoint = null;

                for (int i = 0; i < tags.Length; i++)
                {
                    string id = extractField(tag, "id:");
                    if (string.IsNullOrEmpty(id))
                        return;
                    string sT = extractField(tag, "t:");
                    double t = 0;
                    if (!double.TryParse(sT, out t))
                    {
                        AlienLog.WriteLine(true, "Bad Time token '" + sT + "' in tag: " + tag);
                        return;
                    }
                    string sVel = extractField(tag, "vel:");
                    double vel = 0;
                    if (!double.TryParse(sVel, out vel))
                    {
                        AlienLog.WriteLine(true, "Bad Velocity token '" + sVel + "' in tag: " + tag);
                        return;
                    }
                    string sRSSI = extractField(tag, "sig:");
                    double rssi = 0;
                    if (!double.TryParse(sRSSI, out rssi))
                    {
                        AlienLog.WriteLine(true, "Bad Signal token '" + sRSSI + "' in tag: " + tag);
                        return;
                    }
                    string sFreq = extractField(tag, "freq:");
                    double freq = 0;
                    if (!double.TryParse(sFreq, out freq))
                    {
                        AlienLog.WriteLine(true, "Bad Frequency token '" + sFreq + "' in tag: " + tag);
                        return;
                    }
                    string sTime = extractField(tag, "TIME2:");

                    lock (moDataPointsLock)
                    {
                        if (!mdDataPoints.ContainsKey(id))
                        {
                            datapoint = new DataPoint();
                            datapoint.Color = mColors[miNextColor];
                            miNextColor++;
                            if (miNextColor > mColors.Length - 1)
                                miNextColor = 0;
                        }
                        else
                            datapoint = mdDataPoints[id];
                        if (!string.IsNullOrEmpty(sTime))
                            datapoint.sTime = sTime;

                        datapoint.id = id;
                        if (mStartTime == 0)
                            mStartTime = t;
                        datapoint.t = (t - mStartTime) / 1000;
                        datapoint.Vel = -vel;
                        datapoint.Freq = freq;
                        datapoint.Sig = rssi;

                        double filt = -5.0;
                        double dt = datapoint.t - datapoint.lastT;

                        datapoint.smoothVel = datapoint.smoothVel * Math.Exp(filt * dt) +
                                              datapoint.Vel * (1 - Math.Exp(filt * dt));

                        datapoint.integVel = datapoint.integVel +
                                             2 * datapoint.lastVel * dt * Math.Exp(filt * dt);

                        if (mbDiffusionCorrection)
                            datapoint.integVel = datapoint.integVel * Math.Exp(-0.15 * dt);

                        if (mbASCIIMode)
                        {
                            byte b = byte.Parse(id.Substring(id.Length - 2), System.Globalization.NumberStyles.HexNumber);
                            datapoint.Caption = Convert.ToChar(b).ToString();
                        }
                        updateGUI(datapoint);

                        datapoint.lastT = datapoint.t;
                        if (datapoint.Freq != datapoint.lastFreq)
                            datapoint.sigOffset += datapoint.Sig - datapoint.lastSig;

                        datapoint.smoothSig = datapoint.smoothSig * Math.Exp(filt * dt) + (datapoint.Sig - datapoint.sigOffset) * (1 - Math.Exp(filt * dt));

                        if (mbSmoothing)
                            datapoint.integVelSig = datapoint.integVel * datapoint.smoothSig;
                        else
                            datapoint.integVelSig = datapoint.integVel * (datapoint.Sig - datapoint.sigOffset);

                        if (datapoint.integVelSig > datapoint.integVelSigMax)
                        {
                            datapoint.integVelSigMax = datapoint.integVelSig;
                            datapoint.tintegVelSigMax = datapoint.t;
                            mbListRefreshNeeded = true;
                        }
                        datapoint.lastFreq = datapoint.Freq;
                        datapoint.lastSig = datapoint.Sig;
                        datapoint.lastVel = mbSmoothing ? datapoint.smoothVel : datapoint.Vel;
                        if (datapoint.integVel > datapoint.integVelMax)
                        {
                            datapoint.integVelMax = datapoint.integVel;
                            datapoint.tIntegVelMax = datapoint.t;
                        }
                        else
                            mbListRefreshNeeded = true;

                        if (!mdDataPoints.ContainsKey(id))
                            mdDataPoints.Add(id, datapoint);
                        else
                            mdDataPoints[id] = datapoint;
                    }
                }
                if (mbListRefreshNeeded)
                    refreshList();
            }
        }
Currently, I do not Understand hown can they calculate the smoothSig, smoothVel, integVel, integVelSig.
I am researching with this document : https://tandmconsulting.wordpress.com/2 ... hase-data/
But I have no result.
Could you please help me to convert the logic to the math equations?

nurban
Posts: 80
Joined: Mon Apr 21, 2014 10:33 am
Organization: PMRS, Inc.
Contact:

Re: rifidi and motion detection?

Post by nurban » Fri Oct 02, 2015 10:03 am

It looks like these are just operations done using the more granular tagread data, as specified in the custom format.

For example, datapoint.smoothVel uses the double dt, which comes from time datapoints. It also uses datapoint.Vel, which comes from the reader's built-in velocity calculation as parsed here:

Code: Select all

string sVel = extractField(tag, "vel:");
                    double vel = 0;
                    if (!double.TryParse(sVel, out vel))
                    {
                        AlienLog.WriteLine(true, "Bad Velocity token '" + sVel + "' in tag: " + tag);
                        return;
                    }
Trace back each variable to where it gets parsed, they're all there.

zuzoovn
Posts: 9
Joined: Sun Aug 30, 2015 11:22 pm

Re: rifidi and motion detection?

Post by zuzoovn » Fri Oct 02, 2015 11:02 pm

Thank you

I know about how to get value from custom format.

Currently, I want to convert from below logic to the math equations in order to write it in to the research report.
Something like "Equations 3-10" in this image Image

So that I can implement the algorithm in other programing language

Code: Select all

double filt = -5.0;
                        double dt = datapoint.t - datapoint.lastT;

                        datapoint.smoothVel = datapoint.smoothVel * Math.Exp(filt * dt) +
                                              datapoint.Vel * (1 - Math.Exp(filt * dt));

                        datapoint.integVel = datapoint.integVel +
                                             2 * datapoint.lastVel * dt * Math.Exp(filt * dt);

                        if (mbDiffusionCorrection)
                            datapoint.integVel = datapoint.integVel * Math.Exp(-0.15 * dt);

                        if (mbASCIIMode)
                        {
                            byte b = byte.Parse(id.Substring(id.Length - 2), System.Globalization.NumberStyles.HexNumber);
                            datapoint.Caption = Convert.ToChar(b).ToString();
                        }
                        updateGUI(datapoint);

                        datapoint.lastT = datapoint.t;
                        if (datapoint.Freq != datapoint.lastFreq)
                            datapoint.sigOffset += datapoint.Sig - datapoint.lastSig;

                        datapoint.smoothSig = datapoint.smoothSig * Math.Exp(filt * dt) + (datapoint.Sig - datapoint.sigOffset) * (1 - Math.Exp(filt * dt));

nurban
Posts: 80
Joined: Mon Apr 21, 2014 10:33 am
Organization: PMRS, Inc.
Contact:

Re: rifidi and motion detection?

Post by nurban » Mon Oct 05, 2015 9:26 am

Have you tried working backwards and substituting each component of the code? For example:

Code: Select all

datapoint.smoothVel = datapoint.smoothVel * Math.Exp(filt * dt) + datapoint.Vel * (1 - Math.Exp(filt * dt));
Trace back where each variable comes from and fill in the actual value or equation, and do the same with each mathematical operation. In this case, the variable filt can be replaced with the constant -5.0. Doing this for everything should leave you with the formula, or at least something close enough that you can adapt it to another language.

If you're looking for just one equation, then first identify the variable or output that is equal to what you would like to calculate, and then work from there.

Post Reply

Who is online

Users browsing this forum: Antoniotbo and 3 guests