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)
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)
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)
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)
def ping(): ros.loginfo("Pinged") return True