Example #1
0
	def on_data_passing(self, data):
		"""
		Callback for the subscribed topic. Receives data from js client and saves the configuration on mongoDB using label @robot_side
			@params: RosMessage of type StringArray
		"""
		#Write to db
		db = mongodb_interface.MongoDBInterface()
		db.write_robot_sv(data, "robot_side") ## Label for reading
 def __init__(self):
     self._db = mongodb_interface.MongoDBInterface()
     self._message = None  # The message containing all state var
     self._publicators = {
     }  # key: SV, value: tuples (topic, type, ). corresponds to msgs published by planner for each SV
     self._subscriptors = {
     }  # key: SV, value: tuples (topic, type, ). corresponds to msgs subscribed by planner for each SV
     self.build_java_methods()
 def get_state_var(self):
     '''Reads data from JSON file and extracts the state variables only'''
     state_vars = []
     db = mongodb_interface.MongoDBInterface()
     message = db.read_robot_sv("planner_side")
     for sv in message:
         state_vars.append(json.loads(sv))
     return state_vars
Example #4
0
label = "test_interface"  ## Label for writing and reading
d = [
    "{{field1: topo}, {field2: gigio}}",
    "{{field1: gatto}, {field2: silvestro}}"
]
d2 = [
    "{{field1: topo}, {field2: gigio}}",
    "{{field1: gatto}, {field2: silvestro}}",
    "{{field1: cocco}, {field2: bill}}"
]

data = np.array(d, dtype=np.str)
data2 = np.array(d2, dtype=np.str)

db = mongodb_interface.MongoDBInterface()


class TestDataOnFilePersistence(unittest.TestCase):
    def test_normal_flow(self):
        db.write_robot_sv(data, label)
        info = db.read_robot_sv(label)
        for i in xrange(len(data)):
            self.assertEqual(data[i], info[i],
                             "Value read and wrote are different.")

    def test_different_data(self):
        db.write_robot_sv(data2, label)
        info = db.read_robot_sv(label)
        self.assertNotEqual(len(data), len(info),
                            "Value read and wrote must be different.")
Example #5
0
	def __init__(self):
		self._db = mongodb_interface.MongoDBInterface()
		self._syncronization = []
		self._timelines = []
Example #6
0
	def __init__(self):
		self._pub = rospy.Publisher('config_plan_side_sender',numpy_msg(StringArray), queue_size=10)
		self._db = mongodb_interface.MongoDBInterface()