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)
def hal_config(): from machinekit import launcher launcher.cleanup_session() comp_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), '../components/absolute_joint.icomp', ) launcher.install_comp(comp_path) launcher.start_realtime() rt.init_RTAPI() config = HalConfig(thread=THREAD) rt.newthread(config.thread.name, config.thread.period_ns, fp=True) hal.start_threads() yield config hal.stop_threads() launcher.end_session()
parser = argparse.ArgumentParser( description='This is the Prusa-i3-soc run script ' 'it demonstrates how a run script could look like ' 'and of course starts the Prusa-i3 config') parser.add_argument('-v', '--video', help='Starts the video server', action='store_true') args = parser.parse_args() try: launcher.check_installation() launcher.cleanup_session() launcher.register_exit_handler() # needs to executed after HAL files launcher.install_comp('thermistor_check.comp') launcher.install_comp('reset.comp') nc_path = os.path.expanduser('~/nc_files') if not os.path.exists(nc_path): os.mkdir(nc_path) if not check_mklaucher( ): # start mklauncher if not running to make things easier launcher.start_process('mklauncher .') launcher.start_process("configserver -n Prusa-i3 ~/Machineface ") if args.video: launcher.start_process('videoserver --ini video.ini Webcam1') launcher.start_process('linuxcnc Prusa-i3.ini') while True:
#!/usr/bin/env python # -*- coding: utf-8 -*- # very small helper script for short-cutting # input and output pins when passing data # thru HAL shared memory setup import sys import time import subprocess from machinekit import launcher from machinekit import hal try: launcher.check_installation() launcher.cleanup_session() # kill any running Machinekit instances launcher.start_realtime() # start Machinekit realtime environment while 'ul_iface_component.joint_6.pos-cmd' not in hal.pins: time.sleep(0.5) print('found HAL pin, connecting') # create 6 signals between pos-cmd and pos-fb pins # when machinekit_ros_control has started with # parameter machinekit_interface: 0 for i in range(1, 7): hal.Pin('ul_iface_component.joint_%s.pos-cmd' % i).link( 'ul_iface_component.joint_%s.pos-fb' % i) launcher.register_exit_handler( ) # enable on ctrl-C, needs to executed after HAL files
import sys import os import subprocess import importlib from machinekit import launcher from time import * launcher.register_exit_handler() launcher.set_debug_level(5) os.chdir(os.path.dirname(os.path.realpath(__file__))) try: launcher.check_installation() # make sure the Machinekit installation is sane launcher.cleanup_session() # cleanup a previous session # Uncomment and modify the following line if you create a configuration for the BeagleBone Black #launcher.load_bbio_file('cape-universal') launcher.load_bbio_file('cramps_cape.bbio') # load a BeagleBone Black universal overlay file # Uncomment and modify the following line of you have custom HAL components # launcher.install_comp('gantry.comp') # install a comp HAL component if not already installed launcher.start_process("configserver ~/Machineface") # start the configserver with Machineface an Cetus user interfaces launcher.start_process('machinekit -k ~/machinekit/configs/ARM.BeagleBone.CRAMPS/CRAMPS.ini') # start linuxcnc except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) # loop until script receives exit signal # or one of the started applications exited incorrectly # cleanup is done automatically while True:
import sys import os import subprocess import importlib import argparse from time import * from machinekit import launcher launcher.register_exit_handler() #launcher.set_debug_level(5) os.chdir(os.path.dirname(os.path.realpath(__file__))) try: launcher.check_installation() launcher.cleanup_session() launcher.install_comp('thermistor_check.comp') launcher.install_comp('reset.comp') # Video Streaming: you might need to create your own config # launcher.start_process("videoserver --ini ~/video.ini Webcam1") # Remote Control: Get a Machineface at ARM.Replicape.A4A.vel/ launcher.start_process("configserver -n Replicape ~/Machineface/") launcher.start_process('linuxcnc replicape.ini') except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) while True: sleep(1) launcher.check_processes()
import subprocess import importlib from machinekit import launcher from machinekit import config from time import * launcher.register_exit_handler() launcher.set_debug_level(5) os.chdir(os.path.dirname(os.path.realpath(__file__))) c = config.Config() os.environ["MACHINEKIT_INI"] = c.MACHINEKIT_INI try: launcher.check_installation( ) # make sure the Machinekit installation is sane launcher.cleanup_session() # cleanup a previous session # Uncomment and modify the following line if you create a configuration for the BeagleBone Black # launcher.load_bbio_file('myoverlay.bbio') # load a BeagleBone Black universal overlay file # Uncomment and modify the following line of you have custom HAL components # launcher.install_comp('gantry.comp') # install a comp HAL component if not already installed # launcher.install_comp('lineardeltajointscartesian.comp') launcher.start_process( "configserver ~/Machineface ~/Cetus/" ) # start the configserver with Machineface or an Cetus user interfaces launcher.start_process('linuxcnc prusa-i3_dev.ini') # start linuxcnc except subprocess.CalledProcessError: launcher.end_session() sys.exit(1) # loop until script receives exit signal # or one of the started applications exited incorrectly
parser.add_argument('-s', '--halscope', help='Starts the halscope', action='store_true') parser.add_argument('-m', '--halmeter', help='Starts the halmeter', action='store_true') 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: