RobotStudio event

How to attach a body to external axes

Hi,

I want to attach a body to the external axes of my station (MTD-750) programmatically, like when you use the contextual menu->Connect To->MTD-750, but I can´t find how to do it.

Thanks in advance.

Comments

  • You can refer this Doc for getting detailed information about the how to attach external axes to body: http://developercenter.robotstudio.com/BlobProxy/manuals/RobotStudioOpManual/doc61.html
  • John Wiberg
    John Wiberg ✭✭✭
    edited April 2013

    Hi,

    Since you are in the Developer Center part, I'm going to assume that you want to do this using the RobotStudio SDK?
    http://developercenter.robotstudio.com/DevCenter.aspx?DevCenter=RobotStudio
    If not then please give us a context.
    If so then the attach functionality is on the Frame or Flange of the External Axis depending on how you created it. But note that a body cannot be attached by itself, instead it needs to be in a part to be attachable.
    Here is a snippet that creates a cylinder at the flange of the active mechanism:
     {
                Logger.AddMessage(new LogMessage(sender.ToString()));
                // Check that we have an active station
                Station _station = Project.ActiveProject as Station;
                if (_station == null) return;
                // Get the active task and it's mechanism
                RsTask _task = _station.ActiveTask;
                if (_task == null) return;
                Mechanism _mechanism = _task.Mechanism;
                if (_mechanism == null)
                {
                    Logger.AddMessage(new LogMessage("No active mechanism"));
                    return;
                }
                Part p=null;
                Body cyl=Body.CreateSolidCone(new Matrix4(new Vector3(Axis.X), 0.0), 0.1, 0.5);
                foreach (Flange x in _mechanism.GetFlanges())
     {
                    p = new Part();
                    p.Bodies.Add(cyl);
                    _station.GraphicComponents.Add(p);
                    x.Attach(p,true);
     }
                Logger.AddMessage(new LogMessage("It is done!"));
           }

    You could also attach directly to a specific joint, in this example it is joint 3 of a robot.
                GraphicComponent _gc;
                _mechanism.GetParentLink(3, out _gc);
                Part myPart=(Part)_gc;
                myPart.Attach(p,true);

     

  • Hi,

    yes, I´m working on the PC SDK. Ok, I didn´t know the Flange structure... but when I list all the flanges of the mechanism, the only one available is the wrist of my robot, and the external axis is not in this list... should it be listed in this collection? Is it possible that I have my Station misconfigured and the external axis is not visible by the system?
  • John Wiberg
    John Wiberg ✭✭✭

    Hi again HM

    Seems to be some confusion here. The PC SDK deals with communication with the controller from a PC app. the RobotStudio SDK deals with the functionality in RobotStudio.

    The only attach functionality in PC SDK is for attaching GUIDs to controllerIDs.

     

    Here is a RobotStudio SDK snippet that goes through all mechanisms in the station and attaches a cylinder to all flanges on those mechanisms.

            static void button2_ExecuteCommand(object sender, ExecuteCommandEventArgs e)
            {
                Logger.AddMessage(new LogMessage(sender.ToString()));

                // Check that we have an active station
                Station station = Project.ActiveProject as Station;
                if (station == null) return;

                Mechanism m = null;
                IEnumerable<ProjectObject> stationobjects = station.GetAllObjects();
                foreach (ProjectObject po in stationobjects)
                {
                    if (po.TypeDisplayName == "Mechanism")
                    {
                        m = (Mechanism)po;
                        Flange[] flanges = m.GetFlanges();
                        foreach (Flange f in flanges)
                        {
                            Part p = new Part();
                            p.Bodies.Add(Body.CreateSolidCone(new Matrix4(new Vector3(Axis.X), 0.0), 0.1, 0.5));
                            station.GraphicComponents.Add(p);
                            f.Attach(p, true);
                            Logger.AddMessage(new LogMessage("Another one bites the dust: " + f.Name));
                        }
                    }
                   
                }
                Logger.AddMessage(new LogMessage("It is done!"));
            }

     

    Now you can actually create a mechanism that doesn't have a flange. Most tools are like that.

    So if you have created the external axes yourself then you might have missed specifying a flange?

     

  • HM
    HM
    Ok! This works perfectly! Thanks a lot.