|
@@ -15,10 +15,16 @@
|
|
|
#include "modules/common/util/message_util.h"
|
|
|
#include "modules/common/util/util.h"
|
|
|
|
|
|
+#include "modules/transform/transform_broadcaster.h"
|
|
|
+
|
|
|
|
|
|
std::shared_ptr<apollo::cyber::Writer<apollo::localization::LocalizationEstimate>>
|
|
|
localization_writer_;
|
|
|
|
|
|
+apollo::transform::TransformBroadcaster * mtf_broadcaster_;
|
|
|
+
|
|
|
+using apollo::transform::TransformStamped;
|
|
|
+
|
|
|
using apollo::common::Point3D;
|
|
|
using apollo::common::math::HeadingToQuaternion;
|
|
|
using apollo::common::Quaternion;
|
|
@@ -81,11 +87,28 @@ void PublishLocalization(const double x,const double y,const double z,const doub
|
|
|
pose->mutable_linear_acceleration_vrf());
|
|
|
localization_writer_->Write(localization);
|
|
|
|
|
|
+ TransformStamped rawtransform;
|
|
|
+ TransformStamped * transform = &rawtransform;
|
|
|
+ double timestamp = ::apollo::cyber::Clock::NowInSeconds();
|
|
|
+ transform->mutable_header()->set_timestamp_sec(timestamp);
|
|
|
+ transform->mutable_header()->set_frame_id("world");
|
|
|
+ transform->set_child_frame_id("novatel");
|
|
|
+ auto translation = transform->mutable_transform()->mutable_translation();
|
|
|
+ translation->set_x(x);
|
|
|
+ translation->set_y(y);
|
|
|
+ translation->set_z(z);
|
|
|
+ auto rotation = transform->mutable_transform()->mutable_rotation();
|
|
|
+ rotation->set_qx(cur_orientation.x());
|
|
|
+ rotation->set_qy(cur_orientation.y());
|
|
|
+ rotation->set_qz(cur_orientation.z());
|
|
|
+ rotation->set_qw(cur_orientation.w());
|
|
|
+
|
|
|
+ mtf_broadcaster_->SendTransform(rawtransform);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void hcp2callback(iv::rawgps xrawgps)
|
|
|
{
|
|
|
-// std::cout<<"call callback. "<<std::endl;
|
|
|
double flon = xrawgps.mfLon;
|
|
|
double flat = xrawgps.mfLat;
|
|
|
|
|
@@ -103,11 +126,12 @@ int main(int argc, char *argv[])
|
|
|
QCoreApplication a(argc, argv);
|
|
|
|
|
|
apollo::cyber::Init("apllodriver_hcp2");
|
|
|
- std::unique_ptr<apollo::cyber::Node> pilot_node = apollo::cyber::CreateNode("apllodriver_hcp2");
|
|
|
+ std::shared_ptr<apollo::cyber::Node> pilot_node = apollo::cyber::CreateNode("apllodriver_hcp2");
|
|
|
|
|
|
localization_writer_ = pilot_node->CreateWriter<apollo::localization::LocalizationEstimate>("/apollo/localization/adcpose");
|
|
|
+ mtf_broadcaster_ = new apollo::transform::TransformBroadcaster(pilot_node);
|
|
|
|
|
|
- std::string strgpsport = "/dev/ttyTHS1";
|
|
|
+ std::string strgpsport = "/dev/ttyUSB0";
|
|
|
hcp2fun funcall = std::bind(&hcp2callback,std::placeholders::_1);
|
|
|
hcp2 xhcp2(strgpsport,funcall);
|
|
|
|