LORD-MicroStrain / MSCL

MicroStrain Communication Library
https://www.microstrain.com/software/mscl
MIT License
76 stars 57 forks source link

how can I use 3DMCV7-AHRS sensor in ubuntu? is it mandatory to install driver to get sensor data using my c++ code? #396

Open Chad-Chang opened 1 month ago

Chad-Chang commented 1 month ago

Hello I am currently working on getting sensor data from 3DMCV7-AHRS using c++ code in ubuntu 20.04. but I couldn't get it. I installed MSCL library from the github hompage. and I want to use the sensor data without ROS. but

mscl::Connection connection = mscl::Connection::Serial(COM_PORT,9600);

is failed. I already checked the serial port name. I wonder if it is not possible to get data from 3DMCV7-AHRS without driver installation. I searched it on github page but there was only wireless driver for linux.

last question is there any example code for ubuntu user without ROS?


#include <iostream>
using namespace std;

#include "mscl/mscl.h"

#include "getCurrentConfig.h"
#include "parseData.h"
#include "setCurrentConfig.h"
#include "startSampling.h"
#include "setToIdle.h"
#include <iostream>
using namespace std;

int main(int argc, char **argv)
{
    //TODO: change these constants to match your setup
    const string COM_PORT = "/dev/ttyACM0";

    try
    {
        cout <<"adf" <<endl;
        //create a SerialConnection with the COM port
        mscl::Connection connection = mscl::Connection::Serial(COM_PORT);
        cout <<"adf" <<endl;

        //create an InertialNode with the connection
        mscl::InertialNode node(connection);

        cout << "Node Information: " << endl;
        cout << "Model Name: " << node.modelName() << endl;
        cout << "Model Number: " << node.modelNumber() << endl;
        cout << "Serial: " << node.serialNumber() << endl;
        cout << "Firmware: " << node.firmwareVersion().str() << endl << endl;

        //TODO: Uncomment the lines below to run the examples

        //Example: Get Configuration
        //getCurrentConfig(node);

        //Example: Set Configuration
        //setCurrentConfig(node);       //Warning: this example changes settings on your Node!

        //Example: Start Sampling
        //startSampling(node);

        //Example: Set to Idle
        //setToIdle(node);

        //Example: Parse Data
        //parseData(node);
    }
    catch(mscl::Error& e)
    {
        cout << "Error: " << e.what() << endl;
    }

    system("pause");
    return 0;
}