def start(self): # Find the hal_hw_interface comp's directory in # LD_LIBRARY_PATH and put it into $COMP_DIR for path in os.environ.get("LD_LIBRARY_PATH", "").split(":"): rospy.loginfo(f"Checking for hal_hw_interface.so in {path}") if os.path.exists(os.path.join(path, "hal_hw_interface.so")): comp_dir = path break else: comp_dir = "" os.environ["COMP_DIR"] = comp_dir rospy.loginfo("hal_mgr: COMP_DIR set to '%s'" % comp_dir) # Get parameters if not rospy.has_param(self.NAME): self.shutdown("No parameters set for '%s'" % self.NAME, 1) try: hal_mgr_config = rospy.get_param(self.NAME) except KeyError: self.shutdown("No keys defined at %s" % self.NAME, 1) return if "hal_files" not in hal_mgr_config: self.shutdown("%s has no 'hal_files' key" % self.NAME, 1) if "hal_file_dir" not in hal_mgr_config: self.shutdown("%s has no 'hal_file_dir' key" % self.NAME, 1) # Set up HAL launcher.cleanup_session() # kill any running Machinekit instances launcher.start_realtime() rospy.loginfo("hal_mgr: Started realtime") # Load rtapi module and set up signal handlers if not getattr(rtapi, "__rtapicmd"): rtapi.init_RTAPI() def shutdown_graceful(signum, frame): self.shutdown("Gracefully shutting down after interrupt signal") signal.signal(signal.SIGINT, shutdown_graceful) signal.signal(signal.SIGTERM, shutdown_graceful) # Load HAL configuration for fname in hal_mgr_config["hal_files"]: fpath = os.path.join(hal_mgr_config["hal_file_dir"], fname) if not os.path.exists(fpath): self.shutdown( "No file '%s' in directory '%s'" % (fname, hal_mgr_config["hal_file_dir"]), res=1, ) rospy.loginfo("hal_mgr: Loading hal file '%s'" % fname) launcher.load_hal_file(fpath) rospy.loginfo("hal_mgr: Loading hal file '%s' complete" % fpath) # Spin until ROS shutdown event rospy.loginfo("ROS node and HAL started successfully") self._pub.publish(True)
#parser = argparse.ArgumentParser(description='Chip Hello World') def check_mklaucher(): try: subprocess.check_output(['pgrep', 'mklauncher']) return True except subprocess.CalledProcessError: return False try: launcher.check_installation() launcher.cleanup_session() launcher.start_realtime() launcher.load_hal_file('chip.py') launcher.register_exit_handler() # needs to executed after HAL files # if not check_mklaucher(): # start mklauncher if not running to make things easier # launcher.start_process('mklauncher .') while True: launcher.check_processes() time.sleep(1) except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) sys.exit(0)
args = parser.parse_args() if args.debug: launcher.set_debug_level(5) if 'MACHINEKIT_INI' not in os.environ: # export for package installs mkconfig = config.Config() os.environ['MACHINEKIT_INI'] = mkconfig.MACHINEKIT_INI try: launcher.check_installation() launcher.cleanup_session() # kill any running Machinekit instances launcher.load_bbio_file('parallel_cape_io_test.bbio') # load the BBIO pin overlay launcher.start_realtime() # start Machinekit realtime environment launcher.load_hal_file(MAIN_HAL) # load the main HAL file launcher.register_exit_handler() # enable on ctrl-C, needs to executed after HAL files launcher.ensure_mklauncher() # ensure mklauncher is started launcher.start_process('configserver -n {} .'.format(NAME)) while True: launcher.check_processes() time.sleep(1) except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) sys.exit(0)
#args = parser.parse_args() #if args.debug: #launcher.set_debug_level(5) if 'MACHINEKIT_INI' not in os.environ: # export for package installs mkconfig = config.Config() os.environ['MACHINEKIT_INI'] = mkconfig.MACHINEKIT_INI try: launcher.check_installation() launcher.cleanup_session() # kill any running Machinekit instances launcher.start_realtime() # start Machinekit realtime environment launcher.install_comp('dxlincurve.comp') launcher.install_comp('progtime.icomp') launcher.load_hal_file('main.hal') # load the main HAL file launcher.register_exit_handler( ) # enable on ctrl-C, needs to executed after HAL files launcher.ensure_mklauncher() # ensure mklauncher is started launcher.start_process( "configserver -n kilncontrol ./ui_mon ./ui_prog ./ui_run") while True: launcher.check_processes() time.sleep(1) except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) sys.exit(0)
def check_mklaucher(): try: subprocess.check_output(['pgrep', 'mklauncher']) return True except subprocess.CalledProcessError: return False try: launcher.check_installation() launcher.cleanup_session() launcher.load_bbio_file('cramps2_cape.bbio') launcher.start_realtime() launcher.load_hal_file('basic.hal') launcher.start_process("configserver -n Electrolab \"demo-ui.Awesome UI\"") #launcher.start_process('linuxcnc CRAMPS.ini') if not check_mklaucher( ): # start mklauncher if not running to make things easier launcher.start_process('mklauncher .') while True: launcher.check_processes() time.sleep(1) except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) sys.exit(0)
parser.add_argument('-d', '--debug', help='Enable debug mode', action='store_true') args = parser.parse_args() if args.debug: launcher.set_debug_level(5) if 'MACHINEKIT_INI' not in os.environ: # export for package installs mkconfig = config.Config() os.environ['MACHINEKIT_INI'] = mkconfig.MACHINEKIT_INI try: launcher.check_installation() launcher.cleanup_session() # kill any running Machinekit instances launcher.start_realtime() # start Machinekit realtime environment launcher.load_hal_file('anddemo.py') # load the main HAL file launcher.register_exit_handler() # enable on ctrl-C, needs to executed after HAL files launcher.ensure_mklauncher() # ensure mklauncher is started if not args.no_config: # the point-of-contact for QtQUickVCP launcher.start_process('configserver -n AND-Demo .') if args.gladevcp: # start the gladevcp version if args.local: # no -N flag - local case, use IPC sockets, no zeroconf resolution launcher.start_process('gladevcp -E -u motorctrl.py motorctrl.ui') else: # -N - remote case, use zeroconf resolution launcher.start_process('gladevcp -N -E -u motorctrl.py motorctrl.ui')
mkconfig = config.Config() os.environ['MACHINEKIT_INI'] = mkconfig.MACHINEKIT_INI def check_mklaucher(): try: subprocess.check_output(['pgrep', 'mklauncher']) return True except subprocess.CalledProcessError: return False try: launcher.check_installation() launcher.cleanup_session() launcher.load_bbio_file('cramps2_cape.bbio') launcher.start_realtime() launcher.load_hal_file('basic.hal') launcher.start_process("configserver -n Electrolab \"demo-ui.Awesome UI\"") #launcher.start_process('linuxcnc CRAMPS.ini') if not check_mklaucher(): # start mklauncher if not running to make things easier launcher.start_process('mklauncher .') while True: launcher.check_processes() time.sleep(1) except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) sys.exit(0)