Skip to content

Commit f6db1c0

Browse files
authored
Merge pull request #179 from BCLab-UNM/calibration-file-arrangements
Added New Libraries, Script File, and Calibration Code
2 parents 4c65385 + b2e197b commit f6db1c0

File tree

442 files changed

+42235
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

442 files changed

+42235
-21
lines changed

arduino/calibrator/calibrator.ino

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#define USE_USBCON
2+
3+
#include <ros.h>
4+
#include <std_msgs/String.h>
5+
#include <std_msgs/Int32MultiArray.h>
6+
7+
#include <Wire.h>
8+
#include <LSM303.h>
9+
10+
LSM303 lsm303;
11+
12+
ros::NodeHandle_<ArduinoHardware, 2, 2, 125, 125> nh;
13+
14+
std_msgs::Int32MultiArray imu_msg;
15+
long int imu_data[8];
16+
ros::Publisher imu_pub("/imu_raw", &imu_msg);
17+
18+
void setup()
19+
{
20+
nh.initNode();
21+
22+
imu_msg.data = (long int *) &imu_data;
23+
imu_msg.data_length = 8;
24+
nh.advertise(imu_pub);
25+
nh.spinOnce();
26+
27+
Wire.begin();
28+
29+
/* Initialize the sensor */
30+
if(iicScan() > 0) {
31+
lsm303.init();
32+
lsm303.enableDefault();
33+
lsm303.setTimeout(1);
34+
35+
// Enable temperature sensor
36+
byte ctrl5 = lsm303.readReg(0x24);
37+
ctrl5 |= 0x80;
38+
39+
// Set the mag data rate to 50Hz
40+
ctrl5 &= ~0b00011100;
41+
ctrl5 |= 0b00010000;
42+
43+
lsm303.writeReg(0x24, ctrl5);
44+
45+
// Set the acc data rate to 50Hz
46+
byte ctrl1 = lsm303.readReg(0x20);
47+
ctrl1 &= ~0b11110000;
48+
ctrl1 |= 0b01010000;
49+
50+
// Enable BDU - Synchronized conversion.
51+
ctrl1 |= 0b00001000;
52+
53+
lsm303.writeReg(0x20, ctrl1);
54+
}
55+
}
56+
57+
int iicScan() {
58+
byte numberOfDevices = 0;
59+
60+
for(byte address = 1; address < 127; address++ ) {
61+
Wire.beginTransmission(address);
62+
byte error = Wire.endTransmission();
63+
64+
if (!error) {
65+
numberOfDevices++;
66+
}
67+
}
68+
69+
return numberOfDevices;
70+
}
71+
72+
void loop()
73+
{
74+
if (iicScan() > 0) {
75+
lsm303.read();
76+
LSM303::vector<int16_t> acc = lsm303.a;
77+
LSM303::vector<int16_t> mag = lsm303.m;
78+
79+
byte temp_lo = lsm303.readReg(0x05);
80+
byte temp_hi = lsm303.readReg(0x06);
81+
82+
imu_data[0] = mag.x;
83+
imu_data[1] = mag.y;
84+
imu_data[2] = mag.z;
85+
imu_data[3] = acc.x;
86+
imu_data[4] = acc.y;
87+
imu_data[5] = acc.z;
88+
imu_data[6] = temp_lo;
89+
imu_data[7] = temp_hi;
90+
imu_pub.publish(&imu_msg);
91+
}
92+
93+
nh.spinOnce();
94+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
language: python
2+
3+
cache:
4+
directories:
5+
- "~/.platformio"
6+
7+
install:
8+
- pip install -U platformio
9+
10+
env:
11+
- BOARD=uno
12+
- BOARD=leonardo
13+
- BOARD=micro
14+
- BOARD=megaatmega2560
15+
- BOARD=due
16+
- BOARD=yun
17+
- BOARD=genuino101
18+
- BOARD=zero
19+
20+
script:
21+
- set -eo pipefail;
22+
for e in examples/*; do
23+
platformio ci --board=$BOARD --lib=. $e/*;
24+
done
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2013 Pololu Corporation. For more information, see
2+
3+
http://www.pololu.com/
4+
http://forum.pololu.com/
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the "Software"), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)