使用imu_utils标定,拥有了db3文件了,使用ros2 launch启动编译好的imu_an节点报错,启动不了
-
此回复已被删除! -
template< typename T > T readParam( rclcpp::Node& n, std::string name ) { T ans; if ( n.get_parameter( name, ans ) ) { RCLCPP_INFO_STREAM(n.get_logger(), "Loaded " << name << ": " << ans ); } else { RCLCPP_ERROR_STREAM(n.get_logger(), "Failed to load " << name ); rclcpp::shutdown(); } return ans; }
-
@yuan 在 使用imu_utils标定,拥有了db3文件了,使用ros2 launch启动编译好的imu_an节点报错,启动不了 中说:
rclcpp::shutdown();
这里这里,你给shutdown() 干啥!!!!!
删掉!!!!!
-
@小鱼 没有呀,现在是这个样子的
int main( int argc, char** argv ) { rclcpp::init( argc, argv); //rclcpp::Node n( "~" ); auto node = std::make_shared<rclcpp::Node>("n"); //rclcpp::Logger( ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug ); RCLCPP_INFO(node->get_logger(), "Waiting for IMU data..."); std::string IMU_TOPIC; std::string IMU_NAME; int max_cluster; IMU_TOPIC = ros_utils::readParam<std::string>(*node, "imu_topic"); IMU_NAME = ros_utils::readParam<std::string>(*node, "imu_name"); data_save_path = ros_utils::readParam<std::string>(*node, "data_save_path"); max_time_min = ros_utils::readParam<int>(*node, "max_time_min"); max_cluster = ros_utils::readParam<int>(*node, "max_cluster"); // rclcpp::Subscription sub_imu = n->create_subscription( IMU_TOPIC, // // 20000000, // imu_callback, // ros::TransportHints( ).tcpNoDelay( ) ); // rclcpp::Publisher pub = n.advertise< geometry_msgs::Vector3Stamped >( ALLAN_TOPIC, // 2000 ); auto sub_imu = node->create_subscription<sensor_msgs::msg::Imu>( IMU_TOPIC, 10, imu_callback); auto gyr_x = std::make_shared<imu::AllanGyr>("gyr x", max_cluster); auto gyr_y = std::make_shared<imu::AllanGyr>("gyr y", max_cluster); auto gyr_z = std::make_shared<imu::AllanGyr>("gyr z", max_cluster); auto acc_x = std::make_shared<imu::AllanAcc>("acc x", max_cluster); auto acc_y = std::make_shared<imu::AllanAcc>("acc y", max_cluster); auto acc_z = std::make_shared<imu::AllanAcc>("acc z", max_cluster); std::cout << "wait for imu data." << std::endl; rclcpp::WallRate loop( 100 ); // ros::spin( ); while ( !end ) { loop.sleep( ); rclcpp::spin_some(node); //rclcpp::spin(n); }
-
@yuan
你的意思是read文件里面吗 -
@小鱼
删掉重新编译还是一样的鱼哥ysh@ysh:~/ros2_ws$ ros2 run imu_utils imu_an [INFO] [1723018093.544028406] [n]: Waiting for IMU data... [ERROR] [1723018093.544215273] [n]: Failed to load imu_topic [ERROR] [1723018093.544802558] [n]: Failed to load imu_name [ERROR] [1723018093.544864169] [n]: Failed to load data_save_path [ERROR] [1723018093.544946202] [n]: Failed to load max_time_min [ERROR] [1723018093.544995910] [n]: Failed to load max_cluster terminate called after throwing an instance of 'rclcpp::exceptions::RCLError' what(): could not create subscription: rcl node's context is invalid, at ./src/rcl/node.c:428 [ros2run]: Aborted
-
@yuan 在 使用imu_utils标定,拥有了db3文件了,使用ros2 launch启动编译好的imu_an节点报错,启动不了 中说:
RCLCPP_ERROR_STREAM(n.get_logger(), "Failed to load " << name ); rclcpp::shutdown();
这里,兄弟,你获取失败为什么要shutdown,就算不执行了,你也要直接抛出异常推出
-
@小鱼 他源码是这样的,我把它删掉还是报错了呀
-
@yuan 删掉重新构建,你现在没办法给我证明你现在运行的是之前的程序,还是你删除之后的
-
@小鱼
您能远程帮我看下吗,孩子都要重装系统了,磕头感谢