What??s wrong with my codes?
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:18Comments
-
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))
cookie2007-6-26 6:41:38
{
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();
}0 -
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 ,
Q
0 -
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
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 314 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 794 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings