RobotStudio event

Emergency stop simulation on robotstudio

I am a student and i am working on Emergency stop simulation on RobotStudio. Actually my purpose is to compare the emergency stop distance in reality and the emergency stop distance on RobotStudio. Is it possible to simulate that on RobotStudio ? 
Thank you a lot and have a nice day.

Best regards,

Comments

  • Hi Amjed,
    There is a lot of useful info in this old forum post: https://forums.robotstudio.com/discussion/4969/simulate-emergency-stop#latest 
    Also, there is two types of emergency stops, Category 1 and Category 0.

    You cannot rely on the data from the robot controller after emergency stop has been issued, therefore it is hard to say if the end pose is accurate compared to the real world.

    Best Regards
    Oskar

  • Hi everybody,

    For those who are interested in the simulation of the emergency stop category 0 and category 1. Using the signal analyzer, i tried to verify if the controler is able to save data after pushing  the ES1 button. the controler stopped directly and there is no data saved after the order of stopping. Next step, i will try create an add-in which stops the robot mechanically ( mechanical brake) not the controler. If anybody wants to participate to help in this work, you are really welcome.

    Regards,
    /Amjed
  • OskarHenriksson
    edited April 2018
    Hi Amjed
    You will not be able to activate the brakes in any other way than to issue a category0 stop (the controller will be involved).
    Though maybe it is possible to log testsignals from the controller even after an emergency stop and in that way follow the stop pose.

    Here are some known testsignals: https://forums.robotstudio.com/discussion/10562/test-signal-number 

    Testsignal subscriptions are a bit difficult to setup from the RobotStudio API(you need to implement the abstract class DataRecordersinkBase2), here is my implementation, hope it can be of use.
    
    class SinkBaseImplementation : DataRecorderSinkBase2
        {
            private SimulationDataRecorder connectedRecorder;
            private DataRecorderSignal signalSubscribedTo = null; 
            public SinkBaseImplementation(string sinkId, IList<DataRecorderSignal> signals) : base(sinkId, signals)
            {
            }
    
            public event EventHandler<EventArgs> NewDataEvent;
    
            public void SubscribeToSignal(RsIrc5Controller controller, RsMechanicalUnit mech, int joint, int testsignal)
            {
                if (signalSubscribedTo != null) throw new Exception("SinkBaseImplementation: I'm already subscribed to a signal!");
                var signalInfo = new DataRecorderSignalInfo(SignalDataType.Number, SignalInterpolationType.Discrete, BuiltInControllerSourceSignals.MotionSignalTag);
                signalSubscribedTo = StationsHelper.GetMotionSignal(controller, mech.Name, joint, testsignal, signalInfo, "");
                this.Signals.Add(signalSubscribedTo);
            }
    
            protected override void OnData(double time, DataRecorderSignal signal, object value)
            {
                NewDataEvent(value, new EventArgs());
            }
    
            protected override void OnSignalsDisabled(double time, IEnumerable<DataRecorderSignal> signals)
            {
                //ignore for now
            }
    
            protected override void OnSignalsEnabled(double time, IEnumerable<DataRecorderSignal> signals)
            {
                //Do nothing.
            }
    
            public bool Dispose()
            {
                if(this.Signals.Contains(signalSubscribedTo)) this.Signals.Remove(signalSubscribedTo);
                var removed = RemoveMeFromSimulationDataRecorder(connectedRecorder);
                return removed;
            }
    
            private bool RemoveMeFromSimulationDataRecorder(SimulationDataRecorder dataRec)
            {
                if (dataRec.Sinks.Contains(this)) return dataRec.Sinks.Remove(this);
                else return false;
            }
            public bool TryAddMeToSimulationDataRecorder(SimulationDataRecorder dataRec)
            {
                bool success = false;
                if (!dataRec.Sinks.Contains(this))
                {
                    connectedRecorder = dataRec;
                    connectedRecorder.Sinks.Add(this);
                    success = true;
                }
                return success;
            }
        }<br>


    /Oskar

  • And this is how I use it:
            public static SinkBaseImplementation InitDataRecorder(string sinkId, EventHandler<EventArgs> newDataHandler)
            {
                var sinkBase = new SinkBaseImplementation(sinkId, new List<DataRecorderSignal>());
                sinkBase.NewDataEvent += newDataHandler;
                if (sinkBase.TryAddMeToSimulationDataRecorder(Simulator.DataRecorder)) return sinkBase;
                else throw new Exception("could not add data recorder");
            }

  • Thank you Oskar ^^ the code you put above must be written on Visual Studio isn't it ? Can you please tell me where i find a document that helps me to create a program used on robotstudio because i don't know how to create a link between robotstudio and visual studio.

    Regards, 
    /Amjed
  • OskarHenriksson
    edited April 2018
    Hi Amjed
    Yes it is C# code, you can use it by creating a RobotStudio Add-In:
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotStudio/html/08a465af-bdcc-4f65-a647-764c14005d00.htm
    An Add-In is runned by RobotStudio and does not neccesarily have any connection with a robot controller at all, meanwhile RAPID code is executed on the robot controller.

    It is possible to read testsignals from RAPID as well
    http://developercenter.robotstudio.com/BlobProxy/manuals/RapidIFDTechRefManual/doc471.html