DJIRonin_NodeJS.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import rospy
00003 from Naked.toolshed.shell import execute_js
00004 import subprocess, signal
00005 import os
00006 
00007 __author__ = 'Itamar Eliakim'
00008 
00009 class DJIRonin_NodeJS():
00010     def __init__(self):
00011         rospy.init_node("DJI_Ronin_NodeJS")
00012         rospy.loginfo("Starting DJI Ronin NodeJS Server")
00013         #self.startApp = subprocess.Popen("adb shell am start -n com.dji.gimbal/com.dji.gimbal.ui.HomeActivity", shell=True, stdout=subprocess.PIPE).stdout.read()
00014         self.getROSpath = subprocess.Popen("echo $ROS_PACKAGE_PATH", shell=True, stdout=subprocess.PIPE).stdout.read().split(':')[0]
00015         self.success = execute_js(self.getROSpath + '/dji_ronin/scripts/sji-android-screen-capture/bin/asc.js')
00016         if self.success==False:
00017             self.killserver()
00018         else:
00019             rospy.loginfo("ROS DJI Ronin NodeJS Server is ON")
00020         ### If doesnt work - ps aux | grep node -> kill -9 proccessid
00021         rospy.spin()
00022 
00023 
00024     def killserver(self):
00025         rospy.loginfo("Kill old server!")
00026         p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
00027         out, err = p.communicate()
00028 
00029         for line in out.splitlines():
00030             if 'node' in line:
00031                 pid = int(line.split(None, 1)[0])
00032                 os.kill(pid, signal.SIGKILL)
00033         self.success = execute_js(os.getcwd() + '/sji-android-screen-capture/bin/asc.js')
00034         rospy.loginfo("ROS DJI Ronin NodeJS Server is ON")
00035 if __name__ == "__main__":
00036     DJIRonin_NodeJS()
00037 


dji_ronin
Author(s):
autogenerated on Sat Jun 8 2019 20:15:31