-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from dgerod/develop
Scene Database node to access ROS Server in safe way.
- Loading branch information
Showing
23 changed files
with
612 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(rosplan_pytools) | ||
|
||
find_package(catkin REQUIRED) | ||
catkin_package(CATKIN_DEPENDS | ||
rospy std_msgs mongodb_store | ||
rosplan_dispatch_msgs rosplan_knowlege_msgs) | ||
find_package(catkin REQUIRED COMPONENTS | ||
rospy genmsg message_generation actionlib_msgs std_msgs | ||
rosplan_dispatch_msgs rosplan_knowledge_msgs | ||
) | ||
|
||
add_service_files( | ||
FILES | ||
AddElement.srv | ||
DiagnosticsDB.srv | ||
FindElement.srv | ||
RemoveElement.srv | ||
ResetDB.srv | ||
RetrieveElements.srv | ||
UpdateElement.srv | ||
) | ||
|
||
catkin_python_setup() | ||
|
||
generate_messages(DEPENDENCIES | ||
std_msgs rosplan_dispatch_msgs rosplan_knowledge_msgs | ||
) | ||
|
||
catkin_package( | ||
LIBRARIES ${PROJECT_NAME} | ||
CATKIN_DEPENDS rospy std_msgs mongodb_store | ||
rosplan_dispatch_msgs rosplan_knowlege_msgs | ||
DEPENDS | ||
CATKIN_DEPENDS rospy genmsg message_generation message_runtime std_msgs | ||
rosplan_dispatch_msgs rosplan_knowledge_msgs | ||
) | ||
|
||
install(DIRECTORY src | ||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) | ||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import rospy | ||
from rosplan_pytools.controller.nodes import scene_database | ||
|
||
|
||
def main(): | ||
|
||
try: | ||
scene_database.start_node("scene_database") | ||
|
||
except rospy.ROSInterruptException: | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
class Element(object): | ||
|
||
@staticmethod | ||
def extract_ros_type(message): | ||
return message._type | ||
|
||
def __init__(self, value=None, metadata=""): | ||
|
||
self._metadata = metadata | ||
|
||
if value is not None: | ||
self._ros_message_value = value | ||
self._ros_message_type = self.extract_ros_type(value) | ||
else: | ||
self._ros_message_value = None | ||
self._ros_message_type = "" | ||
|
||
def __str__(self): | ||
|
||
if self._ros_message_value is not None: | ||
value = self._ros_message_value | ||
else: | ||
value = "" | ||
|
||
return "%s, %s, %s" % (self._ros_message_type, value, self._metadata) | ||
|
||
def __eq__(self, other): | ||
|
||
return self._ros_message_type == other._ros_message_type | ||
|
||
def clean(self): | ||
self._metadata = "" | ||
self._ros_message_value = None | ||
self._ros_message_type = "" | ||
|
||
def is_valid(self): | ||
return self._ros_message_value is not None | ||
|
||
def metadata(self): | ||
return self._metadata | ||
|
||
def value(self): | ||
return self._ros_message_value | ||
|
||
def type(self): | ||
return self._ros_message_type | ||
|
27 changes: 27 additions & 0 deletions
27
src/rosplan_pytools/controller/common/sdb_element_converter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
from rosplan_pytools.common import message_converter | ||
from rosplan_pytools.controller.common.sdb_element import Element | ||
|
||
|
||
def sdb_element_to_string(element): | ||
|
||
if not isinstance(element, Element): | ||
raise TypeError | ||
|
||
dict_ = {'msg_type': element.type(), | ||
'msg_value': message_converter.convert_ros_message_to_dictionary(element.value())} | ||
|
||
value = json.dumps(dict_) | ||
return element.metadata(), value | ||
|
||
|
||
def string_to_sdb_element(metadata, value): | ||
|
||
if not isinstance(metadata, str) or not isinstance(value, str): | ||
raise TypeError | ||
|
||
dict_ = json.loads(value) | ||
msg_value = message_converter.convert_dictionary_to_ros_message(dict_['msg_type'], | ||
dict_['msg_value'], | ||
'message') | ||
return Element(msg_value, metadata) |
Empty file.
Oops, something went wrong.