How do I use the Livox SDK? #155

Open
opened 2021-11-23 23:51:54 +01:00 by Grudz · 1 comment
Grudz commented 2021-11-23 23:51:54 +01:00 (Migrated from github.com)

I want to turn my livox on and off via software. I have a similar application to issue 94 and I don't want my Livox running 24/7

I am trying to use LidarSetMode to achieve this documented here but I can't make an instance of the livox class to interact with the SDK for some reason. The following code is the bottom of livox_ros_driver.cpp which includes my modifications. (I'm using the ws_livox downloaded from this repo)

  lddc->lds_->semaphore_.Wait();
  if(true) // Configure as launch file param later
  {
    //ROS_FATAL("Here");
    int32_t test;
    //LdsLidar *g_lds_ldiar = nullptr;
    //Lds* read_lidar_ptr = static_cast<Lds *>(read_lidar);
    std::cout << "Count: " << int(lddc->lds_->lidar_count_) << std::endl;
    for (uint32_t i = 0; i < kMaxSourceLidar; i++) {
      test = LidarSetMode(lddc->lds_->lidars_[i].handle, kLidarModePowerSaving, randomCB, (void *)lddc->lds_);  // I NEED HELP WITH THIS LINE
      std::cout << "Power Saving value:" << kLidarModePowerSaving << std::endl; 
      std::cout << "State: " << lddc->lds_->lidars_[i].connect_state << std::endl;
      std::cout << "LidarSetMode ouput:" << test << std::endl;
    }
  }
  //ros::spin();
  while (ros::ok()) {
    lddc->DistributeLidarData();
  }
  return 0;
}

The following snip is the output of the above code when running livox_lidar.launch

Lidar[0][3WEDH7600108471] storage queue size : 500 512
Lidar[0][3WEDH7600108471] imu storage queue size : 256 256
[2021-11-22 16:42:15.314] [console] [info]  Recieve Ack: Set 0 Id 4 Seq 9  [command_handler.cpp] [OnCommand] [118]
Lidar start sample success
Count: 32
Lidar handle: 0
Power Saving value:2
State: 3
LidarSetMode ouput:0
Lidar handle: 32
Power Saving value:2
State: 0
LidarSetMode ouput:-7
Lidar handle: 32
Power Saving value:2
State: 0

(Where this part is repeated for the rest of the for-loop iterations)

LidarSetMode ouput:-7
Lidar handle: 32
Power Saving value:2
State: 0

Any help? Does anyone know how to properly use the Livox SDK api with C++?

I want to turn my livox on and off via software. I have a similar application to [issue 94](https://github.com/Livox-SDK/Livox-SDK/issues/94) and I don't want my Livox running 24/7 I am trying to use LidarSetMode to achieve this [documented here](https://livox-sdk.github.io/Livox-SDK-Doc/livox__sdk_8h.html#af5e112560f926a14b9b37e03f76b5a6b) but I can't make an instance of the livox class to interact with the SDK for some reason. The following code is the bottom of livox_ros_driver.cpp which includes my modifications. (I'm using the ws_livox downloaded from this repo) ``` lddc->lds_->semaphore_.Wait(); if(true) // Configure as launch file param later { //ROS_FATAL("Here"); int32_t test; //LdsLidar *g_lds_ldiar = nullptr; //Lds* read_lidar_ptr = static_cast<Lds *>(read_lidar); std::cout << "Count: " << int(lddc->lds_->lidar_count_) << std::endl; for (uint32_t i = 0; i < kMaxSourceLidar; i++) { test = LidarSetMode(lddc->lds_->lidars_[i].handle, kLidarModePowerSaving, randomCB, (void *)lddc->lds_); // I NEED HELP WITH THIS LINE std::cout << "Power Saving value:" << kLidarModePowerSaving << std::endl; std::cout << "State: " << lddc->lds_->lidars_[i].connect_state << std::endl; std::cout << "LidarSetMode ouput:" << test << std::endl; } } //ros::spin(); while (ros::ok()) { lddc->DistributeLidarData(); } return 0; } ``` The following snip is the output of the above code when running livox_lidar.launch ``` Lidar[0][3WEDH7600108471] storage queue size : 500 512 Lidar[0][3WEDH7600108471] imu storage queue size : 256 256 [2021-11-22 16:42:15.314] [console] [info] Recieve Ack: Set 0 Id 4 Seq 9 [command_handler.cpp] [OnCommand] [118] Lidar start sample success Count: 32 Lidar handle: 0 Power Saving value:2 State: 3 LidarSetMode ouput:0 Lidar handle: 32 Power Saving value:2 State: 0 LidarSetMode ouput:-7 Lidar handle: 32 Power Saving value:2 State: 0 ``` (Where this part is repeated for the rest of the for-loop iterations) ``` LidarSetMode ouput:-7 Lidar handle: 32 Power Saving value:2 State: 0 ``` Any help? Does anyone know how to properly use the Livox SDK api with C++?
gabrielheider commented 2022-05-05 09:03:31 +02:00 (Migrated from github.com)

Hi Grudz,
I have similar problem. I want to change working mode from c++ SDK I do not understand how to properly use the SDK. Did you solve your problem? And can you or someone post a short example how to change working mode from c++. so I am not working with Ros.
Thanks

Hi Grudz, I have similar problem. I want to change working mode from c++ SDK I do not understand how to properly use the SDK. Did you solve your problem? And can you or someone post a short example how to change working mode from c++. so I am not working with Ros. Thanks
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mmr/Livox-SDK#155