RobotStudio event

move irb140 in real time via joystick

Hello!

I want to move a robot arm with a joystick by an addin. I have tried to ad the offset from the joystick to "station.ActiveTask.Mechanism.SetJointValues()" in visual studios but it results with the robotstudio crashing. Have anyone had the same problem? Or is there a bether way to solve this task?

Comments

  • John Wiberg
    John Wiberg ✭✭✭

    Could you provide a snippet? I'm guessing you don't supply the correct values. Like mm to m conversion, or in the case of angles, euler to quaternions. Have you tried the GetJointValues before to see that they match?

    Now why would you want to jog the mechanism like this? Its just the simulation mechanism in RobotStudio, and for that you have better tools available like the "Mechanism Joint Jog" dialog in RobotStudio. Or the freehand "Jog Linear". Is it for school?

  • Yes it's a school project but the code is eventually suposed to work with a real robot in smaller scale. If I understand you right solving it this way wont work whith a real robot? In that case are there any other way to solve it?

    Now i'm just trying to make the robot to move without joystick just by assign a small shift in one of the joints. Here is the code for that:

        Shared Function myFunction()

            jointVal(2) = jointVal(2) + 0.1

            mech.SetJointValues(jointVal, False)
            station.UpdateGraphics(True)
            Exit Function
        End Function

       Shared Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs)
            myFunction()
        End Sub

    Where "OnTimedEvent" is called 2 times every second. It works if i call the "myFunction()" from "Shared Sub AddinMain()" but not if i call it from "OnTimedEvent".
  • John Wiberg
    John Wiberg ✭✭✭

    Using Mechanism.SetJointValues would be the equivalent to going to the robot and physically pushing the arm to get it to move. You are not creating any motion initiated by the controller. So that will not work at all on a real controller+robot.

    The RobotStudio SDK handles everything in the RobotStudio GUI domain. That means that it doesn't handle the controller.

    To be able to get the controller to move the manipulator you need to use the PC SDK. That gives you the ability to actually control a robot.

    http://developercenter.robotstudio.com/DevCenter.aspx?DevCenter=RobotCommunication

     

    If it works when coming from a menu/button call but doesn't when coming from the OnTimedEvent then I think you have a classic GUI threading issue. You should solve that with an invoke delegate solution.

    http://msdn.microsoft.com/en-us/library/aa645739(v=vs.71).aspx

     

    Now in this forum we have had a couple of these types of app questions. So you should be able to get some basics by searching. Like this one which will give some hints to where you should be heading:

    http://forums.robotstudio.com/discussion/comment/20748

     

    Maybe you/your teacher might be interested in this? (Joysticks are so old school  ;)

    http://mdh.diva-portal.org/smash/record.jsf?pid=diva2:279305&rvn=1

  • Thanks for the reply. 
    Tried the invoke delegate but didn't really work, I can use "getjointvalues()" in the onTimedEvent sub but not "setjointvalues()" in onTimedEvent. Are there any other way just to control the robot in robotstudio (it doesn't have to work with a real robot)? Like the way you can controll the robot with the joystick in the virtual flexpendant?
  • Or could i get some help vi the invoke delegate solution, i'm brand new with VS and visual basic. 
  • I would be very grateful if there Isithere anyone who has an example code on howe to solve this with an invoke deligate solution.