RobotStudio event

Graphics Window Viewpoint

I would like to extract the viewpoint data (XYZ positions and rotations) from the graphics window in RS. I can see that the XYZ positions are given next to the "controller status" bar. It seems these values are only updated by clicking in the active area of the graphics window.

Is there another way of extracting viewpoint data in RS?

Thanks in advance,
Neil

Comments

  • Hi Neil,

    The values in the status bar is the the position of the white marker, which has nothing to do the viewpoint.

    You could write a simple addin to retrieve the viewpoint, using the LookAt and LookFrom properties of the GraphicControl object. This isn't supported in VSTA, so you would have to use Visual Studio.

    regards,
    Johannes

    Johannes Weiman
    Software Engineer
    ABB Robotics
  • Hi,

    Thanks for the reply on the viewpoint issue. I have a few more queries on the same topic...

    1. What project template is used when developing a RobotStudio API through Visual Studio (not VSTA)?

    2. Is the "AddInMain()" method a requirement for add-in applications developed through Visual Studio or VSTA?

    3.  Ideally I would like to develop a form which can do the following:

    set the viewpoint in RS - retrieve image of RS graphics area - embed image on form

    Is this possible, using the current RobotStudio API?

    Thanks in advance,
    Neil

  • Hi Neil,

    That's definitely possible.
    The project should be a C# or VB.Net Class Library. The AddinMain() method is the way RS identifies and activates an addin so it must be present. (Also see this post.)

    Something like this should do the trick:

    GraphicControl gc = GraphicControl.ActiveGraphicControl;
    gc.LookFrom = new Vector3(x, y, z);
    // Give graphic control time to redraw
    Application.DoEvents();
    Bitmap bmp = gc.ScreenShot();

    regards,
    Johannes


    Johannes Weiman
    Software Engineer
    ABB Robotics
  • Hi Johannes,

    Thanks for the advice, it seemed to work ok but l have some more queries.

    I would like to view an object from the target points perspective i.e.
    the viewpoint should be at the same position and rotation as the target
    point, so....


    1. How do the vector3 arguments (x,y,z) relate to the target point arguments (x,y,z,rot_x,rot_y,rot_z)?

    2. Does the "camera" class offer any additional functionality for controlling the viewpoint?

    Thanks in advance,
    Neil



  • 1. The x/y/z components of an object's global matrix corresponds to the x/y/z axis of the object's local coordinate system. So to look along the z axis of a target you could do this:

    RsTarget target = ...
    Matrix4 targetMat = target.Transform.GlobalMatrix;
    Vector3 lookFrom = targetMat.Translation;
    Vector3 lookDirection = new Vector3(targetMat.z);
    double lookDistance = 1; //m
    GraphicControl gc = ...
    gc.LookFrom = lookFrom;
    gc.LookAt = lookFrom + lookDirection * lookDistance;

    2. Yes, absolutely. With the Camera class you can
    - Save viewpoints in the station (Station.Cameras)
    - Lock the view (Camera.LockXX)
    - Track a moving object (Camera.FollowObject)

    Johannes Weiman
    Software Engineer
    ABB Robotics
  • Hi Johannes,

    That last piece of code worked ok and I can now SET the LookAt property.

    I am now trying to GET the LookAt property from the ActiveGraphicControl object.

    I would like to manually select a view in the RS graphics window (using mouse control) and display the vector3 values for that viewpoint in a simple message box.

    The problem is that when I move to a new viewpoint in the RS graphics window, the vector3 values are not updated accordingly. I have tried to update the graphic control object but it has made no difference. I have also tried using both GraphicControl and Camera classes but I get the same result.

    The code using the GraphicControl object is given below.

    Any help appreciated,
    Neil


    GraphicControl gc = GraphicControl.ActiveGraphicControl;

    double xx = gc.LookAt.x;
    double yy = gc.LookAt.y;
    double zz = gc.LookAt.z;

    gc.Update();
                
    Vector3 vect3 = new Vector3(xx, yy, zz);
                
    string St1=vect3.ToString();

    MessageBox.Show(St1,"Vector3 Values");


  • When using the LookAt property, the ActiveGraphicControl is updated when selecting the pre-defined viewpoints on the view toolbar. and not by panning and tilting with mouse.
    However using the LookFrom property, the ActiveGraphicControl is also updated when selecting the view by panning and tilting with mouse.

    Neil

  • LookAt will not change when you rotate or zoom the view, because LookAt is the point around which the view is rotated/zoomed!
    It should change when you pan the view (CTRL + left mouse button) though, are you sure that's not the case?

    regards,
    Johannes

    Johannes Weiman
    Software Engineer
    ABB Robotics
  • You're correct......panning the view does update the values.

    Thanks for your help,
    Neil

  • Sorry for rekindling an old thread, but I was wondering if there is any way to lock or set the ROLL of the camera? Using LookAt and LookFrom can change the yaw and pitch of the camera, but they are unable to define the roll. It seems  that the camera automatically attempts to be as "straight up" as possible (0 degrees along what would be perceived as its Y-axis) but I would really like to be able to manipulate it myself. Any ideas?
  • Hi,

    You are right that in the GUI and the GraphicControl API there is no way to set the roll of the camera.

    However, if you connect a Camera object to the GraphicControl you get some additional possibilities. One of these is to set the UpDirection which corresponds to the 'Y-axis' of the view. Another is to lock the view so the user cannot change zoom/pan/rotation.

     

    regards,
    Johannes

    Johannes Weiman
    Software Engineer
    ABB Robotics
  • Thank you, this was exactly what I was looking for, somehow I missed such an obvious member name. Thank you Johannes!