RobotStudio event

What??s wrong with my codes?

Options

Hi!

I try to write to a RobTarget object position which is existed, but it doesn't work, as I run the program, the exception will be thrown. the exception is exactly what I catch in the below"Get value problem"

               try
                 {  
                     IRD = rdp1.Value;
                     aRobTarget = (RobTarget)IRD;
                     aRobTarget.Trans.X = Convert.ToSingle(this.textBoxX.Text);
                     aRobTarget.Trans.Y = Convert.ToSingle(this.textBoxY.Text);
                     aRobTarget.Trans.Z = Convert.ToSingle(this.textBoxZ.Text);
                     rdp1.Value = aRobTarget;
                 }
                 catch (GeneralException ex)
                 {
                     throw new ApplicationException("Get value problem", ex);
                 }

Is there anything wrong with my codes, when I try to modify the target position. Please help me out of this issue. thanks forward.

Best Regards!

cookie2007-6-25 8:10:18

Comments

  • cookie
    Options

    I try to modify the codes in the following, refering to RAB manual.But it still doesn't work. The last line: It seems that I can't deliver the aRobTarget back to rdp1.value, there always an error when executing"Get value problem". Who knows how to deal with it.

     

                 using (Mastership m = Mastership.Request(controller.Rapid))
                 {
                     RapidData rdp1 = this.controller.Rapid.GetRapidData("T_ROB1", "MainModule", "p1");
                     RobTarget aRobTarget;
                     IRapidData IRD;
                     if (rdp1 == null)
                     {
                         throw new Exception("Could not find p1!");
                     }
                     try
                     {  
                         IRD = rdp1.Value;
                         aRobTarget = (RobTarget)IRD;
                         aRobTarget.Trans.X = aRobTarget.Trans.X + Convert.ToSingle(this.numericUpDownX.Value);
                         aRobTarget.Trans.Y = aRobTarget.Trans.Y + Convert.ToSingle(this.numericUpDownY.Value);
                         aRobTarget.Trans.Z = aRobTarget.Trans.Z + Convert.ToSingle(this.numericUpDownZ.Value);
                         rdp1.Value = aRobTarget;
                     }
                     catch (GeneralException ex)
                     {
                         throw new ApplicationException("Get value problem", ex);
                     }
                     rdp1.Dispose();
                  }

    cookie2007-6-26 6:41:38
  • Qrius
    Options

    Hi,

    I'm not sure about this (I'm just a noob) but, Trans takes float values. You are trying to fill it with Single values. So you might wanna try this:

    aRobTarget.Trans.X = aRobTarget.Trans.X + Convert.ToFloat(this.numericUpDownX.Value);

    No guarantees though image,

    Q

     

     

  • Qrius
    Options

    P.S. What exactly is the error msg that you get? Cause just telling us that you get a "general" exception isn't very helpfull.

    Q