def spawnGenEnvironment(req): initial_pose = Pose() initial_pose.position.x = 0 initial_pose.position.y = 0 initial_pose.position.z = 0 quaternion = tf.transformations.quaternion_from_euler(0, 0, 0) initial_pose.orientation.x = quaternion[0] initial_pose.orientation.y = quaternion[1] initial_pose.orientation.z = quaternion[2] initial_pose.orientation.w = quaternion[3] f = open( '/home/knmcguire/Software/catkin_ws/src/indoor_environment_generator/models/random_generated_environment/test_model.sdf', 'r') sdff = f.read() rospy.wait_for_service('gazebo/spawn_sdf_model') spawn_model_prox = rospy.ServiceProxy('gazebo/spawn_sdf_model', SpawnModel) spawn_model_prox("some_robo_name", sdff, "robotos_name_space", initial_pose, "world") msg = Trigger() msg.succes = True msg.message = "jeej" return []
def _toggle(req): global _ctrl_on _ctrl_on = not _ctrl_on srv = Trigger() srv.success = True srv.message = "Controller is {}".format(_ctrl_on) return TriggerResponse(True, "Controller is {}".format(_ctrl_on))
def callback(self, message): self.latest_message = message self.detection_dict = self.four_sector_detection() crashed, direction = self.has_crashed(): if crashed: trigger = Trigger() trigger.success = False trigger.message = direction self.crash_publisher.publish(trigger)
def command_callback(self, msg): try: if msg.isValid(): if msg.getReceiver() == self.command_proxy_server_name: command = msg.getCommand() try: data = msg.getData("data") except: data = None Trigger(data) Logger.log(self.command_proxy_server_name.replace("_supervisor", "") + ": " + command) else: self.command_server_last_message = None else: self.command_server_last_message = None Logger.error(self.command_proxy_server_name.replace("_supervisor", "") + ": invalid message!!") self.sendResponse(False) except Exception as e: self.sendResponse(False)
def timeout(self, event): """Stop recording when the timeout is reached, callback function""" if self.recording: rospy.logwarn("Reached recording limit, stopping recording!") self.stop_recording(Trigger())
def handle(req): arming(True) rospy.sleep(0.5) arming(False) r = Trigger() return (True, 'ok')
# Create timer event and publish. period = float(rospy.get_param("~period")) # Create lock for msgs. lock = Lock() # Setup services and publish mission. rospy.Service("get_active_mission", Trigger, get_active_mission) rospy.Service("get_mission_by_id", GetMissionByID, get_mission_by_id) # Get mission to begin publishing. This is the first mission published. mission_id = rospy.get_param("~id") msgs = None retry_rate = rospy.Rate(1) while msgs is None and not rospy.is_shutdown(): # If id is negative then it is default and non existent. if mission_id >= 0: req = GetMissionByID() req.id = mission_id get_mission_by_id(req) else: get_active_mission(Trigger()) retry_rate.sleep() # Publish message on timer. timer = rospy.Timer(rospy.Duration(period), publish_mission) rospy.spin()