Main.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package at.acdp.urweb;
  2. import at.acdp.urweb.fhpp.FHMaster;
  3. import at.acdp.urweb.fhpp.FHMasterSim;
  4. import at.acdp.urweb.fhpp.IFHMaster;
  5. import at.acdp.urweb.rtde.RTDEClient;
  6. import at.acdp.urweb.rtde.packets.*;
  7. import at.acdp.urweb.web.FestoXRServer;
  8. import com.nmote.nanohttp.NanoServer;
  9. import com.nmote.xr.HTTPServerEndpoint;
  10. import com.nmote.xr.XR;
  11. import org.slf4j.LoggerFactory;
  12. public class Main {
  13. private final static org.slf4j.Logger logger = LoggerFactory.getLogger(Main.class);
  14. public static IFHMaster fhm=new FHMaster();
  15. public static void main(String[] args) {
  16. Params app = null;
  17. try {
  18. app = picocli.CommandLine.populateCommand(new Params(), args);
  19. if(app==null) {
  20. System.exit(1);
  21. }
  22. NanoServer server = new NanoServer("http://0.0.0.0:" + app.port);
  23. RTDEClient r=new RTDEClient("127.0.0.1", 30004);
  24. var so=new RtdeSetupOutputs()
  25. .addVariable("timestamp")
  26. .addVariable("robot_mode")
  27. .addVariable("safety_mode")
  28. .addVariable("safety_status")
  29. .addVariable("target_speed_fraction")
  30. .addVariable("runtime_state")
  31. .addVariable("speed_scaling");
  32. r.start(so);
  33. PosThread p=new PosThread(r, fhm);
  34. p.start();
  35. FestoXRServer fxrs = new FestoXRServer(r);
  36. HTTPServerEndpoint xrs = XR.server(fxrs, FestoXRServer.class);
  37. server.add(xrs);
  38. server.start();
  39. } catch (Exception e) {
  40. logger.error("Server exited", e);
  41. }
  42. try {
  43. fhm.start(app);
  44. } catch (Exception e) {
  45. logger.error("failed.", e);
  46. picocli.CommandLine.usage(new Params(), System.out);
  47. System.exit(1);
  48. }
  49. }
  50. }