|
@@ -34,7 +34,9 @@
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
-#include "modulecomm.h"
|
|
|
+//#include "modulecomm.h"
|
|
|
+
|
|
|
+
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
@@ -69,16 +71,26 @@ pub_acc_ = create_publisher<AccelWithCovarianceStamped>("/localization/accelerat
|
|
|
sub_cmd_ = create_subscription<AckermannControlCommand>(
|
|
|
"/control/command/control_cmd", 1, [this](const AckermannControlCommand::SharedPtr msg) { mpcmd_ptr = msg;mbcmdupdate = true; std::cout<<"new cmd. "<<std::endl;});
|
|
|
|
|
|
-mpsharegps = new QSharedMemory("gps");
|
|
|
+
|
|
|
+ mpsharecmd = new simplesmshare("aw_ctrlcmd",1000);
|
|
|
+ mpsharecmd->create();
|
|
|
+ mpsharecmd->attach();
|
|
|
+
|
|
|
+ mpsharechassis = new simplesmshare("aw_chassis",1000);
|
|
|
+ mpsharegps = new simplesmshare("aw_gps",10000);
|
|
|
+
|
|
|
+
|
|
|
mptimer= create_wall_timer(100ms,std::bind(&pilot_autoware_bridge::callbackTimer, this));
|
|
|
mptimerGPS = create_wall_timer(10ms,std::bind(&pilot_autoware_bridge::callbackTimerGPS, this));
|
|
|
|
|
|
|
|
|
|
|
|
- ModuleFun fungpsimu =std::bind(&pilot_autoware_bridge::UpdateGPSIMU,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
+// ModuleFun fungpsimu =std::bind(&pilot_autoware_bridge::UpdateGPSIMU,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
// mpagpsimu = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungpsimu);
|
|
|
|
|
|
- mpactrlcmd = iv::modulecomm::RegisterSend("ctrlcmd",1000,1);
|
|
|
+// mpactrlcmd = iv::modulecomm::RegisterSend("ctrlcmd",1000,1);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -215,48 +227,32 @@ void pilot_autoware_bridge::callbackPose(geometry_msgs::msg::PoseStamped::Shared
|
|
|
|
|
|
void pilot_autoware_bridge::callbackTimerGPS()
|
|
|
{
|
|
|
- static int64_t nLastUpdate = 0;
|
|
|
- if(mbGPSAttach == false)
|
|
|
- {
|
|
|
- mbGPSAttach = mpsharegps->attach();
|
|
|
- }
|
|
|
- if(mbGPSAttach == false)return;
|
|
|
- int npostime = sizeof(int);
|
|
|
- int npossize = sizeof(int64_t) + npostime;
|
|
|
- int nposdata = npossize + sizeof(int);
|
|
|
-
|
|
|
- char * pmem = (char *)mpsharegps->data();
|
|
|
- int * pmark = (int * )pmem;
|
|
|
- int64_t * ptime = (int64_t * )(pmem + npostime);
|
|
|
- int * psize = (int * )(pmem + npossize);
|
|
|
- char * pdata = (char * )(pmem + nposdata);
|
|
|
-
|
|
|
- if(*pmark == 1)return;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(*ptime == nLastUpdate)
|
|
|
+
|
|
|
+
|
|
|
+ unsigned int nSize;
|
|
|
+ char * strdata = new char[10000];
|
|
|
+
|
|
|
+ int nread = mpsharegps->read(strdata,10000);
|
|
|
+
|
|
|
+ if(nread < 1)
|
|
|
{
|
|
|
- return;
|
|
|
+
|
|
|
}
|
|
|
- nLastUpdate = *ptime;
|
|
|
-
|
|
|
- std::cout<<" run hear. "<<std::endl;
|
|
|
-
|
|
|
-
|
|
|
- unsigned int nSize;
|
|
|
- nSize = *psize ;
|
|
|
- char * strdata = new char[nSize];
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ nSize = nread;
|
|
|
|
|
|
std::cout<<" nSize: "<<nSize<<std::endl;
|
|
|
- memcpy(strdata,pdata,nSize);
|
|
|
|
|
|
iv::gps::gpsimu xgpsimu;
|
|
|
if(!xgpsimu.ParseFromArray(strdata,nSize))
|
|
|
{
|
|
|
- delete strdata;
|
|
|
+ std::cout<<" parse gps msg fail."<<std::endl;
|
|
|
return;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
|
|
|
double flat = xgpsimu.lat();
|
|
|
double flon = xgpsimu.lon();
|
|
@@ -308,8 +304,37 @@ void pilot_autoware_bridge::callbackTimerGPS()
|
|
|
publish_acceleration();
|
|
|
|
|
|
|
|
|
- delete strdata;
|
|
|
std::cout<<" rec gps."<<std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ nread = mpsharechassis->read(strdata,10000);
|
|
|
+
|
|
|
+ if(nread < 1)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ iv::chassis xchassis;
|
|
|
+ // static int ncount = 0;
|
|
|
+ if(!xchassis.ParseFromArray(strdata,nread))
|
|
|
+ {
|
|
|
+ std::cout<<"Chassis ParseFrom Array Error."<<std::endl;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ steear_now = (xchassis.angle_feedback() *M_PI/180.0)/15.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ delete strdata;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -328,12 +353,12 @@ void pilot_autoware_bridge::callbackTimer()
|
|
|
xcmd.set_linear_acceleration(accel);
|
|
|
xcmd.set_linear_velocity(vel);
|
|
|
xcmd.set_steering_angle(steer);
|
|
|
- steear_now = steer;
|
|
|
+ // steear_now = steer;
|
|
|
int ndatasize = xcmd.ByteSizeLong();
|
|
|
std::shared_ptr<char> pstr_ptr = std::shared_ptr<char>(new char[ndatasize]);
|
|
|
if(xcmd.SerializeToArray(pstr_ptr.get(),ndatasize))
|
|
|
{
|
|
|
- iv::modulecomm::ModuleSendMsg(mpactrlcmd ,pstr_ptr.get(),ndatasize);
|
|
|
+ mpsharecmd->write(pstr_ptr.get(),ndatasize);
|
|
|
}
|
|
|
else
|
|
|
{
|