Пример #1
0
def roscreatepkg_main():
    from optparse import OptionParser    
    parser = OptionParser(usage="usage: %prog <package-name> [dependencies...]", prog=NAME)
    options, args = parser.parse_args()
    if not args:
        parser.error("you must specify a package name and optionally also list package dependencies")
    package = args[0]

    if not roslib.names.is_legal_resource_base_name(package):
        parser.error("illegal package name: %s\nNames must start with a letter and contain only alphanumeric characters\nand underscores."%package)

    # validate dependencies and turn into XML
    depends = args[1:]
    uses_roscpp = 'roscpp' in depends
    uses_rospy = 'rospy' in depends

    rospack = RosPack()
    for d in depends:
        try:
            rospack.get_path(d)
        except ResourceNotFound:
            print("ERROR: dependency [%s] cannot be found"%d, file=sys.stderr)
            sys.exit(1)

    depends = u''.join([u'  <depend package="%s"/>\n'%d for d in depends])

    if not on_ros_path(os.getcwd()):
        print('!'*80+"\nWARNING: current working directory is not on ROS_PACKAGE_PATH!\nPlease update your ROS_PACKAGE_PATH environment variable.\n"+'!'*80, file=sys.stderr)
    if type(package) == str:
        package = package.decode('utf-8')
    create_package(package, author_name(), depends, uses_roscpp=uses_roscpp, uses_rospy=uses_rospy)
def create_qt_package(package, depends):
    
    p = os.path.abspath(package)
    os.makedirs(os.path.join(p,"src"))
    os.makedirs(os.path.join(p,"include"))
    os.makedirs(os.path.join(p,"include",package))
    os.makedirs(os.path.join(p,"resources"))
    os.makedirs(os.path.join(p,"resources","images"))
    os.makedirs(os.path.join(p,"ui"))
    print "Created qt package directories."

    # Qt text files
    templates = get_qt_text_templates(package)
    for filename, template in templates.iteritems():
        contents = instantiate_template(template, package, package, package, author_name(), depends)
        try:
            p = os.path.abspath(os.path.join(package, filename))
            f = open(p, 'w')
            f.write(contents)
            print "Created package file", p
        finally:
            f.close()
    # Qt binary files
    shutil.copy(os.path.join(roslib.packages.get_pkg_dir('eros_python_tools'),'templates','qt','resources','images','icon.png'),
                os.path.join(os.path.abspath(package),'resources','images','icon.png'))
Пример #3
0
def roscreatepkg_main():
    from optparse import OptionParser    
    parser = OptionParser(usage="usage: %prog <package-name> [dependencies...]", prog=NAME)
    options, args = parser.parse_args()
    if not args:
        parser.error("you must specify a package name and optionally also list package dependencies")
    package = args[0]

    if not roslib.names.is_legal_resource_base_name(package):
        parser.error("illegal package name: %s\nNames must start with a letter and contain only alphanumeric characters\nand underscores."%package)

    # validate dependencies and turn into XML
    depends = args[1:]
    uses_roscpp = 'roscpp' in depends
    uses_rospy = 'rospy' in depends

    rospack = RosPack()
    for d in depends:
        try:
            rospack.get_path(d)
        except ResourceNotFound:
            print("ERROR: dependency [%s] cannot be found"%d, file=sys.stderr)
            sys.exit(1)

    depends = u''.join([u'  <depend package="%s"/>\n'%d for d in depends])

    if not on_ros_path(os.getcwd()):
        print('!'*80+"\nWARNING: current working directory is not on ROS_PACKAGE_PATH!\nPlease update your ROS_PACKAGE_PATH environment variable.\n"+'!'*80, file=sys.stderr)
    if type(package) == str:
        package = package.decode('utf-8')
    create_package(package, author_name(), depends, uses_roscpp=uses_roscpp, uses_rospy=uses_rospy)
Пример #4
0
def roscreatestack_main():
    from optparse import OptionParser    
    parser = OptionParser(usage="usage: %prog <path-to-stack>", prog=NAME)
    parser.add_option("--show-deps", 
                      dest="show_deps", default=False,
                      action="store_true",
                      help="show stack dependencies, instead of generating stack.xml")
    options, args = parser.parse_args()
    if not args:
        parser.error("you must specify the path to a stack")
    stack_dir = args[0]
    stack = os.path.basename(os.path.abspath(stack_dir))

    if not on_ros_path(stack_dir):
        print("ERROR: roscreate-stack only work in directories in ROS_PACKAGE_PATH\nPlease update your ROS_PACKAGE_PATH environment variable.", file=sys.stderr)
        sys.exit(1)
    
    try:
        depends, licenses = compute_stack_depends_and_licenses(stack_dir)
    except rospkg.ResourceNotFound as e:
        print("Cannot find resource: %s"%str(e), file=sys.stderr)
        sys.exit(1)

    # defaults
    stack_manifest = None
    author = "Maintained by %s"%author_name()

    if not options.show_deps:
      # Check for existing stack.xml
      stack_xml_path = os.path.join(stack_dir, 'stack.xml')
      if os.path.exists(stack_xml_path):
          import shutil
          stack_xml_path_bak = os.path.join(stack_dir, 'stack.xml.bak')
          print('Backing up existing stack.xml to %s'%(stack_xml_path_bak))
          shutil.copyfile(stack_xml_path, stack_xml_path_bak)

      try:
          # load existing stack.xml properties (soft fail if there are issues with existing file)
          stack_manifest = rospkg.manifest.parse_manifest_file(stack_dir, rospkg.STACK_FILE)
          author = stack_manifest.author
      except:
          pass
  
    create_stack(stack, stack_dir, stack_manifest, author, depends, licenses, options.show_deps)
Пример #5
0
def roscreatepkg_main():
    from optparse import OptionParser    
    parser = OptionParser(usage="usage: %prog <package-name> [dependencies...]", prog=NAME)
    options, args = parser.parse_args()
    if not args:
        parser.error("you must specify a package name and optionally also list package dependencies")
    package = args[0]

    ###### BRSU EXTENSION ###############################################################
    if (not package.startswith('raw_')) and (not package.startswith('brsu_')) and (not package.startswith('hbrs_')):
        parser.error("illegal package name: %s\n\nPackage name must start either with 'raw_', 'brsu_' or 'hbrs_'"%package)

    if not roslib.names.is_legal_resource_base_name(package):
        parser.error("illegal package name: %s\n\nNames must start with a letter and contain only alphanumeric characters\nand underscores."%package)

    # validate dependencies and turn into XML
    depends = args[1:]
    uses_roscpp = 'roscpp' in depends
    uses_rospy = 'rospy' in depends

    ###### BRSU EXTENSION ###############################################################
    depends.append("roscpp")
    depends.append("sensor_msgs")
    depends.append("std_srvs")
    
    for d in depends:
        try:
            roslib.packages.get_pkg_dir(d)
        except roslib.packages.InvalidROSPkgException:
            print >> sys.stderr, "ERROR: dependency [%s] cannot be found"%d
            sys.exit(1)
    depends = u''.join([u'  <depend package="%s"/>\n'%d for d in depends])


    if not on_ros_path(os.getcwd()):
        print >> sys.stderr, '!'*80+"\nWARNING: current working directory is not on ROS_PACKAGE_PATH!\nPlease update your ROS_PACKAGE_PATH environment variable.\n"+'!'*80
    if type(package) == str:
        package = package.decode('utf-8')
    create_package(package, author_name(), depends, uses_roscpp=uses_roscpp, uses_rospy=uses_rospy)
Пример #6
0
    if not on_ros_path(stack_dir):
        print >> sys.stderr, "ERROR: roscreate-stack only work in directories in ROS_PACKAGE_PATH\nPlease update your ROS_PACKAGE_PATH environment variable."
        sys.exit(1)
    
    try:
        depends, licenses = compute_stack_depends_and_licenses(stack_dir)
    except roslib.packages.InvalidROSPkgException, e:
        print >> sys.stderr, str(e)
        sys.exit(1)

    if not options.show_deps:
      # Check for existing stack.xml
      stack_xml_path = os.path.join(stack_dir, 'stack.xml')
      if os.path.exists(stack_xml_path):
          import shutil
          stack_xml_path_bak = os.path.join(stack_dir, 'stack.xml.bak')
          print 'Backing up existing stack.xml to %s'%stack_xml_path_bak
          shutil.copyfile(stack_xml_path, stack_xml_path_bak)

          # load existing stack.xml properties
          stack_manifest = roslib.stack_manifest.parse_file(stack_xml_path)
          author = stack_manifest.author
      else:
          stack_manifest = None
          author = "Maintained by %s"%author_name()
  
    create_stack(stack, stack_dir, stack_manifest, author, depends, licenses, options.show_deps)

if __name__ == "__main__":
    roscreatestack_main()
Пример #7
0
def test_author_name():
    from roscreate.core import author_name
    val = author_name()
    assert val, val
Пример #8
0
#!/usr/bin/python
import sys
import os
import roslib
from ros import roscreate
from roscreate.core import read_template, author_name, on_ros_path
from Cheetah.Template import Template

if __name__ == "__main__":
	packagename = sys.argv[1]
	print "creating ros package"
	depends = ["ros_simulink"]
	roscreate.roscreatepkg.create_package(packagename, author_name(), depends, uses_roscpp=True, uses_rospy=True)
	print "creating folder structure"
	os.mkdir(packagename+"/simulink")
	os.mkdir(packagename+"/ros")
	os.mkdir(packagename+"/rtw")
	print "generating configured mdl file"
	template_values = {'simulinkname': packagename}
	tmpl = Template( file = roslib.packages.get_pkg_dir("ros_simulink")+"/files/configured_mdl_file.template", searchList = (template_values,) )
	filename = packagename+"/simulink/"+packagename+".mdl"
	f = open(filename, 'w')
	f.write(str(tmpl))
	f.close()
	print "finished. Now start a rosmatlab session and use 'rosrun ros_simulink load "+packagename+"' to load the simulink model"
Пример #9
0
def test_author_name():
    from roscreate.core import author_name
    val = author_name()
    assert val, val