teensy and mpu 9250

782 views
Skip to first unread message

woos kim

unread,
May 17, 2018, 11:43:28 AM5/17/18
to LINOROBOT

After finishing linorobot and trying to imu.launch, only the phrases in the picture are kept floating. I wonder what the problem is. Use teensy mpu9250 with raspberry pie
캡처.PNG

choi

unread,
May 17, 2018, 11:46:59 AM5/17/18
to LINOROBOT
2.PNG

Juan Miguel Jimeno

unread,
May 18, 2018, 7:04:12 AM5/18/18
to LINOROBOT
Hi Choi,

Can you post your lino_base_config.h here?

Message has been deleted
Message has been deleted

choi

unread,
May 19, 2018, 9:11:42 AM5/19/18
to LINOROBOT
#ifndef LINO_BASE_CONFIG_H
#define LINO_BASE_CONFIG_H

//uncomment the base you're building
//#define LINO_BASE DIFFERENTIAL_DRIVE // 2WD and Tracked robot w/ 2 motors
// #define LINO_BASE SKID_STEER      // 4WD robot
// #define LINO_BASE ACKERMANN       // Car-like steering robot
 #define LINO_BASE MECANUM         // Mecanum drive robot

//uncomment the motor driver you're using
#define USE_L298_DRIVER
// #define USE_BTS7960_DRIVER
// #define USE_ESC

//uncomment the IMU you're using
//#define USE_GY85_IMU
// #define USE_MPU6050_IMU
 #define USE_MPU9150_IMU

#define DEBUG 1

#define K_P 0.6 // P constant
#define K_I 0.3 // I constant
#define K_D 0.5 // D constant

//define your robot' specs here
#define MAX_RPM 330               // motor's maximum RPM
#define COUNTS_PER_REV 1550       // wheel encoder's no of ticks per rev
#define WHEEL_DIAMETER 0.10       // wheel's diameter in meters
#define PWM_BITS 8                // PWM Resolution of the microcontroller
#define LR_WHEELS_DISTANCE 0.235  // distance between left and right wheels
#define FR_WHEELS_DISTANCE 0.30   // distance between front and rear wheels. Ignore this if you're on 2WD/ACKERMANN

//=================BIGGER ROBOT SPEC (BTS7960)=============================
// #define K_P 0.05  // P constant
// #define K_I 0.9   // I constant
// #define K_D 0.1   // D constant

// define your robot' specs here
// #define MAX_RPM 45               // motor's maximum RPM
// #define COUNTS_PER_REV 4000      // wheel encoder's no of ticks per rev
// #define WHEEL_DIAMETER 0.15      // wheel's diameter in meters
// #define PWM_BITS 8               // PWM Resolution of the microcontroller
// #define LR_WHEELS_DISTANCE 0.32  // distance between left and right wheels
// #define FB_WHEELS_DISTANCE 0.38  // distance between front and back wheels. Ignore this if you're on 2WD/ACKERMANN
//================= END OF BIGGER ROBOT SPEC =============================

/*
ROBOT ORIENTATION
         FRONT
    MOTOR1  MOTOR2  (2WD/ACKERMANN)
    MOTOR3  MOTOR4  (4WD/MECANUM)  
         BACK
*/

/// ENCODER PINS
#define MOTOR1_ENCODER_A 15
#define MOTOR1_ENCODER_B 14 

#define MOTOR2_ENCODER_A 11
#define MOTOR2_ENCODER_B 12 

#define MOTOR3_ENCODER_A 17
#define MOTOR3_ENCODER_B 16 

#define MOTOR4_ENCODER_A 9
#define MOTOR4_ENCODER_B 10

//MOTOR PINS
#ifdef USE_L298_DRIVER
  #define MOTOR_DRIVER L298

  #define MOTOR1_PWM 21
  #define MOTOR1_IN_A 20
  #define MOTOR1_IN_B 1

  #define MOTOR2_PWM 5
  #define MOTOR2_IN_A 8
  #define MOTOR2_IN_B 6

  #define MOTOR3_PWM 22
  #define MOTOR3_IN_A 23
  #define MOTOR3_IN_B 0

  #define MOTOR4_PWM 4
  #define MOTOR4_IN_A 2
  #define MOTOR4_IN_B 3

  #define PWM_MAX pow(2, PWM_BITS) - 1
  #define PWM_MIN -PWM_MAX
#endif 

#ifdef USE_BTS7960_DRIVER
  #define MOTOR_DRIVER BTS7960  

  #define MOTOR1_PWM 1 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR1_IN_A 21
  #define MOTOR1_IN_B 20

  #define MOTOR2_PWM 8 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR2_IN_A 5
  #define MOTOR2_IN_B 6

  #define MOTOR3_PWM 0 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR3_IN_A 22
  #define MOTOR3_IN_B 23

  #define MOTOR4_PWM 2 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR4_IN_A 4
  #define MOTOR4_IN_B 3

  #define PWM_MAX pow(2, PWM_BITS) - 1
  #define PWM_MIN -PWM_MAX
#endif

#ifdef USE_ESC
  #define MOTOR_DRIVER ESC  

  #define MOTOR1_PWM 1 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR1_IN_A 21
  #define MOTOR1_IN_B 20

  #define MOTOR2_PWM 8 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR2_IN_A 5
  #define MOTOR2_IN_B 6

  #define MOTOR3_PWM 0 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR3_IN_A 22
  #define MOTOR3_IN_B 23

  #define MOTOR4_PWM 2 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR4_IN_A 4
  #define MOTOR4_IN_B 3

  #define PWM_MAX 400
  #define PWM_MIN -PWM_MAX
#endif

#define STEERING_PIN 7

#endif

Juan Miguel Jimeno

unread,
May 19, 2018, 1:53:17 PM5/19/18
to LINOROBOT
Hi Choi,

Have you checked if the IMU is powered and your SDA/SCL are wired up correctly?

choi

unread,
May 19, 2018, 11:33:00 PM5/19/18
to LINOROBOT
3.3v cennect and every wire is correctly connected.

gearsmotion789

unread,
May 25, 2018, 11:52:55 PM5/25/18
to LINOROBOT
I am getting the same problem too. Additionally, I also see the error message, "[FATAL] [1527306692.511688]: IMU failed to initialize. Check your IMU connection.". I also wired everything correctly and setup code to use the correct IMU.

Juan Miguel Jimeno

unread,
May 26, 2018, 2:10:37 AM5/26/18
to LINOROBOT
Hi,

Can you temporarily replace firmware.ino with https://gist.github.com/grassjelly/ef3b8f5741feaf2784526fb0c975bfb0 and upload the code.

Run:

screen /dev/linobase 9600

and post the return device id here.

Thanks!

gearsmotion789

unread,
May 26, 2018, 11:32:03 AM5/26/18
to LINOROBOT
Which path is firmware.ino in?

Juan Miguel Jimeno

unread,
May 26, 2018, 11:42:22 AM5/26/18
to LINOROBOT
https://github.com/linorobot/linorobot/tree/master/teensy/firmware/src

Just copy and paste the gist code to firmware.ino

Dominic Schmidt

unread,
May 26, 2018, 11:46:09 AM5/26/18
to LINOROBOT
The path is linorobot/teensy/firmware/src/firmware.ino

You can also look online for other teensy MPU 9250 sketches to make sure your hardware isn't the problem.

gearsmotion789

unread,
May 26, 2018, 2:05:12 PM5/26/18
to LINOROBOT
I ran the command, and I get the message [screen is terminating]. I don't see a device id.

Juan Miguel Jimeno

unread,
May 26, 2018, 9:50:05 PM5/26/18
to LINOROBOT
run:

sudo chmod 666 /dev/linobase

before running the screen command

gearsmotion789

unread,
May 26, 2018, 10:51:10 PM5/26/18
to LINOROBOT

gearsmotion789

unread,
May 26, 2018, 10:52:04 PM5/26/18
to LINOROBOT
I still get the same message.

Juan Miguel Jimeno

unread,
May 26, 2018, 11:12:31 PM5/26/18
to LINOROBOT
Have you done the udev rules yet? I assume you also have copy paste the gist into firmware.ino?

Verify that theTeensy’s serial port is /dev/ttyACM0

ls /dev/ttyACM0

if so, run:

sudo chmod 666 /dev/ttyACM0
screen /dev/ttyACM0 9600

gearsmotion789

unread,
May 27, 2018, 1:58:44 AM5/27/18
to LINOROBOT
I tried, but still get the same message.

Juan Miguel Jimeno

unread,
May 27, 2018, 5:30:40 AM5/27/18
to LINOROBOT
It will be great to describe what you've done and which message you're receiving. It's pretty hard to debug something without any description ;)

gearsmotion789

unread,
May 27, 2018, 9:01:26 PM5/27/18
to LINOROBOT
I've been following instructions from https://github.com/linorobot/linorobot/wiki/1.-Getting-Started. When I ran the commands you told me to run, I just see a blank screen with a flashing cursor. No text shows up.

Juan Miguel Jimeno

unread,
May 28, 2018, 11:01:22 AM5/28/18
to lino...@googlegroups.com
I suspect this might be a hardware issue as even the basic sketch doesn't work. Do you have a spare IMU to try?
Message has been deleted

gearsmotion789

unread,
May 28, 2018, 10:56:49 PM5/28/18
to LINOROBOT
No. I don't have another IMU. Do you have any other suggestions? How could I prove that my IMU is bad?

choi

unread,
May 29, 2018, 2:33:34 AM5/29/18
to LINOROBOT
Hardware is not a problem.
I was tested in arduinomega2560
It works well

gearsmotion789

unread,
May 29, 2018, 2:41:54 AM5/29/18
to LINOROBOT
What do you think my problem might be?

Juan Miguel Jimeno

unread,
May 29, 2018, 3:17:54 AM5/29/18
to LINOROBOT
Which code did use to try?

choi

unread,
May 29, 2018, 3:33:56 AM5/29/18
to LINOROBOT
#include "Wire.h"
// I2Cdev and MPU9250 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "MPU9250.h"
// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU9250 accelgyro;
I2Cdev I2C_M;
uint8_t buffer_m[6];
int16_t ax, ay, az;
int16_t gx, gy, gz;
int16_t mx, my, mz;
float heading;
float tiltheading;
float Axyz[3];
float Gxyz[3];
float Mxyz[3];
#define sample_num_mdate 5000
volatile float mx_sample[3];
volatile float my_sample[3];
volatile float mz_sample[3];
static float mx_centre = 0;
static float my_centre = 0;
static float mz_centre = 0;
volatile int mx_max = 0;
volatile int my_max = 0;
volatile int mz_max = 0;
volatile int mx_min = 0;
volatile int my_min = 0;
volatile int mz_min = 0;
float temperature;
float pressure;
float atm;
float altitude;
void setup()
{
// join I2C bus (I2Cdev library doesn't do this automatically)
Wire.begin();
// initialize serial communication
// (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
// it's really up to you depending on your project)
Serial.begin(9600);
// initialize device
Serial.println("Initializing I2C devices...");
accelgyro.initialize();
// verify connection
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU9250 connection successful" : "MPU9250 connection failed");
delay(1000);
Serial.println(" ");
// Mxyz_init_calibrated ();
}
void loop()
{
getAccel_Data();
getGyro_Data();
getCompassDate_calibrated(); // compass data has been calibrated here
getHeading(); //before we use this function we should run 'getCompassDate_calibrated()' frist, so that we can get calibrated data ,then we can get correct angle .
getTiltHeading();
Serial.println("calibration parameter: ");
Serial.print(mx_centre);
Serial.print(" ");
Serial.print(my_centre);
Serial.print(" ");
Serial.println(mz_centre);
Serial.println(" ");
Serial.println("Acceleration(g) of X,Y,Z:");
Serial.print(Axyz[0]);
Serial.print(",");
Serial.print(Axyz[1]);
Serial.print(",");
Serial.println(Axyz[2]);
Serial.println("Gyro(degress/s) of X,Y,Z:");
Serial.print(Gxyz[0]);
Serial.print(",");
Serial.print(Gxyz[1]);
Serial.print(",");
Serial.println(Gxyz[2]);
Serial.println("Compass Value of X,Y,Z:");
Serial.print(Mxyz[0]);
Serial.print(",");
Serial.print(Mxyz[1]);
Serial.print(",");
Serial.println(Mxyz[2]);
Serial.println("The clockwise angle between the magnetic north and X-Axis:");
Serial.print(heading);
Serial.println(" ");
Serial.println("The clockwise angle between the magnetic north and the projection of the positive X-Axis in the horizontal plane:");
Serial.println(tiltheading);
Serial.println(" ");
Serial.println();
delay(1000);
}
void getHeading(void)
{
heading = 180 * atan2(Mxyz[1], Mxyz[0]) / PI;
if (heading < 0) heading += 360;
}
void getTiltHeading(void)
{
float pitch = asin(-Axyz[0]);
float roll = asin(Axyz[1] / cos(pitch));
float xh = Mxyz[0] * cos(pitch) + Mxyz[2] * sin(pitch);
float yh = Mxyz[0] * sin(roll) * sin(pitch) + Mxyz[1] * cos(roll) - Mxyz[2] * sin(roll) * cos(pitch);
float zh = -Mxyz[0] * cos(roll) * sin(pitch) + Mxyz[1] * sin(roll) + Mxyz[2] * cos(roll) * cos(pitch);
tiltheading = 180 * atan2(yh, xh) / PI;
if (yh < 0) tiltheading += 360;
}
void Mxyz_init_calibrated ()
{
Serial.println(F("Before using 9DOF,we need to calibrate the compass frist,It will takes about 2 minutes."));
Serial.print(" ");
Serial.println(F("During calibratting ,you should rotate and turn the 9DOF all the time within 2 minutes."));
Serial.print(" ");
Serial.println(F("If you are ready ,please sent a command data 'ready' to start sample and calibrate."));
while (!Serial.find("ready"));
Serial.println(" ");
Serial.println("ready");
Serial.println("Sample starting......");
Serial.println("waiting ......");
get_calibration_Data ();
Serial.println(" ");
Serial.println("compass calibration parameter ");
Serial.print(mx_centre);
Serial.print(" ");
Serial.print(my_centre);
Serial.print(" ");
Serial.println(mz_centre);
Serial.println(" ");
}
void get_calibration_Data ()
{
for (int i = 0; i < sample_num_mdate; i++)
{
get_one_sample_date_mxyz();
/*
Serial.print(mx_sample[2]);
Serial.print(" ");
Serial.print(my_sample[2]); //you can see the sample data here .
Serial.print(" ");
Serial.println(mz_sample[2]);
*/
if (mx_sample[2] >= mx_sample[1])mx_sample[1] = mx_sample[2];
if (my_sample[2] >= my_sample[1])my_sample[1] = my_sample[2]; //find max value
if (mz_sample[2] >= mz_sample[1])mz_sample[1] = mz_sample[2];
if (mx_sample[2] <= mx_sample[0])mx_sample[0] = mx_sample[2];
if (my_sample[2] <= my_sample[0])my_sample[0] = my_sample[2]; //find min value
if (mz_sample[2] <= mz_sample[0])mz_sample[0] = mz_sample[2];
}
mx_max = mx_sample[1];
my_max = my_sample[1];
mz_max = mz_sample[1];
mx_min = mx_sample[0];
my_min = my_sample[0];
mz_min = mz_sample[0];
mx_centre = (mx_max + mx_min) / 2;
my_centre = (my_max + my_min) / 2;
mz_centre = (mz_max + mz_min) / 2;
}
void get_one_sample_date_mxyz()
{
getCompass_Data();
mx_sample[2] = Mxyz[0];
my_sample[2] = Mxyz[1];
mz_sample[2] = Mxyz[2];
}
void getAccel_Data(void)
{
accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
Axyz[0] = (double) ax / 16384;
Axyz[1] = (double) ay / 16384;
Axyz[2] = (double) az / 16384;
}
void getGyro_Data(void)
{
accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
Gxyz[0] = (double) gx * 250 / 32768;
Gxyz[1] = (double) gy * 250 / 32768;
Gxyz[2] = (double) gz * 250 / 32768;
}
void getCompass_Data(void)
{
I2C_M.writeByte(MPU9150_RA_MAG_ADDRESS, 0x0A, 0x01); //enable the magnetometer
delay(10);
I2C_M.readBytes(MPU9150_RA_MAG_ADDRESS, MPU9150_RA_MAG_XOUT_L, 6, buffer_m);
mx = ((int16_t)(buffer_m[1]) << 8) | buffer_m[0] ;
my = ((int16_t)(buffer_m[3]) << 8) | buffer_m[2] ;
mz = ((int16_t)(buffer_m[5]) << 8) | buffer_m[4] ;
Mxyz[0] = (double) mx * 1200 / 4096;
Mxyz[1] = (double) my * 1200 / 4096;
Mxyz[2] = (double) mz * 1200 / 4096;
}
void getCompassDate_calibrated ()
{
getCompass_Data();
Mxyz[0] = Mxyz[0] - mx_centre;
Mxyz[1] = Mxyz[1] - my_centre;
Mxyz[2] = Mxyz[2] - mz_centre;
}

Juan Miguel Jimeno

unread,
May 29, 2018, 4:01:25 AM5/29/18
to LINOROBOT
Thanks for the feedback. May I know the source of the library? I need to get the device id  used so I can patch the firmware.
Message has been deleted

choi

unread,
May 29, 2018, 4:30:26 AM5/29/18
to LINOROBOT
i used this
mpu9250_raw.zip

Juan Miguel Jimeno

unread,
May 29, 2018, 5:23:40 AM5/29/18
to LINOROBOT
I've created a branch to update the library. https://github.com/linorobot/linorobot/tree/imufix

Would appreciate if you can post the results here so I can merge it to master branch if this solves the problem.

Thank you!!

choi

unread,
May 29, 2018, 5:55:04 AM5/29/18
to LINOROBOT
i'm sorry 
it doesn't works 
same message again

Juan Miguel Jimeno

unread,
May 29, 2018, 6:00:54 AM5/29/18
to LINOROBOT
Can you try the same codes on your Arduino Mega?

choi

unread,
May 29, 2018, 6:14:57 AM5/29/18
to LINOROBOT
same message 
sorry......

choi

unread,
May 29, 2018, 6:24:12 AM5/29/18
to LINOROBOT
i was tried 2 teensy & 2 imu
 I just see a blank screen with a flashing cursor. No text shows up. when i try screen /dev/ttyACM0 9600

Juan Miguel Jimeno

unread,
May 29, 2018, 6:41:16 AM5/29/18
to LINOROBOT
Hi Choi,

You need to download the branch I posted and upload it again. Can you plug in your Teensy to your machine and run the following;

cd ~/linorobot_ws/src
rm
-rf linorobot
git clone https
://github.com/linorobot/linorobot
cd linorobot
git checkout imufix
cd teensy
/firmware/
pio run
--target upload
roslaunch linorobot minimal
.launch


choi

unread,
May 29, 2018, 7:07:55 AM5/29/18
to LINOROBOT
SUMMARY
========

PARAMETERS
 * /apply_calib/calib_file: /home/woo/linorob...
 * /imu_filter_madgwick/fixed_frame: odom
 * /imu_filter_madgwick/publish_tf: True
 * /imu_filter_madgwick/use_mag: True
 * /imu_filter_madgwick/use_magnetic_field_msg: True
 * /imu_filter_madgwick/world_frame: enu
 * /rosdistro: kinetic
 * /rosversion: 1.12.13

NODES
  /
    apply_calib (imu_calib/apply_calib)
    imu_filter_madgwick (imu_filter_madgwick/imu_filter_node)

auto-starting new master
process[master]: started with pid [13270]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 46cc660e-6330-11e8-8d1c-ac7289ece66d
process[rosout-1]: started with pid [13283]
started core service [/rosout]
process[apply_calib-2]: started with pid [13293]
process[imu_filter_madgwick-3]: started with pid [13301]
[ INFO] [1527591963.754222353]: Starting ImuFilter
[ INFO] [1527591963.762462673]: Using dt computed from message headers
[ INFO] [1527591963.774535246]: Imu filter gain set to 0.100000
[ INFO] [1527591963.774577964]: Gyro drift bias set to 0.000000
[ INFO] [1527591963.774613064]: Magnetometer bias values: 0.000000 0.000000 0.000000
[ WARN] [1527591973.792338656]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527591983.791872794]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527591993.792538068]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527592003.791940698]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527592013.792367781]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527592023.793019413]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527592033.792560120]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527592043.791896561]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ WARN] [1527592053.792393983]: Still waiting for data on topics /imu/data_raw and /imu/mag...

choi

unread,
May 29, 2018, 7:35:31 AM5/29/18
to LINOROBOT

Do you have to connect all the wires? I only connected the IMU sensor.

Juan Miguel Jimeno

unread,
May 29, 2018, 11:18:32 AM5/29/18
to LINOROBOT
I forgot to mention that you need to uncomment:

#define USE_MPU9150_IMU

on lino_base_config.h


Juan Miguel Jimeno

unread,
May 31, 2018, 3:48:20 AM5/31/18
to LINOROBOT
Injected the library you're using for 9250 on imufix branch. 


You can give it a try. Thanks!

choi

unread,
Jun 5, 2018, 1:56:35 AM6/5/18
to LINOROBOT
it doesn't works.......
i don't know how to fix this problem

choi

unread,
Jun 5, 2018, 2:14:13 AM6/5/18
to LINOROBOT
$ pio run --target upload
[Tue Jun  5 15:11:23 2018] Processing teensy31 (platform: teensy; board: teensy31; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Teensy > Teensy 3.1 / 3.2
SYSTEM: MK20DX256 72MHz 64KB RAM (256KB Flash)
DEBUG: CURRENT(jlink) EXTERNAL(jlink)
Converting firmware.ino
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(light)
Collected 100 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Servo> v1.1.2
|-- <ros_lib>
|-- <pid>
|-- <motor>
|   |-- <Servo> v1.1.2
|-- <config>
|-- <encoder>
|-- <kinematics>
|-- <imu>
|   |-- <Wire> v1.0
|   |-- <ros_lib>
Compiling .pioenvs/teensy31/src/firmware.ino.cpp.o
Compiling .pioenvs/teensy31/libb8b/Servo/Servo.cpp.o
Compiling .pioenvs/teensy31/liba54/ros_lib/duration.cpp.o
Compiling .pioenvs/teensy31/liba54/ros_lib/time.cpp.o
Compiling .pioenvs/teensy31/libe9c/pid/PID.cpp.o
Compiling .pioenvs/teensy31/lib7d3/motor/Motor.cpp.o
Archiving .pioenvs/teensy31/lib1dc/libconfig.a
Indexing .pioenvs/teensy31/lib1dc/libconfig.a
Compiling .pioenvs/teensy31/lib970/encoder/Encoder.cpp.o
Compiling .pioenvs/teensy31/libc49/kinematics/Kinematics.cpp.o
Archiving .pioenvs/teensy31/liba54/libros_lib.a
Indexing .pioenvs/teensy31/liba54/libros_lib.a
Compiling .pioenvs/teensy31/lib952/Wire/Wire.cpp.o
Compiling .pioenvs/teensy31/lib952/Wire/WireKinetis.cpp.o
Compiling .pioenvs/teensy31/lib952/Wire/utility/twi.c.o
Compiling .pioenvs/teensy31/lib155/imu/ADXL345.cpp.o
Archiving .pioenvs/teensy31/libe9c/libpid.a
Indexing .pioenvs/teensy31/libe9c/libpid.a
Archiving .pioenvs/teensy31/lib7d3/libmotor.a
Indexing .pioenvs/teensy31/lib7d3/libmotor.a
Archiving .pioenvs/teensy31/libb8b/libServo.a
Archiving .pioenvs/teensy31/lib970/libencoder.a
Indexing .pioenvs/teensy31/libb8b/libServo.a
Indexing .pioenvs/teensy31/lib970/libencoder.a
Compiling .pioenvs/teensy31/lib155/imu/HMC5883L.cpp.o
Compiling .pioenvs/teensy31/lib155/imu/I2Cdev.cpp.o
Compiling .pioenvs/teensy31/lib155/imu/ITG3200.cpp.o
Compiling .pioenvs/teensy31/lib155/imu/MPU6050.cpp.o
Archiving .pioenvs/teensy31/libc49/libkinematics.a
Indexing .pioenvs/teensy31/libc49/libkinematics.a
Compiling .pioenvs/teensy31/lib155/imu/MPU9150.cpp.o
Archiving .pioenvs/teensy31/lib952/libWire.a
Indexing .pioenvs/teensy31/lib952/libWire.a
Compiling .pioenvs/teensy31/lib155/imu/MPU9250.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/AudioStream.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/DMAChannel.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/EventResponder.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/HardwareSerial1.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/HardwareSerial2.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/HardwareSerial3.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/HardwareSerial4.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/HardwareSerial5.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/HardwareSerial6.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/IPAddress.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/IntervalTimer.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/Print.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/Stream.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/Tone.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/WMath.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/WString.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/analog.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/avr_emulation.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/eeprom.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/keylayouts.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/main.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/math_helper.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/memcpy-armv7m.S.o
Compiling .pioenvs/teensy31/FrameworkArduino/memset.S.o
Compiling .pioenvs/teensy31/FrameworkArduino/mk20dx128.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/new.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/nonstd.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/pins_teensy.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/ser_print.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/serial1.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/serial2.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/serial3.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/serial4.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/serial5.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/serial6.c.o
lib/imu/MPU9250.cpp: In member function 'bool MPU9250::writeMemoryBlock(const uint8_t*, uint16_t, uint8_t, uint8_t, bool, bool)':
lib/imu/MPU9250.cpp:3067:37: warning: 'progBuffer' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (useProgMem) free(progBuffer);
^
Compiling .pioenvs/teensy31/FrameworkArduino/serial6_lpuart.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/touch.c.o
lib/imu/MPU9250.cpp: In member function 'bool MPU9250::writeDMPConfigurationSet(const uint8_t*, uint16_t, bool)':
lib/imu/MPU9250.cpp:3145:37: warning: 'progBuffer' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (useProgMem) free(progBuffer);
^
Compiling .pioenvs/teensy31/FrameworkArduino/usb_audio.cpp.o
Archiving .pioenvs/teensy31/lib155/libimu.a
Indexing .pioenvs/teensy31/lib155/libimu.a
Compiling .pioenvs/teensy31/FrameworkArduino/usb_desc.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_dev.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_flightsim.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_inst.cpp.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_joystick.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_keyboard.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_mem.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_midi.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_mouse.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_mtp.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_rawhid.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_seremu.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_serial.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/usb_touch.c.o
Compiling .pioenvs/teensy31/FrameworkArduino/yield.cpp.o
Archiving .pioenvs/teensy31/libFrameworkArduino.a
Indexing .pioenvs/teensy31/libFrameworkArduino.a
Linking .pioenvs/teensy31/firmware.elf
Checking program size
text    data     bss     dec     hex filename
49936       0    5480   55416    d878 .pioenvs/teensy31/firmware.elf
Building .pioenvs/teensy31/firmware.hex
Configuring upload protocol...
AVAILABLE: jlink, teensy-cli, teensy-gui, teensy-gui
CURRENT: upload_protocol = teensy-gui
Uploading .pioenvs/teensy31/firmware.hex
Rebooting...
========================= [SUCCESS] Took 5.49 seconds =========================

Juan Miguel Jimeno

unread,
Jun 5, 2018, 2:43:30 AM6/5/18
to LINOROBOT
what happens when you run minimal.launch?

choi

unread,
Jun 5, 2018, 4:33:51 AM6/5/18
to LINOROBOT
$ roslaunch linorobot minimal.launch
... logging to /home/woo/.ros/log/9c371b88-689a-11e8-aa9a-ac7289ece66d/roslaunch-woo-HP-Pavilion-dv6-Notebook-PC-12095.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.


SUMMARY
========

PARAMETERS
 * /apply_calib/calib_file: /home/woo/linorob...
 * /imu_filter_madgwick/fixed_frame: odom
 * /imu_filter_madgwick/publish_tf: True
 * /imu_filter_madgwick/use_mag: True
 * /imu_filter_madgwick/use_magnetic_field_msg: True
 * /imu_filter_madgwick/world_frame: enu
 * /rosdistro: kinetic
 * /rosserial_lino/baud: 57600
 * /rosserial_lino/port: /dev/ttyACM0
 * /rosversion: 1.12.13

NODES
  /
    apply_calib (imu_calib/apply_calib)
    base_footprint_to_base_link (tf/static_transform_publisher)
    imu_filter_madgwick (imu_filter_madgwick/imu_filter_node)
    lino_base_node (linorobot/lino_base_node)
    rosserial_lino (rosserial_python/serial_node.py)

auto-starting new master
process[master]: started with pid [12105]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 9c371b88-689a-11e8-aa9a-ac7289ece66d
process[rosout-1]: started with pid [12118]
started core service [/rosout]
process[rosserial_lino-2]: started with pid [12130]
process[apply_calib-3]: started with pid [12136]
process[imu_filter_madgwick-4]: started with pid [12137]
process[lino_base_node-5]: started with pid [12162]
[ INFO] [1528187389.536970666]: Starting ImuFilter
[ INFO] [1528187389.542659520]: Using dt computed from message headers
process[base_footprint_to_base_link-6]: started with pid [12177]
[ INFO] [1528187389.566349664]: Imu filter gain set to 0.100000
[ INFO] [1528187389.566393504]: Gyro drift bias set to 0.000000
[ INFO] [1528187389.566418968]: Magnetometer bias values: 0.000000 0.000000 0.000000
[INFO] [1528187389.817680]: ROS Serial Python Node
[INFO] [1528187389.825323]: Connecting to /dev/ttyACM0 at 57600 baud
[INFO] [1528187391.949998]: Note: publish buffer size is 1024 bytes
[INFO] [1528187391.950562]: Setup publisher on raw_vel [lino_msgs/Velocities]
[INFO] [1528187391.954764]: Setup publisher on raw_imu [lino_msgs/Imu]
[INFO] [1528187391.961897]: Note: subscribe buffer size is 1024 bytes
[INFO] [1528187391.962223]: Setup subscriber on pid [lino_msgs/PID]
[INFO] [1528187391.970055]: Setup subscriber on cmd_vel [geometry_msgs/Twist]
[INFO] [1528187391.972768]: LINOBASE CONNECTED
[FATAL] [1528187391.992749]: IMU failed to initialize. Check your IMU connection.
[INFO] [1528187391.995333]: Encoder FrontLeft  : 0
[INFO] [1528187391.997484]: Encoder FrontRight : 0
[INFO] [1528187391.999675]: Encoder RearLeft   : 0
[INFO] [1528187392.001955]: Encoder RearRight  : 0
[FATAL] [1528187392.152619]: IMU failed to initialize. Check your IMU connection.
[INFO] [1528187392.192619]: Encoder FrontLeft  : 0
[INFO] [1528187392.195500]: Encoder FrontRight : 0
[INFO] [1528187392.198231]: Encoder RearLeft   : 0
[INFO] [1528187392.200773]: Encoder RearRight  : 0
[FATAL] [1528187392.307263]: IMU failed to initialize. Check your IMU connection.
[INFO] [1528187392.393432]: Encoder FrontLeft  : 0
[INFO] [1528187392.395921]: Encoder FrontRight : 0
[INFO] [1528187392.398128]: Encoder RearLeft   : 0
[INFO] [1528187392.400106]: Encoder RearRight  : 0
[FATAL] [1528187392.462646]: IMU failed to initialize. Check your IMU connection.
[FATAL] [1528187392.613250]: IMU failed to initialize. Check your IMU connection.
[INFO] [1528187392.616124]: Encoder FrontLeft  : 0
[INFO] [1528187392.619040]: Encoder FrontRight : 0
[INFO] [1528187392.621298]: Encoder RearLeft   : 0
[INFO] [1528187392.622921]: Encoder RearRight  : 0
[FATAL] [1528187392.772044]: IMU failed to initialize. Check your IMU connection.
[INFO] [1528187392.813106]: Encoder FrontLeft  : 0
[INFO] [1528187392.815942]: Encoder FrontRight : 0
[INFO] [1528187392.818761]: Encoder RearLeft   : 0
[INFO] [1528187392.820713]: Encoder RearRight  : 0
[FATAL] [1528187392.926476]: IMU failed to initialize. Check your IMU connection.
[INFO] [1528187393.013317]: Encoder FrontLeft  : 0
[INFO] [1528187393.015937]: Encoder FrontRight : 0
[INFO] [1528187393.018219]: Encoder RearLeft   : 0
[INFO] [1528187393.020149]: Encoder RearRight  : 0
[FATAL] [1528187393.083498]: IMU failed to initialize. Check your IMU connection.
^C[FATAL] [1528187393.232498]: IMU failed to initialize. Check your IMU connection.
[INFO] [1528187393.235436]: Encoder FrontLeft  : 0
[INFO] [1528187393.237943]: Encoder FrontRight : 0
[INFO] [1528187393.240420]: Encoder RearLeft   : 0
[INFO] [1528187393.242469]: Encoder RearRight  : 0
[base_footprint_to_base_link-6] killing on exit
[lino_base_node-5] killing on exit
[imu_filter_madgwick-4] killing on exit
[apply_calib-3] killing on exit
[rosserial_lino-2] killing on exit
[INFO] [1528187393.326328]: Send tx stop request
[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

Juan Miguel Jimeno

unread,
Jun 5, 2018, 5:20:50 AM6/5/18
to LINOROBOT
Have you commented out #define USE_MPU9250_IMU in lino_base_config.h?
Message has been deleted

choi

unread,
Jun 5, 2018, 5:35:47 AM6/5/18
to LINOROBOT
#ifndef LINO_BASE_CONFIG_H
#define LINO_BASE_CONFIG_H

//uncomment the base you're building
//#define LINO_BASE DIFFERENTIAL_DRIVE // 2WD and Tracked robot w/ 2 motors
// #define LINO_BASE SKID_STEER      // 4WD robot
// #define LINO_BASE ACKERMANN       // Car-like steering robot
#define LINO_BASE MECANUM         // Mecanum drive robot

//uncomment the motor driver you're using
#define USE_L298_DRIVER
// #define USE_BTS7960_DRIVER
// #define USE_ESC

//uncomment the IMU you're using
//#define USE_GY85_IMU
// #define USE_MPU6050_IMU
// #define USE_MPU9150_IMU
#define USE_MPU9250_IMU

#define DEBUG 1

#define K_P 0.6 // P constant
#define K_I 0.3 // I constant
#define K_D 0.5 // D constant

//define your robot' specs here
#define MAX_RPM 330               // motor's maximum RPM
#define COUNTS_PER_REV 1550       // wheel encoder's no of ticks per rev
#define WHEEL_DIAMETER 0.10       // wheel's diameter in meters
#define PWM_BITS 8                // PWM Resolution of the microcontroller
#define LR_WHEELS_DISTANCE 0.235  // distance between left and right wheels
#define FR_WHEELS_DISTANCE 0.30   // distance between front and rear wheels. Ignore this if you're on 2WD/ACKERMANN

//=================BIGGER ROBOT SPEC (BTS7960)=============================
// #define K_P 0.05  // P constant
// #define K_I 0.9   // I constant
// #define K_D 0.1   // D constant

// define your robot' specs here
// #define MAX_RPM 45               // motor's maximum RPM
// #define COUNTS_PER_REV 4000      // wheel encoder's no of ticks per rev
// #define WHEEL_DIAMETER 0.15      // wheel's diameter in meters
// #define PWM_BITS 8               // PWM Resolution of the microcontroller
// #define LR_WHEELS_DISTANCE 0.32  // distance between left and right wheels
// #define FB_WHEELS_DISTANCE 0.38  // distance between front and back wheels. Ignore this if you're on 2WD/ACKERMANN
//================= END OF BIGGER ROBOT SPEC =============================

/*
ROBOT ORIENTATION
         FRONT
    MOTOR1  MOTOR2  (2WD/ACKERMANN)
    MOTOR3  MOTOR4  (4WD/MECANUM)  
         BACK
*/

/// ENCODER PINS
#define MOTOR1_ENCODER_A 15
#define MOTOR1_ENCODER_B 14 

#define MOTOR2_ENCODER_A 11
#define MOTOR2_ENCODER_B 12 

#define MOTOR3_ENCODER_A 17
#define MOTOR3_ENCODER_B 16 

#define MOTOR4_ENCODER_A 9
#define MOTOR4_ENCODER_B 10

//MOTOR PINS
#ifdef USE_L298_DRIVER
  #define MOTOR_DRIVER L298

  #define MOTOR1_PWM 21
  #define MOTOR1_IN_A 20
  #define MOTOR1_IN_B 1

  #define MOTOR2_PWM 5
  #define MOTOR2_IN_A 8
  #define MOTOR2_IN_B 6

  #define MOTOR3_PWM 22
  #define MOTOR3_IN_A 23
  #define MOTOR3_IN_B 0

  #define MOTOR4_PWM 4
  #define MOTOR4_IN_A 2
  #define MOTOR4_IN_B 3

  #define PWM_MAX pow(2, PWM_BITS) - 1
  #define PWM_MIN -PWM_MAX
#endif 

#ifdef USE_BTS7960_DRIVER
  #define MOTOR_DRIVER BTS7960  

  #define MOTOR1_PWM 1 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR1_IN_A 21
  #define MOTOR1_IN_B 20

  #define MOTOR2_PWM 8 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR2_IN_A 5
  #define MOTOR2_IN_B 6

  #define MOTOR3_PWM 0 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR3_IN_A 22
  #define MOTOR3_IN_B 23

  #define MOTOR4_PWM 2 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR4_IN_A 4
  #define MOTOR4_IN_B 3

  #define PWM_MAX pow(2, PWM_BITS) - 1
  #define PWM_MIN -PWM_MAX
#endif

#ifdef USE_ESC
  #define MOTOR_DRIVER ESC  

  #define MOTOR1_PWM 1 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR1_IN_A 21
  #define MOTOR1_IN_B 20

  #define MOTOR2_PWM 8 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR2_IN_A 5
  #define MOTOR2_IN_B 6

  #define MOTOR3_PWM 0 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR3_IN_A 22
  #define MOTOR3_IN_B 23

  #define MOTOR4_PWM 2 //DON'T TOUCH THIS! This is just a placeholder
  #define MOTOR4_IN_A 4
  #define MOTOR4_IN_B 3

  #define PWM_MAX 400
  #define PWM_MIN -PWM_MAX
#endif

#define STEERING_PIN 7

#endif

choi

unread,
Jun 5, 2018, 5:56:51 AM6/5/18
to LINOROBOT
20180605_185044.jpg

Juan Miguel Jimeno

unread,
Jun 5, 2018, 5:59:12 AM6/5/18
to LINOROBOT
Can you paste this on firmware.ino and upload again.


Run:

sudo chmod 666 /dev/ttyACM0
screen /dev/ttyACM0 9600

Juan Miguel Jimeno

unread,
Jun 5, 2018, 9:42:28 PM6/5/18
to LINOROBOT
I also realized your IMU's GND is connected to Teensy's AGND, you want to try connecting it to GND instead?

Alex

unread,
Jun 6, 2018, 5:07:19 AM6/6/18
to LINOROBOT
What is wrong??
picture_1.jpg
picture_2.jpg

Juan Miguel Jimeno

unread,
Jun 6, 2018, 5:21:59 AM6/6/18
to LINOROBOT
You’re using the wrog launch file. Run minimal.launch instead.

Juan Miguel Jimeno

unread,
Jun 6, 2018, 5:38:23 AM6/6/18
to LINOROBOT
Can you paste this on firmware.ino and upload again.

https://gist.github.com/grassjelly/ef3b8f5741feaf2784526fb0c975bfb0

Run:
sudo chmod 666 /dev/linobase
cd ~/linorobot_ws/src/linorobot/teensy/firmware
pio run —target upload
screen /dev/linobase 9600

Please post the screenshot of the results here.

Alex

unread,
Jun 6, 2018, 9:39:03 PM6/6/18
to LINOROBOT
linorobot_ws/src/linorobot/teensy/firmware/src 
firmware.ino
I have attached the getIMUid. ino code here.
I can't see anything.

Juan Miguel Jimeno

unread,
Jun 6, 2018, 10:26:39 PM6/6/18
to LINOROBOT
Did you run the commands?

Alex

unread,
Jun 7, 2018, 3:06:33 AM6/7/18
to LINOROBOT
Yes.

jan nedvidek

unread,
Jun 9, 2018, 6:00:50 AM6/9/18
to LINOROBOT
Auto Generated Inline Image 1

jan nedvidek

unread,
Jun 9, 2018, 6:03:38 AM6/9/18
to LINOROBOT
this imu is 5V logic with stabilizer to 3v3 tensy is 3v3 logic my arduino mega and DUE works great without problems.
Reply all
Reply to author
Forward
0 new messages