示例#1
0
def compass():
    global compass_data
    if request.method == 'POST':
        json_data = json.loads(request.data)
        compass_data = json_data
        ros.loginfo('/webhook/compass{' + 'heading: ' +
                    str(json_data['heading']) + '}')
        compass_pub.send(ros.json_to_msg(request.data, msgs.compass))
        return True
    else:
        return jsonify(compass_data)
示例#2
0
def gyroscope():
    global gyroscope_data
    if request.method == 'POST':
        json_data = json.loads(request.data)
        gyroscope_data = json_data
        ros.loginfo('/webhook/gyroscope{' + 'x: ' + str(json_data['x']) +
                    ', y: ' + str(json_data['y']) + ', z: ' +
                    str(json_data['z']) + '}')
        gyroscope_pub.send(ros.json_to_msg(request.data, msgs.gyroscope))
        return True
    else:
        return jsonify(gyroscope_data)
示例#3
0
def accel():
    global imu_data
    if request.method == 'POST':
        data = request.data
        json_data = json.loads(data)
        imu_data = json_data
        ros.loginfo('/webhook/accelerometer{' + 'type: ' +
                    str(json_data['type']) + ', x: ' + str(json_data['x']) +
                    ', y: ' + str(json_data['y']) + ', z: ' +
                    str(json_data['z']) + ', duration: ' +
                    str(json_data['duration']) + '}')
        imu_pub.send(ros.json_to_msg(request.data, msgs.imu))
        return True
    elif request.method == 'GET':
        return jsonify(imu_data)
示例#4
0
def gps():
    global gps_location
    if request.method == 'POST':
        json_data = json.loads(request.data)
        gps_location = json_data
        ros.loginfo('/webhook/gps{' + 'latitude: ' +
                    str(json_data['latitude']) + ', longitude: ' +
                    str(json_data['longitude']) + ', altitude: ' +
                    str(json_data['altitude']) + ', accuracy: ' +
                    str(json_data['accuracy']) + ' speed: ' +
                    str(json_data['speed']) + ', speed_accuracy: ' +
                    str(json_data['speed_accuracy']) + '}')
        gps_pub.send(ros.json_to_msg(request.data, msgs.gps))
        return True
    else:
        return jsonify(gps_location)
示例#5
0
def ping():
    ros.loginfo("Pinged")
    return True