Discussion

Left ArrowBack to discussions page
GoldenGolden Posts: 5 Apprentice
Hello :)
I'm using Universal Robots UR10 Simulator at the moment.

I've developed a Client(URScript)-Server(C++) communication program in order to control the robot using C++.
I have two questions:
1) I want to be able to run a new program on the robot (say, Prog2.URP) from C++ (using Dashboard Server, for example) without closing the Client program running on the robot (the one communicating with my C++ program). Is that possible?
2) Is it possible to add the Client side program (or any other URP program) to startup boot like a system program? I don't want my code to be visible from an end-user point of view (which can load the URP program in his Teach Pendent and see the code).

if Question #2 is possible, I guess it solves #1 as well.

Best Answer

  • matthewd92matthewd92 Posts: 995 Handy
    Accepted Answer
    Yes, the *.script file on the robot is the compiled script file of the program you wrote in polyscope, it will have the same name.  You would need to send this file line by line to the port, we use 30002 to send files to.  Also after each line we send the line break, `\n` command so that the server knows where to break lines up.  If you write your own script to send, indentation is important.  The body of the program has to be indented two spaces from the `def` and `end` statements that wrap the script like this.

    def main():
      set_tcp(p[-4.4E-4, -0.00419, 0.42121, -0.78, 0.0, 0.0])
      freedrive_mode()
      sleep(5)
      end_freedrive_mode()
    end

    Other indentations inside the code can be made to make it easier to read as well, but the critical one is that the body of the code is indented at least 2 spaces from the opening and closing lines.

Comments

  • matthewd92matthewd92 Posts: 995Founding Pro, Tactile Sensor Beta Testers Handy
    The only real way that I know of to keep the program totally hidden from the users eyes is to serve the script to the robot over one of the ports 30001, 30002 or I believe 30003.  There may be a way to load a program from another directory other than the programs directory that is then hidden from the user as they can only see the programs directory and its children from the touch pendant, unless they go into terminal mode then they have full access to the entire OS.

    There is a specific format that it has to be sent in regarding indentation of the program lines.  You would need to define the entire program in script...or you could write the program in Polyscope, and take the compiled script and then serve that to the robot over one of those ports.  Doing that does not even require a program to be on the robot. 

    We have done something similar in the past but we actually ran the program on the server and only sent the robot physical commands that it needed to execute such as move commands.  We kept the entire state of the robot on the server, using RTDE, as well as all logic and only sent the required commands to the robot.  You have to then keep track of positioning and distance on the robot from target position as there is no feedback about execution of the line and you can only send one line at a time as the next line sent would halt current execution and then start executing the new line.

    Are you using E-Series or CB series?  The E-Series robots have some limitations around external programs executing in that they have to be in remote control mode to accept external commands and then certain things such as the move screen and free-drive button do not work as you have to be in local mode for that to work.  Also in remote control mode the play/pause/stop buttons on the teach pendant do not work so you have to provide an external system for that control which could just be hard wired buttons and set the inputs to be those actions.   CB series robots do not have these limitations.
  • GoldenGolden Posts: 5 Apprentice
    The only real way that I know of to keep the program totally hidden from the users eyes is to serve the script to the robot over one of the ports 30001, 30002 or I believe 30003.  There may be a way to load a program from another directory other than the programs directory that is then hidden from the user as they can only see the programs directory and its children from the touch pendant, unless they go into terminal mode then they have full access to the entire OS.

    There is a specific format that it has to be sent in regarding indentation of the program lines.  You would need to define the entire program in script...or you could write the program in Polyscope, and take the compiled script and then serve that to the robot over one of those ports.  Doing that does not even require a program to be on the robot. 

    We have done something similar in the past but we actually ran the program on the server and only sent the robot physical commands that it needed to execute such as move commands.  We kept the entire state of the robot on the server, using RTDE, as well as all logic and only sent the required commands to the robot.  You have to then keep track of positioning and distance on the robot from target position as there is no feedback about execution of the line and you can only send one line at a time as the next line sent would halt current execution and then start executing the new line.

    Are you using E-Series or CB series?  The E-Series robots have some limitations around external programs executing in that they have to be in remote control mode to accept external commands and then certain things such as the move screen and free-drive button do not work as you have to be in local mode for that to work.  Also in remote control mode the play/pause/stop buttons on the teach pendant do not work so you have to provide an external system for that control which could just be hard wired buttons and set the inputs to be those actions.   CB series robots do not have these limitations.

    Thank you Matthew,
    I'm having trouble sending the whole script through my C++ program.
    Are .script the compiled files? if not, how to I obtain them? I'm currently running PolyScope sim on a desktop.
    How should it be done? line by line to the same port?

  • GoldenGolden Posts: 5 Apprentice
    Yes, the *.script file on the robot is the compiled script file of the program you wrote in polyscope, it will have the same name.  You would need to send this file line by line to the port, we use 30002 to send files to.  Also after each line we send the line break, `\n` command so that the server knows where to break lines up.  If you write your own script to send, indentation is important.  The body of the program has to be indented two spaces from the `def` and `end` statements that wrap the script like this.

    def main():
      set_tcp(p[-4.4E-4, -0.00419, 0.42121, -0.78, 0.0, 0.0])
      freedrive_mode()
      sleep(5)
      end_freedrive_mode()
    end

    Other indentations inside the code can be made to make it easier to read as well, but the critical one is that the body of the code is indented at least 2 spaces from the opening and closing lines.
    This works great! Thank you!
    I do have a small problem though:
    After I send the last '\n' (after the closing end of my program) and only then, I get a java.lang.NullPointerException popup. It does not effect the program, it needs to be taken care of. If I don't send the last '\n', the program doesn't start, ofcourse.

    Any idea where this is coming from?

    log file included.
  • matthewd92matthewd92 Posts: 995Founding Pro, Tactile Sensor Beta Testers Handy
    Not sure, I checked our code and we send a new line character after every line we send. Have you tried not sending it on the last line?  
  • GoldenGolden Posts: 5 Apprentice
    edited December 2019
    Not sure, I checked our code and we send a new line character after every line we send. Have you tried not sending it on the last line?  
    Yes, I have... sadly, program won't run if I do that :(

    I think this might have something to do with the name of my program or the fact that there's no "main" in it. Is that a thing?

    Update:
    Right after the program starts, in the log tab, I get a Polyscope alert saying C0A0 as the code. nothing else is stated.
  • matthewd92matthewd92 Posts: 995Founding Pro, Tactile Sensor Beta Testers Handy
    edited December 2019
    What's the name of your program? I know that one of the ones that we send over is not called main and we don't have issues with this.  According to the user manual a C0 code means no error.

    Does the program play and then after playing you are getting the Java error or immediately before it starts playing?

    Also, once you send the all of the program are you closing that socket connection or leaving it open?  Not sure if it matters but we close the socket and destroy it on the server side once the program is sent in its entirety.  Maybe the socket is remaining open and causing that Java error.
  • GoldenGolden Posts: 5 Apprentice
    What's the name of your program? I know that one of the ones that we send over is not called main and we don't have issues with this.  According to the user manual a C0 code means no error.

    Does the program play and then after playing you are getting the Java error or immediately before it starts playing?

    Also, once you send the all of the program are you closing that socket connection or leaving it open?  Not sure if it matters but we close the socket and destroy it on the server side once the program is sent in its entirety.  Maybe the socket is remaining open and causing that Java error.
    1) Prog3, Might not be the issue.
    2) It plays and somewhere in the middle, I get the alert (which does not happen if I use Dashboard Server to load the program).
    3) I close the socket on our end.

    The track log(stack calls) states that it comes from a java function related to the GUI (com.ur.view.program.ProgramTrackingInformation.getMainProgram)



    I really thank you for helping out! :)

Sign In or Register to comment.
Left ArrowBack to discussions page