#include <gz/transport.hh>
#include <gz/msgs.hh>
#include <iostream>
void imuCallback(const gz::msgs::IMU &msg)
{
std::cout << "IMU Data:" << std::endl;
std::cout << " Linear Accel: "
<< msg.linear_acceleration().x() << ", "
<< msg.linear_acceleration().y() << ", "
<< msg.linear_acceleration().z() << std::endl;
// std::cout << " Angular Vel: "
// << msg.angular_velocity().x() << ", "
// << msg.angular_velocity().y() << ", "
// << msg.angular_velocity().z() << std::endl;
}
int main()
{
gz::transport::Node node;
std::string topic = "/imu";
if (!node.Subscribe(topic, imuCallback))
{
std::cerr << "Failed to subscribe to topic: " << topic << std::endl;
return -1;
}
std::cout << "Listening to IMU data on: " << topic << std::endl;
gz::transport::waitForShutdown();
return 0;
}