ROS melodic android_apps移植

发布于:2024-03-28 ⋅ 阅读:(14) ⋅ 点赞:(0)

目录

环境

遇到问题

问题一 Waiting for maps ...

问题二 Attempting to connect to mongodb @ localhost:27017

问题三 Insert map failed

问题四  保存同名地图错误

 mongo


环境

Ubuntu 18.04 + ROS melodic

Windows 10 + Android Studio 2020.3.1 Patch 3

遇到问题

问题一 Waiting for maps ...

GitHub - rosjava/android_apps: Applications built on top of the rosjava android libraries.中map_manager、map_nav等APP一直提示wait map list。make_a_map保存地图提示No such service /save_map of type world_canvas_msgs/SaveMap。

通过tcpdump -i any -n -A发现Android App一直在查找/list_maps服务,ROS这边则一直返回-1 no provider错误。

安装mongodb-server,下载world_canvas_server源码,编译。

$ sudo apt-get install mongodb-server
$ cd catkin_ws/src
$ git clone https://github.com/corot/world_canvas.git
Cloning into 'world_canvas'...
remote: Enumerating objects: 946, done.
remote: Total 946 (delta 0), reused 0 (delta 0), pack-reused 946
Receiving objects: 100% (946/946), 597.61 KiB | 1.30 MiB/s, done.
Resolving deltas: 100% (605/605), done.
$ git clone https://github.com/corot/world_canvas_libs.git
Cloning into 'world_canvas_libs'...
remote: Enumerating objects: 642, done.
remote: Total 642 (delta 0), reused 0 (delta 0), pack-reused 642
Receiving objects: 100% (642/642), 103.60 KiB | 353.00 KiB/s, done.
Resolving deltas: 100% (354/354), done.
$ git clone https://github.com/corot/world_canvas_msgs.git
Cloning into 'world_canvas_msgs'...
remote: Enumerating objects: 161, done.
remote: Total 161 (delta 0), reused 0 (delta 0), pack-reused 161
Receiving objects: 100% (161/161), 19.92 KiB | 295.00 KiB/s, done.
Resolving deltas: 100% (89/89), done.
$ cd ..
$ catkin_make
$ source devel/setup.bash
$ roslaunch world_canvas_server world_canvas_server.launch
... logging to /home/freeware/.ros/log/0da06d8a-4b44-11ec-aba4-c85b76ac404e/roslaunch-Z0211122-21558.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://Z0211122:40661/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.12
 * /world_canvas_server/auto_save_map: False
 * /world_canvas_server/start_map_manager: True

NODES
  /
    world_canvas_server (world_canvas_server/world_canvas_server)

auto-starting new master
process[master]: started with pid [21568]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 0da06d8a-4b44-11ec-aba4-c85b76ac404e
process[rosout-1]: started with pid [21581]
started core service [/rosout]
process[world_canvas_server-2]: started with pid [21584]
Traceback (most recent call last):
  File "/data/ros/map/src/world_canvas/world_canvas_server/scripts/world_canvas_server", line 6, in <module>
    import world_canvas_server
  File "/data/ros/map/devel/lib/python2.7/dist-packages/world_canvas_server/__init__.py", line 34, in <module>
    exec(__fh.read())
  File "<string>", line 1, in <module>
  File "/data/ros/map/src/world_canvas/world_canvas_server/src/world_canvas_server/annotations_server.py", line 40, in <module>
    import warehouse_ros as wr
ImportError: No module named warehouse_ros
[world_canvas_server-2] process has died [pid 21584, exit code 1, cmd /data/ros/map/src/world_canvas/world_canvas_server/scripts/world_canvas_server false __name:=world_canvas_server __log:=/home/freeware/.ros/log/0da06d8a-4b44-11ec-aba4-c85b76ac404e/world_canvas_server-2.log].
log file: /home/freeware/.ros/log/0da06d8a-4b44-11ec-aba4-c85b76ac404e/world_canvas_server-2*.log

问题二 Attempting to connect to mongodb @ localhost:27017

下载warehouse_ros,切换到0.8.8版本。编译运行,一直提示Attempting to connect to mongodb @ localhost:27017。

$ cd catkin_ws/src
$ git clone https://github.com/ros-planning/warehouse_ros.git
Cloning into 'warehouse_ros'...
remote: Enumerating objects: 687, done.
remote: Counting objects: 100% (112/112), done.
remote: Compressing objects: 100% (86/86), done.
remote: Total 687 (delta 55), reused 42 (delta 15), pack-reused 575
Receiving objects: 100% (687/687), 164.55 KiB | 1.16 MiB/s, done.
Resolving deltas: 100% (381/381), done.
$ cd warehouse_ros
$ git checkout 0.8.8
Note: checking out '0.8.8'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at cb760de 0.8.8
$ cd ../..
$ catkin_make
$ roslaunch world_canvas_server world_canvas_server.launch
... logging to /home/freeware/.ros/log/4582f280-4b45-11ec-aba4-c85b76ac404e/roslaunch-Z0211122-22169.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://Z0211122:45963/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.12
 * /world_canvas_server/auto_save_map: False
 * /world_canvas_server/start_map_manager: True

NODES
  /
    world_canvas_server (world_canvas_server/world_canvas_server)

auto-starting new master
process[master]: started with pid [22179]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 4582f280-4b45-11ec-aba4-c85b76ac404e
process[rosout-1]: started with pid [22192]
started core service [/rosout]
process[world_canvas_server-2]: started with pid [22195]
[INFO] [1637552144.290101]: Attempting to connect to mongodb @ localhost:27017
[INFO] [1637552146.296010]: Attempting to connect to mongodb @ localhost:27017
[INFO] [1637552148.302977]: Attempting to connect to mongodb @ localhost:27017
^C[world_canvas_server-2] killing on exit
Traceback (most recent call last):
  File "/data/ros/map/src/world_canvas/world_canvas_server/scripts/world_canvas_server", line 15, in <module>
    world_canvas_server.AnnotationsServer()
  File "/data/ros/map/src/world_canvas/world_canvas_server/src/world_canvas_server/annotations_server.py", line 61, in __init__
    wr.MessageCollection("world_canvas", "worlds", WorldCanvas)
  File "/data/ros/map/src/warehouse_ros/src/warehouse_ros/message_collection.py", line 76, in __init__
    self.db = self.conn[db]
AttributeError: MessageCollection instance has no attribute 'conn'
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

进行以下修改后可以正常运行world_canvas_server。

--- a/src/warehouse_ros/message_collection.py
+++ b/src/warehouse_ros/message_collection.py
@@ -65,7 +65,8 @@ class MessageCollection:
         self.port = db_port or rospy.get_param('warehouse_port', 27017)
         while not rospy.is_shutdown():
             try:
-                self.conn = pm.Connection(self.host, self.port)
+                self.conn = pm.MongoClient(self.host, self.port)
                 break
             except:
                 rospy.loginfo( "Attempting to connect to mongodb @ {0}:{1}".\
$ roslaunch world_canvas_server world_canvas_server.launch
... logging to /home/freeware/.ros/log/e5710f98-4b45-11ec-aba4-c85b76ac404e/roslaunch-Z0211122-22361.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://Z0211122:41785/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.12
 * /world_canvas_server/auto_save_map: False
 * /world_canvas_server/start_map_manager: True

NODES
  /
    world_canvas_server (world_canvas_server/world_canvas_server)

auto-starting new master
process[master]: started with pid [22371]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to e5710f98-4b45-11ec-aba4-c85b76ac404e
process[rosout-1]: started with pid [22384]
started core service [/rosout]
process[world_canvas_server-2]: started with pid [22387]
[INFO] [1637552412.649973]: Map manager : initialized.
[INFO] [1637552412.651540]: Annotations server : initialized.

问题三 Insert map failed

用make_a_map App保存地图时,提示如下错误。

Insert map failed: __init__() got an unexpected keyword argument 'safe'

--- a/world_canvas_server/src/world_canvas_server/map_manager.py
+++ b/world_canvas_server/src/world_canvas_server/map_manager.py
@@ -269,7 +269,7 @@ class RecSession:

         if not self.map_saved:
             try:
-                self.parent.map_collection.insert(self.map, self.metadata, safe=True)
+                self.parent.map_collection.insert(self.map, self.metadata)
                 self.metadata = self.parent.get_metadata(self.metadata['uuid'])
                 if self.metadata is None:
                     # This should not happen, obviously

问题四  保存同名地图错误

保存同名地图提示如下错误:

[ERROR] [1637559038.185892]: Error processing request: __init__() got an unexpected keyword argument 'safe'
['Traceback (most recent call last):\n', '  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 632, in _handle_request\n    response = convert_return_to_response(self.handler(request), self.response_class)\n', '  File "/data/ros/catkin_ws/src/world_canvas/world_canvas_server/src/world_canvas_server/map_manager.py", line 226, in save_map\n    if self.rec_session.save(request.map_name) == False:\n', '  File "/data/ros/catkin_ws/src/world_canvas/world_canvas_server/src/world_canvas_server/map_manager.py", line 288, in save\n    self.parent.map_collection.update(self.metadata, msg=self.map)\n', '  File "/data/ros/catkin_ws/src/warehouse_ros/src/warehouse_ros/message_collection.py", line 186, in update\n    self.coll.save(entry, safe=True)\n', '  File "/usr/lib/python2.7/dist-packages/pymongo/collection.py", line 2913, in save\n    write_concern = WriteConcern(**kwargs)\n', "TypeError: __init__() got an unexpected keyword argument 'safe'\n"]

修改如下: 

--- a/src/warehouse_ros/message_collection.py
+++ b/src/warehouse_ros/message_collection.py
@@ -182,7 +182,7 @@ class MessageCollection:
             entry['blob_id'] = new_msg_id
         if metadata:
             entry.update(metadata)
-        self.coll.save(entry, safe=True)
+        self.coll.save(entry)
         if old_blob_id:
             self.fs.delete(old_blob_id)

 mongo

$ mongo
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
Server has startup warnings:
2021-11-22T09:19:17.435+0800 I STORAGE  [initandlisten]
2021-11-22T09:19:17.435+0800 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2021-11-22T09:19:17.435+0800 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-11-22T09:19:18.620+0800 I CONTROL  [initandlisten]
2021-11-22T09:19:18.621+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2021-11-22T09:19:18.621+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2021-11-22T09:19:18.621+0800 I CONTROL  [initandlisten]
> help
        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        sh.help()                    sharding helpers
        rs.help()                    replica set helpers
        help admin                   administrative help
        help connect                 connecting to a db help
        help keys                    key shortcuts
        help misc                    misc things to know
        help mr                      mapreduce

        show dbs                     show database names
        show collections             show collections in current database
        show users                   show users in current database
        show profile                 show most recent system.profile entries with time >= 1ms
        show logs                    show the accessible logger names
        show log [name]              prints out the last segment of log in memory, 'global' is default
        use <db_name>                set current database
        db.foo.find()                list objects in collection foo
        db.foo.find( { a : 1 } )     list objects in foo where a == 1
        it                           result of the last line evaluated; use to further iterate
        DBQuery.shellBatchSize = x   set default number of items to display on shell
        exit                         quit the mongo shell
> show dbs
admin         0.000GB
config        0.000GB
local         0.000GB
world_canvas  0.002GB
> use world_canvas
switched to db world_canvas
> show collections
annotations
annotations_data
fs.chunks
fs.files
maps
worlds
> db.maps.find()
{ "_id" : ObjectId("619b2a8b5b65bf15c79b5c8c"), "blob_id" : ObjectId("619b2a8b5b65bf15c79b5c80"), "uuid" : "f55d993c-f6d8-4e42-9005-8680ff61794f", "creation_time" : 1637558923.118822, "session_id" : "1637558903.25", "name" : "six" }
{ "_id" : ObjectId("619b2bec5b65bf1c901e30be"), "blob_id" : ObjectId("619b2bec5b65bf1c901e30b2"), "uuid" : "85933c68-81a0-4318-ab6f-436400a848a0", "creation_time" : 1637559276.834532, "session_id" : "1637559262.34", "name" : "six" }
本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到