@@ -153,6 +153,8 @@ void AirsimROSWrapper::create_ros_pubs_from_settings_json()
153153
154154 const std::string topic_prefix = " ~/" + curr_vehicle_name;
155155 vehicle_ros->odom_local_pub_ = nh_->create_publisher <nav_msgs::msg::Odometry>(topic_prefix + " /" + odom_frame_id_, 10 );
156+ if (isENU_)
157+ vehicle_ros->odom_local_enu_pub_ = nh_->create_publisher <nav_msgs::msg::Odometry>(topic_prefix + " /" + ENU_ODOM_FRAME_ID , 10 );
156158
157159 vehicle_ros->env_pub_ = nh_->create_publisher <airsim_interfaces::msg::Environment>(topic_prefix + " /environment" , 10 );
158160
@@ -603,6 +605,8 @@ nav_msgs::msg::Odometry AirsimROSWrapper::get_odom_msg_from_kinematic_state(cons
603605{
604606 nav_msgs::msg::Odometry odom_msg;
605607
608+ odom_msg.header .frame_id = AIRSIM_FRAME_ID ;
609+
606610 odom_msg.pose .pose .position .x = kinematics_estimated.pose .position .x ();
607611 odom_msg.pose .pose .position .y = kinematics_estimated.pose .position .y ();
608612 odom_msg.pose .pose .position .z = kinematics_estimated.pose .position .z ();
@@ -618,16 +622,40 @@ nav_msgs::msg::Odometry AirsimROSWrapper::get_odom_msg_from_kinematic_state(cons
618622 odom_msg.twist .twist .angular .y = kinematics_estimated.twist .angular .y ();
619623 odom_msg.twist .twist .angular .z = kinematics_estimated.twist .angular .z ();
620624
621- if (isENU_) {
622- std::swap (odom_msg.pose .pose .position .x , odom_msg.pose .pose .position .y );
623- odom_msg.pose .pose .position .z = -odom_msg.pose .pose .position .z ;
624- std::swap (odom_msg.pose .pose .orientation .x , odom_msg.pose .pose .orientation .y );
625- odom_msg.pose .pose .orientation .z = -odom_msg.pose .pose .orientation .z ;
626- std::swap (odom_msg.twist .twist .linear .x , odom_msg.twist .twist .linear .y );
627- odom_msg.twist .twist .linear .z = -odom_msg.twist .twist .linear .z ;
628- std::swap (odom_msg.twist .twist .angular .x , odom_msg.twist .twist .angular .y );
629- odom_msg.twist .twist .angular .z = -odom_msg.twist .twist .angular .z ;
630- }
625+ return odom_msg;
626+ }
627+
628+ nav_msgs::msg::Odometry AirsimROSWrapper::convert_odom_to_enu (const nav_msgs::msg::Odometry original_odom_msg) const
629+ {
630+ nav_msgs::msg::Odometry odom_msg;
631+
632+ odom_msg.header .stamp = original_odom_msg.header .stamp ;
633+ odom_msg.header .frame_id = " world_enu" ;
634+
635+ odom_msg.pose .pose .position .x = original_odom_msg.pose .pose .position .x ;
636+ odom_msg.pose .pose .position .y = original_odom_msg.pose .pose .position .y ;
637+ odom_msg.pose .pose .position .z = original_odom_msg.pose .pose .position .z ;
638+
639+ odom_msg.pose .pose .orientation .x = original_odom_msg.pose .pose .orientation .x ;
640+ odom_msg.pose .pose .orientation .y = original_odom_msg.pose .pose .orientation .y ;
641+ odom_msg.pose .pose .orientation .z = original_odom_msg.pose .pose .orientation .z ;
642+ odom_msg.pose .pose .orientation .w = original_odom_msg.pose .pose .orientation .w ;
643+
644+ odom_msg.twist .twist .linear .x = original_odom_msg.twist .twist .linear .x ;
645+ odom_msg.twist .twist .linear .y = original_odom_msg.twist .twist .linear .y ;
646+ odom_msg.twist .twist .linear .z = original_odom_msg.twist .twist .linear .z ;
647+ odom_msg.twist .twist .angular .x = original_odom_msg.twist .twist .angular .x ;
648+ odom_msg.twist .twist .angular .y = original_odom_msg.twist .twist .angular .y ;
649+ odom_msg.twist .twist .angular .z = original_odom_msg.twist .twist .angular .z ;
650+
651+ std::swap (odom_msg.pose .pose .position .x , odom_msg.pose .pose .position .y );
652+ odom_msg.pose .pose .position .z = -odom_msg.pose .pose .position .z ;
653+ std::swap (odom_msg.pose .pose .orientation .x , odom_msg.pose .pose .orientation .y );
654+ odom_msg.pose .pose .orientation .z = -odom_msg.pose .pose .orientation .z ;
655+ std::swap (odom_msg.twist .twist .linear .x , odom_msg.twist .twist .linear .y );
656+ odom_msg.twist .twist .linear .z = -odom_msg.twist .twist .linear .z ;
657+ std::swap (odom_msg.twist .twist .angular .x , odom_msg.twist .twist .angular .y );
658+ odom_msg.twist .twist .angular .z = -odom_msg.twist .twist .angular .z ;
631659
632660 return odom_msg;
633661}
@@ -1026,6 +1054,9 @@ void AirsimROSWrapper::publish_vehicle_state()
10261054
10271055 // odom and transforms
10281056 vehicle_ros->odom_local_pub_ ->publish (vehicle_ros->curr_odom_ );
1057+ if (isENU_)
1058+ vehicle_ros->odom_local_enu_pub_ ->publish (convert_odom_to_enu (vehicle_ros->curr_odom_ ));
1059+
10291060 publish_odom_tf (vehicle_ros->curr_odom_ );
10301061
10311062 // ground truth GPS position from sim/HITL
0 commit comments