Skip to content
Snippets Groups Projects
Commit 9e169fd2 authored by Augustin Jaujay's avatar Augustin Jaujay
Browse files

Première connexion Arduino

parent d26a77ac
No related branches found
No related tags found
No related merge requests found
Showing
with 50 additions and 1819 deletions
// IndoorAtlas iOS SDK
// IAFloor.h
#import <Foundation/Foundation.h>
#define INDOORATLAS_API __attribute__((visibility("default")))
/**
* IACertainty
*
* Discussion:
* Type used for representing the certainty that something is true.
* Has a value from 0.0 to 1.0, inclusive. A negative value indicates an invalid certainty.
*/
typedef double IACertainty;
/**
* IAFloor specifies the floor of the building on which the user is located.
* It is a replacement for CoreLocation's CLFloor as the interface for that is not open.
*/
INDOORATLAS_API
@interface IAFloor : NSObject
/**
* Initializes and returns a floor object with the specified level information.
* @param level initializes level value
*/
+ (nonnull IAFloor*)floorWithLevel:(NSInteger)level;
/**
* Floor level values correspond to the floor numbers assigned by the user in the mapping phase.
*
* It is erroneous to use the user's level in a building as an estimate of altitude.
*/
@property (nonatomic, readonly) NSInteger level;
/**
* Certainty that <IALocation> floor has the correct value.
*/
@property (nonatomic, readonly) IACertainty certainty;
@end
#undef INDOORATLAS_API
// IndoorAtlas iOS SDK
// IAFloorPlan.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <IndoorAtlas/IAFloor.h>
#define INDOORATLAS_API __attribute__((visibility("default")))
/**
* IAFloorPlan represents floor plan data received from service.
*/
INDOORATLAS_API
@interface IAFloorPlan : NSObject
/**
* @name Floor plan information
*/
/**
* Identifier of the floor plan.
*/
@property (nonatomic, readonly, nullable) NSString *floorPlanId;
/**
* Name of the floor plan.
*/
@property (nonatomic, readonly, nullable) NSString *name;
/**
* Image URL of the floor plan.
*/
@property (nonatomic, readonly, nullable) NSURL *imageUrl;
/**
* Width of the image bitmap in pixels.
*/
@property (nonatomic, readonly) NSUInteger width;
/**
* Height of the image bitmap in pixels.
*/
@property (nonatomic, readonly) NSUInteger height;
/**
* Conversion multiplier from pixels to meters.
*/
@property (nonatomic, readonly) float pixelToMeterConversion;
/**
* Conversion multiplier from meters to pixels.
*/
@property (nonatomic, readonly) float meterToPixelConversion;
/**
* Width of floor plan in meters.
*/
@property (nonatomic, readonly) float widthMeters;
/**
* Height of floor plan in meters.
*/
@property (nonatomic, readonly) float heightMeters;
/**
* Object containing the floor of floor plan.
* If the object is nil, the floor is unspecified.
*/
@property (nonatomic, readonly, nullable) IAFloor *floor;
/**
* The approximate bearing of left side of floor plan in
* degrees east of true north.
*/
@property (nonatomic, readonly) double bearing;
/**
* Corresponding WGS84 coordinate of center of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D center;
/**
* Corresponding WGS84 coordinate of top left of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D topLeft;
/**
* Corresponding WGS84 coordinate of top right of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D topRight;
/**
* Corresponding WGS84 coordinate of bottom left of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D bottomLeft;
/**
* Corresponding WGS84 coordinate of bottom right of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D bottomRight;
/**
* Converts coordinate to corresponding point.
*
* @param coord WGS84 coordinate
* @return corresponding pixel point on floor plan bitmap
*/
- (CGPoint)coordinateToPoint:(CLLocationCoordinate2D)coord;
/**
* Converts point to corresponding coordinate.
*
* @param point pixel point of floor plan bitmap
* @return corresponding WGS84 coordinate
*/
- (CLLocationCoordinate2D)pointToCoordinate:(CGPoint)point;
@end
#undef INDOORATLAS_API
// IndoorAtlas iOS SDK
// IndoorAtlas.h
#import <IndoorAtlas/IAFloor.h>
#import <IndoorAtlas/IAFloorPlan.h>
#import <IndoorAtlas/IALocationManager.h>
framework module IndoorAtlas {
umbrella header "IndoorAtlas.h"
header "IALocationManager.h"
header "IAFloorPlan.h"
header "IAFloor.h"
export * module * { export * }
}
// IndoorAtlas iOS SDK
// IAFloor.h
#import <Foundation/Foundation.h>
#define INDOORATLAS_API __attribute__((visibility("default")))
/**
* IACertainty
*
* Discussion:
* Type used for representing the certainty that something is true.
* Has a value from 0.0 to 1.0, inclusive. A negative value indicates an invalid certainty.
*/
typedef double IACertainty;
/**
* IAFloor specifies the floor of the building on which the user is located.
* It is a replacement for CoreLocation's CLFloor as the interface for that is not open.
*/
INDOORATLAS_API
@interface IAFloor : NSObject
/**
* Initializes and returns a floor object with the specified level information.
* @param level initializes level value
*/
+ (nonnull IAFloor*)floorWithLevel:(NSInteger)level;
/**
* Floor level values correspond to the floor numbers assigned by the user in the mapping phase.
*
* It is erroneous to use the user's level in a building as an estimate of altitude.
*/
@property (nonatomic, readonly) NSInteger level;
/**
* Certainty that <IALocation> floor has the correct value.
*/
@property (nonatomic, readonly) IACertainty certainty;
@end
#undef INDOORATLAS_API
// IndoorAtlas iOS SDK
// IAFloorPlan.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <IndoorAtlas/IAFloor.h>
#define INDOORATLAS_API __attribute__((visibility("default")))
/**
* IAFloorPlan represents floor plan data received from service.
*/
INDOORATLAS_API
@interface IAFloorPlan : NSObject
/**
* @name Floor plan information
*/
/**
* Identifier of the floor plan.
*/
@property (nonatomic, readonly, nullable) NSString *floorPlanId;
/**
* Name of the floor plan.
*/
@property (nonatomic, readonly, nullable) NSString *name;
/**
* Image URL of the floor plan.
*/
@property (nonatomic, readonly, nullable) NSURL *imageUrl;
/**
* Width of the image bitmap in pixels.
*/
@property (nonatomic, readonly) NSUInteger width;
/**
* Height of the image bitmap in pixels.
*/
@property (nonatomic, readonly) NSUInteger height;
/**
* Conversion multiplier from pixels to meters.
*/
@property (nonatomic, readonly) float pixelToMeterConversion;
/**
* Conversion multiplier from meters to pixels.
*/
@property (nonatomic, readonly) float meterToPixelConversion;
/**
* Width of floor plan in meters.
*/
@property (nonatomic, readonly) float widthMeters;
/**
* Height of floor plan in meters.
*/
@property (nonatomic, readonly) float heightMeters;
/**
* Object containing the floor of floor plan.
* If the object is nil, the floor is unspecified.
*/
@property (nonatomic, readonly, nullable) IAFloor *floor;
/**
* The approximate bearing of left side of floor plan in
* degrees east of true north.
*/
@property (nonatomic, readonly) double bearing;
/**
* Corresponding WGS84 coordinate of center of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D center;
/**
* Corresponding WGS84 coordinate of top left of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D topLeft;
/**
* Corresponding WGS84 coordinate of top right of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D topRight;
/**
* Corresponding WGS84 coordinate of bottom left of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D bottomLeft;
/**
* Corresponding WGS84 coordinate of bottom right of floor plan bitmap placed
* on the surface of Earth.
*/
@property (nonatomic, readonly) CLLocationCoordinate2D bottomRight;
/**
* Converts coordinate to corresponding point.
*
* @param coord WGS84 coordinate
* @return corresponding pixel point on floor plan bitmap
*/
- (CGPoint)coordinateToPoint:(CLLocationCoordinate2D)coord;
/**
* Converts point to corresponding coordinate.
*
* @param point pixel point of floor plan bitmap
* @return corresponding WGS84 coordinate
*/
- (CLLocationCoordinate2D)pointToCoordinate:(CGPoint)point;
@end
#undef INDOORATLAS_API
// IndoorAtlas iOS SDK
// IndoorAtlas.h
#import <IndoorAtlas/IAFloor.h>
#import <IndoorAtlas/IAFloorPlan.h>
#import <IndoorAtlas/IALocationManager.h>
framework module IndoorAtlas {
umbrella header "IndoorAtlas.h"
header "IALocationManager.h"
header "IAFloorPlan.h"
header "IAFloor.h"
export * module * { export * }
}
......@@ -33,11 +33,13 @@ var gyroscope = navigator.gyroscope;
var magnetometer = navigator.magnetometer;
var sensors = navigator.orientation;
var rotation = navigator.rotationvector;
var constraints;
var constraints = [];
var saveFile;
var errorsFile;
var nbProbes = 6;
///var IndoorAtlas = navigator.indooratlas;
function onDeviceReady() {
......@@ -54,6 +56,7 @@ function onDeviceReady() {
setTimeout(createErrorsFile, 300);
setTimeout(setArduinoConnexion, 400);
setTimeout(askArduinoData, 500);
setTimeout(beginMeasures, 500);
}
......@@ -80,22 +83,32 @@ function handleButtonEvent() {
+ "\n Z: " + acceleration.z;
//Set gyroscope in html
// document.getElementById('gyroscopeData').innerHTML = ""
// + " timestamp: " + gyroscope.timestamp
// + "\n X: " + gyroscope.x
// + "\n Y: " + gyroscope.y
// + "\n Z: " + gyroscope.z;
document.getElementById('gyroscopeData').innerHTML = ""
+ " timestamp: " + gyroscope.timestamp
+ "\n X: " + gyroscope.x
+ "\n Y: " + gyroscope.y
+ "\n Z: " + gyroscope.z;
//Set magnetometer in html
// document.getElementById('magnetometerData').innerHTML = ""
// + " timestamp: " + acceleration.timestamp
// + "\n X: " + magnetometer.x
// + "\n Y: " + magnetometer.y
// + "\n Z: " + magnetometer.z;
document.getElementById('magnetometerData').innerHTML = ""
+ " timestamp: " + acceleration.timestamp
+ "\n X: " + magnetometer.x
+ "\n Y: " + magnetometer.y
+ "\n Z: " + magnetometer.z;
// Reading arduino data
serial.read(function(buffer) {
console.log(buffer);
if (buffer.length !== nbProbes) {
handleError(`Error : the number of probes is not correct`, new Error());
} else {
constraints = new Float32Array(buffer);
}
}, error => handleError(`Error while reading data from Arduino`, error));
serial.read(function(buffer) {console.log(buffer);}, error => handleError(`Error while reading data from Arduino`, error));
askArduinoData();
save(position, acceleration, gyroscope, magnetometer);
save(position, acceleration, gyroscope, magnetometer, constraints);
}
function startOrStopTimer() {
......@@ -131,9 +144,13 @@ function setArduinoConnexion() {
}, error => handleError(`Error while getting permission for serial link`, error));
}
function askArduinoData() {
serial.write('0', function() {}, error => handleError(`Couldn't communicate with Arduino`, error));
}
// DATA MANAGING FUNCTIONS
function save(positionData, accelerationData, gyroscopeData, magnetometerData) {
function save(positionData, accelerationData, gyroscopeData, magnetometerData, arduinoData) {
newLine = `${positionData.timestamp};
${positionData.coords.latitude};
${positionData.coords.longitude};
......@@ -144,15 +161,21 @@ function save(positionData, accelerationData, gyroscopeData, magnetometerData) {
${accelerationData.timestamp};
${accelerationData.x};
${accelerationData.y};
${accelerationData.z}\n`;
// ${gyroscopeData.timestamp};
// ${gyroscopeData.x};
// ${gyroscopeData.y};
// ${gyroscopeData.z};
// ${accelerationData.timestamp};
// ${magnetometerData.x};
// ${magnetometer.y};
// ${magnetometer.z}\n`;
${accelerationData.z};
${gyroscopeData.timestamp};
${gyroscopeData.x};
${gyroscopeData.y};
${gyroscopeData.z};
${accelerationData.timestamp};
${magnetometerData.x};
${magnetometerData.y};
${magnetometerData.z};
${arduinoData[1]};
${arduinoData[2]};
${arduinoData[3]};
${arduinoData[4]};
${arduinoData[5]};
${arduinoData[6]}\n`;
writeFile(saveFile, new Blob([newLine]));
readFile(saveFile);
......@@ -175,10 +198,10 @@ function createDataFile() {
saveFile = fileEntry;
writeFile(saveFile, new Blob([
`position timestamp;latitude;longitude;altitude;heading;speed;accuracy;
acceleration timestamp;acceleration x;acceleration y;acceleration z\n`
// gyrorsope timestamp;gyroscope x;gyroscope y;gyroscope z;
// magnetometer timestamp;magnetometer x;magnetometer y;magnetometer z;
// constraint 1;constraint 2;constraint 3;constraint 4;constraint 5;constraint 6\n`
acceleration timestamp;acceleration x;acceleration y;acceleration z;
gyrorsope timestamp;gyroscope x;gyroscope y;gyroscope z;
magnetometer timestamp;magnetometer x;magnetometer y;magnetometer z;
constraint 1;constraint 2;constraint 3;constraint 4;constraint 5;constraint 6\n`
]));
console.log('Data file opened');
}, error => handleError(`Error while getting file ${fileEntry.name}`, error));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment