JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
Plot results of processing IMU data with the on-chip Digital Motion Processor (DMP) More...
Public Member Functions | |
DemoDMP (std::string const &instance) | |
Constructor. | |
void | postInit () |
Load camera calibration on init. | |
virtual | ~DemoDMP () |
Virtual destructor for safe inheritance. | |
virtual void | process (jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override |
Processing function. | |
Public Member Functions inherited from jevois::Module | |
Module (std::string const &instance) | |
virtual | ~Module () |
virtual void | process (InputFrame &&inframe) |
virtual void | process (InputFrame &&inframe, GUIhelper &helper) |
virtual void | sendSerial (std::string const &str) |
virtual void | parseSerial (std::string const &str, std::shared_ptr< UserInterface > s) |
virtual void | supportedCommands (std::ostream &os) |
Public Member Functions inherited from jevois::Component | |
Component (std::string const &instance) | |
virtual | ~Component () |
std::shared_ptr< Comp > | addSubComponent (std::string const &instance, Args &&...args) |
void | removeSubComponent (std::shared_ptr< Comp > &component) |
void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
bool | isTopLevel () const |
bool | initialized () const |
std::string const & | className () const |
std::string const & | instanceName () const |
std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, bool doit) |
void | freezeAllParams (bool doit) |
std::string | descriptor () const |
void | setParamsFromFile (std::string const &filename) |
std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
virtual void | paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="") |
void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
void | setPath (std::string const &path) |
std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
std::shared_ptr< Comp > | addSubComponent (std::string const &instance, Args &&...args) |
void | removeSubComponent (std::shared_ptr< Comp > &component) |
void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
bool | isTopLevel () const |
bool | initialized () const |
std::string const & | className () const |
std::string const & | instanceName () const |
std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, bool doit) |
void | freezeAllParams (bool doit) |
std::string | descriptor () const |
void | setParamsFromFile (std::string const &filename) |
std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
virtual void | paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="") |
void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
void | setPath (std::string const &path) |
std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
Public Member Functions inherited from jevois::ParameterRegistry | |
virtual | ~ParameterRegistry () |
Additional Inherited Members | |
Protected Member Functions inherited from jevois::Component | |
virtual void | preInit () |
virtual void | preUninit () |
virtual void | postUninit () |
virtual void | preInit () |
virtual void | preUninit () |
virtual void | postUninit () |
Protected Member Functions inherited from jevois::ParameterRegistry | |
void | addParameter (ParameterBase *const param) |
void | removeParameter (ParameterBase *const param) |
void | callbackInitCall () |
Plot results of processing IMU data with the on-chip Digital Motion Processor (DMP)
As an optional hardware upgrade, one can install a global shutter sensor into JeVois (an OnSemi AR0135 1.2MP), which also includes on its custom circuit board for JeVois an inertial measurement unit (IMU). The IMU is a 9-degrees-of-freedom (9DOF) TDK InvenSense ICM-20948 (with 3-axis accelerometer, 3-axis gyroscope, and 3-axis magnetometer). This IMU also includes a digital motion processing unit (small programmable processor inside the IMU chip), which allows it to compute and filter quaternions directly inside the IMU chip.
This module only works with optional JeVois sensors that include an IMU! The base JeVois-A33 smart camera does not have an onboard IMU.
This module demonstrates the digital motion processing (DMP) mode of the IMU.
The specifications of this chip are quite impressive:
With quaternions computed on-chip, with an algorithm that gets sensor data at a highly accurate, fixed rate, and applies various calibrations, drift corrections, and compensations on the fly, one gets highly accurate real-time estimate of the sensor's pose in the 3D world and of how it is moving.
Note that communication with the IMU is over a 400kHz I2C bus, which may limit data readout rate depending on which data is requested from the IMU.
This IMU has 3 basic modes of operation (parameter mode, which can only be set in params.cfg):
The ICM-20948 IMU chip is a very sophisticated and complex computer on its own right. There are many settings and modes that are supported. Unfortunately, the full documentation is not open. But you can obtain it after registration with TDK InvenSense. We provide the following user-level functions in the command-line interface of JeVois to allow you to get/set raw registers of the IMU and DMP:
The registers and values can be specified in decimal, hex (with prefix 0x), or octal (with prefix 0 - beware of this and be careful). The values returned are always in hex (with no prefix). Note that the above functions are not activated by default, to prevent mistakes by rookie users. To activate them, issue a setpar camreg 1
on the JeVois console.
For example, to set the output data rate (ODR) of the DMP quaternion-9; this is in DMP register DMP_ODR_QUAT9 = 168 (see definitions in file ICM20948_regs.H of the JeVois core software):
setpar camreg 1 getdmpreg 168 # shows default divider value of 5; ODR is DMP engine rate / (1 + divider) setdmpreg 168 2
To see the effect, you should first turn on FSYNC as one of the DMP outputs (e.g., set dmp
parameter to QF). Then turn on parameter pktdbg
and turn on log messages to USB see how many quaternion packets (long packets that start with 4 0) you get between two FSYNC packets (short packets that start with 0 8 8 0). By default it is about 2 (with camera sensor at 25fps and DMP engine running at 56Hz). Then increase the arate
and grate
to 112 Hz. You should still get about 2 quaternion packets between two FSYNC packets. Finally, apply the above DMP register change. You should now see 4 quaternion packets between two FSYNC packets. Note that sometimes quaternion and FSYNC packets get combined.
As you experiment, keep in mind that the IMU can easily saturate the 400 kHz bandwidth of the i2c bus that connects it to the JeVois main processor. If you start getting errors in the console from IMUdata::parsePacket() then likely your data rate is too high for the i2c bus. One of the nice things about the DMP is that you can still run the quaternion computation very fast (e.g., at 450 Hz or even 1125 Hz) while maintaining a low output data rate.
|
inline |
|
inlinevirtual |
|
inlinevirtual |
Load camera calibration on init.
Reimplemented from jevois::Component.
|
inlineoverridevirtual |
Processing function.
Reimplemented from jevois::Module.
Definition at line 166 of file DemoDMP.C.
References jevois::DMPdata::accel, jevois::DMPdata::activity2(), jevois::IMUdata::ax(), jevois::IMUrawData::ax(), jevois::IMUdata::ay(), jevois::IMUrawData::ay(), jevois::IMUdata::az(), jevois::IMUrawData::az(), jevois::yuyv::Black, jevois::RawImage::buf, jevois::CameraCalibration::camMatrix, jevois::DMPdata::cpass, jevois::CameraCalibration::distCoeffs, jevois::rawimage::drawFilledRect(), jevois::rawimage::drawLine(), jevois::DMPdata::fix2float(), jevois::RawImage::fmt, jevois::rawimage::Font10x20, jevois::DMPdata::fsync_us(), jevois::DMPdata::geomag, jevois::IMUdata::gx(), jevois::IMUrawData::gx(), jevois::IMUdata::gy(), jevois::IMUrawData::gy(), jevois::DMPdata::gyro, jevois::IMUdata::gz(), jevois::IMUrawData::gz(), h, jevois::DMPdata::header1, jevois::DMPdata::header2, jevois::RawImage::height, JEVOIS_DMP_ACCEL, JEVOIS_DMP_ACT_RECOG, JEVOIS_DMP_CPASS, JEVOIS_DMP_FLIP_PICKUP, JEVOIS_DMP_FSYNC, JEVOIS_DMP_GEOMAG, JEVOIS_DMP_GYRO, JEVOIS_DMP_PED_STEPDET, JEVOIS_DMP_QUAT6, JEVOIS_DMP_QUAT9, jevois::join(), jevois::yuyv::LightGreen, jevois::yuyv::MedGreen, jevois::yuyv::MedGrey, jevois::yuyv::MedPurple, jevois::IMUdata::mx(), jevois::IMUrawData::mx(), jevois::IMUdata::my(), jevois::IMUrawData::my(), jevois::IMUdata::mz(), jevois::IMUrawData::mz(), jevois::RawImage::pixels(), jevois::RawImage::pixelsw(), jevois::DMPdata::quat6, jevois::DMPdata::quat9, jevois::RawImage::require(), jevois::sformat(), jevois::DMPdata::steps, jevois::DMPdata::stepts, jevois::yuyv::White, jevois::RawImage::width, and jevois::rawimage::writeText().