RobotStudio event

Write a Robtarget Help !!!


Dim c As New Controller()
Dim motion As MotionSystem = c.MotionSystem
Dim mech As MechanicalUnit = motion.GetActiveMechanicalUnit()
Dim robP As RobTarget
robP = mech.GetPosition(CoordinateSystemType.WorkObject)

Dim rdRobtarget As RapidData = c.Rapid.GetRapidData("T_ROB1", "SrvSysInit", "ptest")
Dim rtValue As RobTarget = DirectCast(rdRobtarget.Value, RobTarget)
rdRobtarget.WriteItem(robP)


i want to change ptest robtarget position to my current robtarget position but always an error not change my ptest robtarget what is the problem please help

Comments

  • Please post the error text.

    Lennart H
  • error code is
     

    object reference not set to an instance of an object

     

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    Message: Object reference not set to an instance of an object.

    System.NullReferenceException: Object reference not set to an instance of an object.
       at ABB.Robotics.Controllers.RapidDomain.UserDefined.FillFromString(String newValue)
    <--

     ABB.Robotics.InternalException at FillFromString in ABB.Robotics.Controllers.RapidDomain.UserDefined
       at ABB.Robotics.Dcl.ExceptionHelp.ReThrowException(String objStr, String method, Exception exception, String[] additionalinfo)
       at ABB.Robotics.Dcl.ExceptionHelp.GenerateException(String objStr, String method, Exception exception, String[] additionalinfo)
       at ABB.Robotics.Dcl.ExceptionHelp.GenerateException(Object obj, String method, Exception exception, String[] additionalinfo)
       at ABB.Robotics.Dcl.ExceptionHelp.GenerateException(Object obj, String method, Exception exception)
       at ABB.Robotics.Controllers.RapidDomain.RapidData.ReadItem(Int32[] index)


     
  • Are you trying to write to a RobTarget stored in an array? I put you the question because the WriteItem method is used when writing to a specific RobTarget that is stored in an array of RobTargets.

    If this is not the case please find below code (C#) that will read the current position of the manipulator and then writes the data to a RobTarget variable.
     


    m_MotionSystem =
    this.controller.MotionSystem;
    m_MechanicalUnit = m_MotionSystem.ActiveMechanicalUnit;
    RobTarget CurrPos = new RobTarget();
    RobTarget rt = new RobTarget();
    RapidData rd = this.controller.Rapid.GetRapidData("T_ROB1", "sample", "pTest");
    CurrPos=m_MechanicalUnit.GetPosition(
    CoordinateSystemType.WorkObject);
    rt=(ABB.Robotics.Controllers.RapidDomain.
    RobTarget)rd.Value;
    rt = CurrPos;
    this.m_master = Mastership.Request(this.controller.Rapid);
    rd.Value = rt;
    this.m_master.Dispose();
    Lennart H