解决问题:ERROR: cannot launch node of type [warehouse_ros/mongo_wrapper_ros.py]
2017-03-30 15:23
1006 查看
解决方式如下,找到ros的安装目录下边的share文件夹下边的warehouse_ros,我的电脑路径为:
/opt/ros/kinetic/share/warehouse_ros
添加一个python文件,名字为mongo_wrapper_ros.py,内容如下:
#!/usr/bin/env python
# This is a ros node wrapper for the mongod database server that
# sets various things using ROS parameters:
# - Parent namespace
# - warehouse_host: hostname used by db
# - warehouse_port: port used by db
# - Private namespace
# - ~database location: where the db is stored. Defaults to /tmp/db.
# - ~overwrite: whether to overwrite existing db. Defaults to false.
import roslib; roslib.load_manifest('warehouse_ros')
import rospy
import subprocess as sp
import sys
import os
from os import path
import shutil
def is_oneiric():
if path.exists('/etc/issue'):
rospy.logdebug('/etc/issue exists')
with open('/etc/issue') as f:
contents = f.readline()
rospy.logdebug('contents are {0}'.format(contents))
return '11.10' in contents
else:
rospy.logdebug('/etc/issue does not exist')
def is_lucid_or_maverick():
if path.exists('/etc/issue'):
rospy.logdebug('/etc/issue exists')
with open('/etc/issue') as f:
contents = f.readline()
rospy.logdebug('contents are {0}'.format(contents))
return '10.04' in contents or '10.10' in contents
else:
rospy.logdebug('/etc/issue does not exist')
def print_help_message():
print """
Usage: rosrun warehouse_ros_mongo mongo_wrapper_ros.py
Start the mongodb database server. Configured using the following ROS parameters.
Parameters in parent namespace
- warehouse_port: port used by db. Defaults to 27017.
- warehouse_host: doesn't directly affect server, but used by clients to know where the db is.
Parameters in parent namespace
- db_path: where the db is stored on the filesystem. Defaults to /tmp/db.
- database_path: same as db_path. For backward compatibility.
- overwrite: whether to overwrite existing database if it exists. Defaults to false.
"""
if __name__ == '__main__':
if '--help' in sys.argv:
print_help_message()
sys.exit()
rospy.init_node('mongodb')
path_param = rospy.get_param('~database_path' , '/tmp/db')
if path_param=='/tmp/db':
path_param = rospy.get_param('~db_path' , '/tmp/db')
dbpath = path.expanduser(path_param)
overwrite = rospy.get_param('~overwrite', False)
if '--repair' in sys.argv:
rospy.loginfo("Repairing database")
lock_file = '{0}/mongod.lock'.format(dbpath)
if path.exists(lock_file):
rospy.loginfo(" Removing lock file")
os.remove(lock_file)
sp.check_call(['mongodb', 'mongod', '--repair', '--dbpath', dbpath.format(dbpath)])
rospy.loginfo(" Successfully repaired.")
sys.exit(0)
# The defaults here should match the ones used by each client library
port = rospy.get_param('warehouse_port', 27017)
host = rospy.get_param('warehouse_host', 'localhost')
rospy.loginfo('Starting mongodb with db location {0} listening on {2}:{1}'.\
format(dbpath, port, host))
if overwrite and path.exists(dbpath):
shutil.rmtree(dbpath)
rospy.loginfo('Removed existing db at %s', dbpath)
if not path.exists(dbpath):
rospy.loginfo('{0} did not exist; creating it.'.format(dbpath))
os.makedirs(dbpath)
# OK, now actually run mongod
try:
cmd = "mongod"
sp.check_call("{2} --dbpath {0} --port {1}".\
format(dbpath, port, cmd).split())
except sp.CalledProcessError as e:
if e.returncode==12:
rospy.loginfo("Ignoring mongod's nonstandard return code of 12")
else:
rospy.logerr("Mongo process exited with error code {0}".format(e.returncode))
except OSError, e:
rospy.logerr("Execution failed: %s", e)
/opt/ros/kinetic/share/warehouse_ros
添加一个python文件,名字为mongo_wrapper_ros.py,内容如下:
#!/usr/bin/env python
# This is a ros node wrapper for the mongod database server that
# sets various things using ROS parameters:
# - Parent namespace
# - warehouse_host: hostname used by db
# - warehouse_port: port used by db
# - Private namespace
# - ~database location: where the db is stored. Defaults to /tmp/db.
# - ~overwrite: whether to overwrite existing db. Defaults to false.
import roslib; roslib.load_manifest('warehouse_ros')
import rospy
import subprocess as sp
import sys
import os
from os import path
import shutil
def is_oneiric():
if path.exists('/etc/issue'):
rospy.logdebug('/etc/issue exists')
with open('/etc/issue') as f:
contents = f.readline()
rospy.logdebug('contents are {0}'.format(contents))
return '11.10' in contents
else:
rospy.logdebug('/etc/issue does not exist')
def is_lucid_or_maverick():
if path.exists('/etc/issue'):
rospy.logdebug('/etc/issue exists')
with open('/etc/issue') as f:
contents = f.readline()
rospy.logdebug('contents are {0}'.format(contents))
return '10.04' in contents or '10.10' in contents
else:
rospy.logdebug('/etc/issue does not exist')
def print_help_message():
print """
Usage: rosrun warehouse_ros_mongo mongo_wrapper_ros.py
Start the mongodb database server. Configured using the following ROS parameters.
Parameters in parent namespace
- warehouse_port: port used by db. Defaults to 27017.
- warehouse_host: doesn't directly affect server, but used by clients to know where the db is.
Parameters in parent namespace
- db_path: where the db is stored on the filesystem. Defaults to /tmp/db.
- database_path: same as db_path. For backward compatibility.
- overwrite: whether to overwrite existing database if it exists. Defaults to false.
"""
if __name__ == '__main__':
if '--help' in sys.argv:
print_help_message()
sys.exit()
rospy.init_node('mongodb')
path_param = rospy.get_param('~database_path' , '/tmp/db')
if path_param=='/tmp/db':
path_param = rospy.get_param('~db_path' , '/tmp/db')
dbpath = path.expanduser(path_param)
overwrite = rospy.get_param('~overwrite', False)
if '--repair' in sys.argv:
rospy.loginfo("Repairing database")
lock_file = '{0}/mongod.lock'.format(dbpath)
if path.exists(lock_file):
rospy.loginfo(" Removing lock file")
os.remove(lock_file)
sp.check_call(['mongodb', 'mongod', '--repair', '--dbpath', dbpath.format(dbpath)])
rospy.loginfo(" Successfully repaired.")
sys.exit(0)
# The defaults here should match the ones used by each client library
port = rospy.get_param('warehouse_port', 27017)
host = rospy.get_param('warehouse_host', 'localhost')
rospy.loginfo('Starting mongodb with db location {0} listening on {2}:{1}'.\
format(dbpath, port, host))
if overwrite and path.exists(dbpath):
shutil.rmtree(dbpath)
rospy.loginfo('Removed existing db at %s', dbpath)
if not path.exists(dbpath):
rospy.loginfo('{0} did not exist; creating it.'.format(dbpath))
os.makedirs(dbpath)
# OK, now actually run mongod
try:
cmd = "mongod"
sp.check_call("{2} --dbpath {0} --port {1}".\
format(dbpath, port, cmd).split())
except sp.CalledProcessError as e:
if e.returncode==12:
rospy.loginfo("Ignoring mongod's nonstandard return code of 12")
else:
rospy.logerr("Mongo process exited with error code {0}".format(e.returncode))
except OSError, e:
rospy.logerr("Execution failed: %s", e)
相关文章推荐
- roslaunch error: ERROR: cannot launch node of type
- ROS Error: Cannot Launch Node of Type
- 解决vue2.0路由 TypeError: Cannot read property 'matched' of undefined 的错误问题
- Uncaught TypeError: Cannot read property 'click' of null问题的解决
- 解决discuz与jquery不兼容问题——下拉列表不能用(Uncaught TypeError: Cannot set property 'position' of undefined)
- 表单提交Erro: formSubmit.html:** Uncaught TypeError: Cannot set property 'action' of null解决
- easyui:Cannot read property 'nodeName' of null问题的解决
- Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node 解决办法
- Uncaught TypeError: Cannot set property ' ' of null 错误解决
- ASP.NET MVC运行出现Uncaught TypeError: Cannot set property __MVC_FormValidation of null的解决方法
- Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#<Object>‘的解决方法
- 解决sweetalert 无故报错 elem.className.replace Uncaught TypeError: Cannot read property 'className' of ...
- Python3.5 TypeError: cannot use a string pattern on a bytes-like object问题解决
- Error:The number of method references in a .dex file cannot exceed 64K 问题解决
- 关于js Uncaught TypeError: Cannot read property 'style' of null 问题
- 遇到问题-----mongodb-------Uncaught TypeError: Cannot read property 'value' of undefined
- angular-cli启动问题——TypeError: Cannot read property 'newLine' of undefined
- ValueError: cannot reshape array of size 9912406 into shape (60000,28,28,1) 问题解决
- ASP.NET MVC运行出现Uncaught TypeError: Cannot set property __MVC_FormValidation of null的解决方法
- 关于Uncaught TypeError: Cannot read property 'toLowerCase' of undefined的问题