ISLoggerExample.cpp
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright (c) 2014-2021 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #include <stdio.h>
14 
15 // STEP 1: Add Includes
16 // Change these include paths to the correct paths for your project
17 #include "../../src/InertialSense.h"
18 
19 static void dataCallback(InertialSense* i, p_data_t* data, int pHandle)
20 {
21  static uint64_t dataCount;
22  printf("Data count: %" PRIu64 " \r", ++dataCount);
23 }
24 
25 int main(int argc, char* argv[])
26 {
27  if (argc < 2)
28  {
29  printf("Please pass the com port and then optionally the log type as the only arguments (dat,sdat,csv,kml).\r\n");
30  // In Visual Studio IDE, this can be done through "Project Properties -> Debugging -> Command Arguments: COM3 kml"
31  return -1;
32  }
33 
34 
35  // STEP 2: Instantiate InertialSense class
36  // InertialSense class wraps communications and logging in a convenient, easy to use class
37  InertialSense inertialSense(dataCallback);
38  if (!inertialSense.Open(argv[1]))
39  {
40  std::cout << "Failed to open com port at " << argv[1] << std::endl;
41  }
42 
43 
44  // STEP 3: Enable data logger
45  // get log type from command line
46  cISLogger::eLogType logType = (argc < 3 ? cISLogger::eLogType::LOGTYPE_DAT : cISLogger::ParseLogType(argv[2]));
47  inertialSense.SetLoggerEnabled(true, "", logType);
48 
49 
50  // STEP 4: Enable data broadcasting
51  // stop current data streaming
52  inertialSense.StopBroadcasts();
53 
54  // broadcast the standard set of post processing messages (ins, imu, etc.)
56 
57  // instead of the rmc preset (real-time message controller) you can request individual messages...
58  // Ask for INS message w/ update 40ms period (4ms source period x 10). Set data rate to zero to disable broadcast and pull a single packet.
59 // inertialSense.BroadcastBinaryData(DID_DUAL_IMU, 10);
60 
61 
62  // utility class for display and ctrl-c handling
63  cInertialSenseDisplay display;
64 
65  std::cout << "Started logger..." << std::endl;
66 
67  while (!display.ControlCWasPressed())
68  {
69  inertialSense.Update();
70  }
71 
72  inertialSense.Close();
73 }
74 
void StopBroadcasts(bool allPorts=true)
int main(int argc, char *argv[])
static void dataCallback(InertialSense *i, p_data_t *data, int pHandle)
#define RMC_PRESET_INS_BITS
Definition: data_sets.h:1342
std::ostream & cout()
bool SetLoggerEnabled(bool enable, const string &path=cISLogger::g_emptyString, cISLogger::eLogType logType=cISLogger::eLogType::LOGTYPE_DAT, uint64_t rmcPreset=RMC_PRESET_PPD_BITS, float maxDiskSpacePercent=0.5f, uint32_t maxFileSize=1024 *1024 *5, const string &subFolder=cISLogger::g_emptyString)
static eLogType ParseLogType(const string &logTypeString)
Definition: ISLogger.h:134
#define printf(...)
Definition: evb_tasks.h:36
USBInterfaceDescriptor data
bool Open(const char *port, int baudRate=IS_COM_BAUDRATE_DEFAULT, bool disableBroadcastsOnClose=false)
void BroadcastBinaryDataRmcPreset(uint64_t rmcPreset=RMC_PRESET_INS_BITS, uint32_t rmcOptions=0)


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57