Giter Site home page Giter Site logo

Getting IMU data about opencat HOT 21 CLOSED

petoicamp avatar petoicamp commented on August 18, 2024
Getting IMU data

from opencat.

Comments (21)

borntoleave avatar borntoleave commented on August 18, 2024 1

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024 1

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

You can delete the macro for DEVELOPER, and use the code blocks inside to print out the angles. The format is yaw, pitch, roll.

#ifdef FIX_OVERFLOW
      for (byte g = 1; g < 3; g++) {
        yprLag[lag][g] = ypr[g];
        ypr[g] = yprLag[(lag - 1 + HISTORY) % HISTORY][g] ;
      }
      lag = (lag + 1) % HISTORY;
#endif

#ifdef DEVELOPER
      PT(ypr[0]);
      PTF("\t");
      PT(ypr[1]);
      PTF("\t");
      PTL(ypr[2]);
#endif
    }

from opencat.

sskorol avatar sskorol commented on August 18, 2024

@borntoleave and what about accelerometer data? Seems like it's not used in the code.

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

from opencat.

sskorol avatar sskorol commented on August 18, 2024

@borntoleave great, thank you!

from opencat.

sskorol avatar sskorol commented on August 18, 2024

@borntoleave to provide sufficient info to nav package I need to collect linear acceleration, angular velocity and orientation from IMU. Just want to confirm this info can be collected from Bittle. I see several examples with accel, but not really sure what’s the difference between common accel and world accel? I also see quaternion structure in code. Is it sufficient to determine orientation? Or I need to apply additional formulas against pitch, roll and yaw to compute it? And for angular velocity I guess I can use roll, pitch and yaw, right?

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

from opencat.

sskorol avatar sskorol commented on August 18, 2024

@borntoleave I want to try another IMU (10 DOF). However, i2c port on RPi is occupied by the NyBoard. Can I access NyBoard's i2C from RPi if I solder the sensor's pins to the available slots above the i2c groove socket?
image

from opencat.

sskorol avatar sskorol commented on August 18, 2024

You can connect external sensors to its port.

@borntoleave do you mean RPi port or those i2C port linked with a groove?
RPi port is already occupied with a hat. I just need to access an external i2C sensor via RPi.

Are you saying it's possible only if RPi switch is on?

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

framework
As long as the I2C switch is not dialed at RPi, the I2C port of RPi is not really connected to the board's I2C network.
The switch can disconnect the I2C network from 328P and connect them to the RPi.

from opencat.

sskorol avatar sskorol commented on August 18, 2024

@borntoleave but even if it's not connected to NyBoard's i2c network, the RPi pins would still be occupied if we use Zero or A+ board as a hat. So we can't physically connect sensors directly to Pi's i2c. And if we switch the I2C network from 328P, we won't be able to control servos via OpenCat code anymore, as you have mentioned. So what would be your recommendation in this case? What's the best option of connecting i2c sensor to Pi mounted on top of 328P w/o loosing the main Bittle's functionality?

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

from opencat.

sskorol avatar sskorol commented on August 18, 2024

But SCL and SDA pins are occupied by NyBoard (2x5 socket) when Pi is used as a hat. And 2 extra SCL/SDA pins on Pi are intended to eeprom usage only. They won't work for common use cases. So how can I wire SDA/SCL between Pi (connected to NyBoard) and a sensor then?

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

SCL and SDA pins are occupied by NyBoard (2x5 socket) when Pi is used as a hat.

Yes. But they are not really connected to anything devices. So you can solder two wires to the back of the pins on the Pi.

from opencat.

sskorol avatar sskorol commented on August 18, 2024

@borntoleave well, I did it, but here's a new issue. When I run i2cdetect -y 1, it gives me the following picture:

Screenshot from 2022-01-29 23-43-35

By default, if I don't connect RPi to NyBoard, I have only a single 0x68 address occupied by my sensor. But when RPi is used as a hat, I see this weird matrix. 0x68 address doesn't work anymore (conflict?). How can I guess which one is mine now w/o brute-forcing each address? I'm also wondering why all those addresses are occupied? Is NyBoard really bind them for something?

from opencat.

sskorol avatar sskorol commented on August 18, 2024

Ok, from the above picture I see that 0x68 address is used by MPU6050. So that's a problem. 2 sensors have the same address. Any thoughts on how to resolve this conflict?

from opencat.

sskorol avatar sskorol commented on August 18, 2024

Made it work via software i2c bus. Details here: https://forums.raspberrypi.com/viewtopic.php?p=1968858#p1967861

@borntoleave I see you committed accel data printing feature. Have you also tried to output raw gyro data? I played with it a bit based on the provided samples but always got constant values like [0;0;1]. Also, wondering why there are int values and not float like for rpy?

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

Thanks for the note on I2C.

The IMU code is mostly from i2cdevlib. The raw gyro data is VectorInt16 gy and you may print it out similar to the example code. 

The accel data is read from the register and is in integer type. You may divide some factors to get real accelerations in float. 

I validated the updated code again on my board. The 'v' token prints the MPU data once and the 'V' token prints the MPU data for every loop. I got the readings changed with my movements.
Screen Shot 2022-02-08 at 7 27 26 PM
Screen Shot 2022-02-08 at 7 27 52 PM

from opencat.

sskorol avatar sskorol commented on August 18, 2024

@borntoleave what lib/tool do you use for plotting real-time data?
Regarding gy example: yes, I used it before, but as I've mentioned, I've been always getting 0, 0, 1 values. So that's weird.

from opencat.

borntoleave avatar borntoleave commented on August 18, 2024

The 2.0 branch has a switch case for printing gyros. token -v and -V

from opencat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.