Beispiel #1
0
def onDisConnect(request, action):
    ''' Removes the robot specified via url like
        '/disconnect/ROBOT_ID' from ROS-Publisher and 
        Ros-Subscriber

        We only are here when the URl is like:
        '/robot/disconnect/ROBOT_ID'

        TODO DL RosConfigurator is here used?
    '''
    partURL = request.path
    # If at the end is a slash we remove it simply
    if "/" is partURL[-1]:
        partURL = partURL[:-1]

    # Get ROBOT_ID, which is the last element
    robotID = partURL.split("/")[-1]

    Log("INFO", "Disconnecting robot '{}'".format(robotID))
    # Iterate through every topic and unregister, then delete it
    if robotID in ROS_PUBLISHER:
        for topic in ROS_PUBLISHER[robotID]:
            ROS_PUBLISHER[robotID][topic].unregister()
        del ROS_PUBLISHER[robotID]
        RosConfigurator.removeRobot(robotID)

    if robotID in ROS_SUBSCRIBER:
        for topic in ROS_SUBSCRIBER[robotID]:
            ROS_SUBSCRIBER[robotID][topic].unregister()
        del ROS_SUBSCRIBER[robotID]
        RosConfigurator.removeRobot(robotID)

    # Return success
    end_request(request, None, 200, "")
def robotDisconnection(data):
    ## \brief Handle robot diconnection
    # \param robot data dict (name)
    robot_name = data.data
    Log("INFO", "Disconnected robot: " + robot_name)
    if robot_name in ROBOT_TOPICS:
        CloudSubscriber.deleteEntity(robot_name, DEFAULT_CONTEXT_TYPE)
        CloudSubscriber.disconnect(robot_name, True)
        for topic in ROBOT_TOPICS[robot_name]["publisher"]:
            ROBOT_TOPICS[robot_name]["publisher"][topic]["publisher"].unregister()
        for topic in ROBOT_TOPICS[robot_name]["subscriber"]:
            ROBOT_TOPICS[robot_name]["subscriber"][topic]["subscriber"].unregister()
        RosConfigurator.removeRobot(robot_name)
Beispiel #3
0
def onDisConnect(request, action):
    ## \brief Disconnect robot
    # \param client request
    # \param action
    robot_name = pathParams(request, action["regexp"])[0]
    Log("INFO", "Disconnecting robot" + robot_name)
    if robot_name in ROBOT_TOPICS:
        CloudSubscriber.deleteEntity(robot_name, DEFAULT_CONTEXT_TYPE)
        CloudSubscriber.disconnect(robot_name, True)
        for topic in ROBOT_TOPICS[robot_name]["publisher"]:
            ROBOT_TOPICS[robot_name]["publisher"][topic][
                "publisher"].unregister()
        for topic in ROBOT_TOPICS[robot_name]["subscriber"]:
            ROBOT_TOPICS[robot_name]["subscriber"][topic][
                "subscriber"].unregister()
        RosConfigurator.removeRobot(robot_name)
    request.send_response(200)
    request.end_headers()
    request.wfile.write("")