Forum Migration Notice
We're transitioning to a more modern community platform by the end of this year. Learn about the upcoming changes and what to expect.

How to solve the problem of reading robot data and new time? For example, get the 6-axis Angle value

How to solve the problem of reading robot data and new time?
For example, get the 6-axis Angle value synchronously.
Timer control card

Comments

  • Hi XiaoEr

    You want to log the axis values at a given pace.
    I propose creating an RobotStudio add-in.

    Here is a dirty function I've created to read the values on joint value change, I hope at least it's a start for you

    Good luck!
    /Oskar
     public static void ReadJoints()
            {
                if (recording) return;
                mech = Station.ActiveStation.ActiveTask.Mechanism;
                td.delta_t *= Simulator.SimulationSpeed;
                mech.GetJointLimits(out td.jointLowerLimits, out td.jointUpperLimits);
                td.axisTranslations = new double[mech.Children.Count()][];
                foreach (var child2 in mech.Children)  
                {
                    var child = child2 as IMechanismLink;
                    Matrix4 ct = child.CorrectionTransform;
                    if (child2.Name.StartsWith("Link") && child2.Name.Length == 5){
                        //TODO: less crappy link identification
                        int linkId = child2.Name.ElementAt(4) - 49;
                        td.axisTranslations[linkId] = ct.Translation.ToArray();
                    }
                }
    
                double[] jValues = mech.GetJointValues();
                String jValues_text = String.Join(" | ", jValues.Select(j => Math.Round(j,2).ToString()));
                Logger.AddMessage("rs-addin: " +jValues_text);
                mech.JointValuesChanged += JointValuesHandler;
                recording = true;
            }
    
    private static void JointValuesHandler(object sender, EventArgs e)
            {
                double[] jValues = mech.GetJointValues();
                if(DateTime.Now.Subtract(LastTimeStamp) > TimeSpan.FromSeconds(td.delta_t))
                {
                    jointList.Push(jValues);
                    LastTimeStamp = DateTime.Now;
                }
            }