mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
curieimu: Plugin to interface with the arduino101's IMU
Internal sensor onboard the Curie/Arduino101 can be accessed via Firmata using this plugin. You will need mraa compiled with -DFIRMATA=ON for this to work and be using Firmata with the CurieIMU firmata extension for ExtensibleFirmata Signed-off-by: Ron Evans <ron@hybridgroup.com> Signed-off-by: Justin Zemlyansky <jlstigman@live.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
0d20cdb25a
commit
fb5c809ff8
@ -255,6 +255,7 @@ add_example (apa102)
|
||||
add_example (tex00)
|
||||
add_example (bmi160)
|
||||
add_example (smartdrive)
|
||||
add_example (curieimu)
|
||||
|
||||
# These are special cases where you specify example binary, source file and module(s)
|
||||
include_directories (${PROJECT_SOURCE_DIR}/src)
|
||||
|
70
examples/c++/curieimu.cxx
Normal file
70
examples/c++/curieimu.cxx
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Author: Ron Evans (@deadprogram)
|
||||
* Author: Justin Zemlyansky (@JustInDevelopment)
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "curieimu.hpp"
|
||||
#include "mraa.h"
|
||||
#include "mraa/firmata.h"
|
||||
#include <math.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
//! [Interesting]
|
||||
mraa_init();
|
||||
mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
|
||||
|
||||
upm::CurieImu* sensor = new upm::CurieImu();
|
||||
|
||||
std::cout << "temperature is: " << (sensor->getTemperature() * pow(0.5, 9) + 23) << std::endl;
|
||||
|
||||
int x, y, z;
|
||||
sensor->readAccelerometer(&x, &y, &z);
|
||||
printf("accelerometer is: %d, %d, %d\n", x, y, z);
|
||||
|
||||
int a, b, c;
|
||||
sensor->readGyro(&a, &b, &c);
|
||||
printf("gyroscope is: %d, %d, %d\n", a, b, c);
|
||||
|
||||
int axis, direction;
|
||||
sensor->enableShockDetection(true);
|
||||
for(int i=0; i<300; i++) {
|
||||
if (sensor->isShockDetected()) {
|
||||
sensor->getShockDetectData(&axis, &direction);
|
||||
printf("shock data is: %d, %d\n", axis, direction);
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
int m, n, o, p, q, r;
|
||||
sensor->readMotion(&m, &n, &o, &p, &q, &r);
|
||||
printf("motion is: %d, %d, %d, %d, %d, %d\n", m, n, o, p, q, r);
|
||||
|
||||
delete sensor;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user