|
@@ -87,6 +87,8 @@ void service1_enablechassis(const std::shared_ptr<adc_autoware_msgs::srv::Chassi
|
|
|
|
|
|
adc_controller_shenlan_v2_core::adc_controller_shenlan_v2_core() : Node("adc_controller_shenlan_v2")
|
|
adc_controller_shenlan_v2_core::adc_controller_shenlan_v2_core() : Node("adc_controller_shenlan_v2")
|
|
{
|
|
{
|
|
|
|
+ mfTorqueLim = declare_parameter<double >("TorqueLim",600.0);
|
|
|
|
+ std::cout<<" torque limit : "<<mfTorqueLim<<std::endl;
|
|
gdecition_def.set_brake(0);
|
|
gdecition_def.set_brake(0);
|
|
gdecition_def.set_rightlamp(false);
|
|
gdecition_def.set_rightlamp(false);
|
|
gdecition_def.set_leftlamp(false);
|
|
gdecition_def.set_leftlamp(false);
|
|
@@ -102,15 +104,21 @@ adc_controller_shenlan_v2_core::adc_controller_shenlan_v2_core() : Node("adc_con
|
|
sub_msgs_chassis = this->create_subscription<adc_autoware_msgs::msg::AdcChassis>("chassis",10,
|
|
sub_msgs_chassis = this->create_subscription<adc_autoware_msgs::msg::AdcChassis>("chassis",10,
|
|
std::bind(&adc_controller_shenlan_v2_core::topic_chassis_callback,this,_1));
|
|
std::bind(&adc_controller_shenlan_v2_core::topic_chassis_callback,this,_1));
|
|
|
|
|
|
|
|
+ pub_steer_ = create_publisher<SteeringReport>("/vehicle/status/steering_status", 10);
|
|
|
|
+
|
|
pub_msgs_cansend0 = this->create_publisher<adc_autoware_msgs::msg::AdcCanMsgs>("cansend0",10);
|
|
pub_msgs_cansend0 = this->create_publisher<adc_autoware_msgs::msg::AdcCanMsgs>("cansend0",10);
|
|
|
|
|
|
- sub_msgs_cmd = this->create_subscription<autoware_auto_control_msgs::msg::AckermannControlCommand>("xx",10,
|
|
|
|
|
|
+ sub_msgs_cmd = this->create_subscription<autoware_control_msgs::msg::Control>("/control/command/control_cmd",10,
|
|
std::bind(&adc_controller_shenlan_v2_core::topic_cmd_callback,this,_1));
|
|
std::bind(&adc_controller_shenlan_v2_core::topic_cmd_callback,this,_1));
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
srv_chassisenable = this->create_service<adc_autoware_msgs::srv::ChassisEnableCtrl>("/adc_controller_shenlan_v2/chassisenable",
|
|
srv_chassisenable = this->create_service<adc_autoware_msgs::srv::ChassisEnableCtrl>("/adc_controller_shenlan_v2/chassisenable",
|
|
std::bind(&adc_controller_shenlan_v2_core::service_enablechassis,this,_1,_2));
|
|
std::bind(&adc_controller_shenlan_v2_core::service_enablechassis,this,_1,_2));
|
|
|
|
|
|
mpthreadsend = new std::thread(&adc_controller_shenlan_v2_core::threadsend,this);
|
|
mpthreadsend = new std::thread(&adc_controller_shenlan_v2_core::threadsend,this);
|
|
|
|
+
|
|
|
|
+ // mptestthread = new std::thread(&adc_controller_shenlan_v2_core::threadtest,this);
|
|
}
|
|
}
|
|
|
|
|
|
adc_controller_shenlan_v2_core::~adc_controller_shenlan_v2_core()
|
|
adc_controller_shenlan_v2_core::~adc_controller_shenlan_v2_core()
|
|
@@ -131,6 +139,11 @@ void adc_controller_shenlan_v2_core::topic_chassis_callback(const adc_autoware_m
|
|
gfWheelAngle = msg.angle_feedback;
|
|
gfWheelAngle = msg.angle_feedback;
|
|
gbHaveWheelAngle = true;
|
|
gbHaveWheelAngle = true;
|
|
|
|
|
|
|
|
+ current_steer_.steering_tire_angle = static_cast<double>(gfWheelAngle/(1.0* (180.0/M_PI) * 15.0));
|
|
|
|
+ current_steer_.stamp = get_clock()->now();
|
|
|
|
+
|
|
|
|
+ pub_steer_->publish(current_steer_);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
void adc_controller_shenlan_v2_core::threadsend()
|
|
void adc_controller_shenlan_v2_core::threadsend()
|
|
@@ -141,6 +154,7 @@ void adc_controller_shenlan_v2_core::threadsend()
|
|
UnAcitvate();
|
|
UnAcitvate();
|
|
// UnAcitvate();
|
|
// UnAcitvate();
|
|
|
|
|
|
|
|
+mbEnableChassis = true;
|
|
int nstate = 0; //0 Un 1 Activate
|
|
int nstate = 0; //0 Un 1 Activate
|
|
// Activate();
|
|
// Activate();
|
|
while(mbtheadrun)
|
|
while(mbtheadrun)
|
|
@@ -160,6 +174,7 @@ void adc_controller_shenlan_v2_core::threadsend()
|
|
{
|
|
{
|
|
if(nstate == 0)
|
|
if(nstate == 0)
|
|
{
|
|
{
|
|
|
|
+ std::cout<<" activate. "<<std::endl;
|
|
Activate();
|
|
Activate();
|
|
nstate = 1;
|
|
nstate = 1;
|
|
}
|
|
}
|
|
@@ -168,6 +183,7 @@ void adc_controller_shenlan_v2_core::threadsend()
|
|
{
|
|
{
|
|
if(nstate == 1)
|
|
if(nstate == 1)
|
|
{
|
|
{
|
|
|
|
+ std::cout<<" unactivate. "<<std::endl;
|
|
UnAcitvate();
|
|
UnAcitvate();
|
|
nstate = 0;
|
|
nstate = 0;
|
|
}
|
|
}
|
|
@@ -194,7 +210,85 @@ void adc_controller_shenlan_v2_core::threadsend()
|
|
std::cout<<std::chrono::system_clock::now().time_since_epoch().count()<<" thread send exit."<<std::endl;
|
|
std::cout<<std::chrono::system_clock::now().time_since_epoch().count()<<" thread send exit."<<std::endl;
|
|
}
|
|
}
|
|
|
|
|
|
-void adc_controller_shenlan_v2_core::topic_cmd_callback(const autoware_auto_control_msgs::msg::AckermannControlCommand & msg)
|
|
|
|
|
|
+void adc_controller_shenlan_v2_core::threadtest()
|
|
|
|
+{
|
|
|
|
+ bool brun = true;
|
|
|
|
+ while(brun)
|
|
|
|
+ {
|
|
|
|
+ iv::brain::decition xdecition;
|
|
|
|
+ double facc = 0;
|
|
|
|
+ double ftorque = 0;
|
|
|
|
+ double fbrake = 0;
|
|
|
|
+ double fwheelangle = 0;
|
|
|
|
+
|
|
|
|
+ // std::cout<<" receive cmd. "<<std::endl;
|
|
|
|
+
|
|
|
|
+ facc = 0;
|
|
|
|
+
|
|
|
|
+ double fVehWeight = 1800;
|
|
|
|
+ // double fg = 9.8;
|
|
|
|
+ double fRollForce = 50;
|
|
|
|
+ const double fRatio = 2.5;
|
|
|
|
+ double fNeed = fRollForce + fVehWeight*facc;
|
|
|
|
+
|
|
|
|
+ ftorque = fNeed/fRatio;
|
|
|
|
+ fbrake = 0;
|
|
|
|
+ if(ftorque<0)
|
|
|
|
+ {
|
|
|
|
+ fbrake = facc;
|
|
|
|
+ ftorque = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// facc = xctrlcmd.linear_acceleration();
|
|
|
|
+ if(ftorque >600)ftorque = 600;
|
|
|
|
+ fwheelangle = 90;
|
|
|
|
+ if(fwheelangle>430)fwheelangle = 430;
|
|
|
|
+ if(fwheelangle<-430)fwheelangle = -430;
|
|
|
|
+ // std::cout<<" acc: "<<facc<<" wheel: "<<fwheelangle<<std::endl;
|
|
|
|
+ xdecition.set_accelerator(facc);
|
|
|
|
+ xdecition.set_brake(fbrake);
|
|
|
|
+ xdecition.set_leftlamp(false);
|
|
|
|
+ xdecition.set_rightlamp(false);
|
|
|
|
+ xdecition.set_speed(0);
|
|
|
|
+ xdecition.set_wheelangle(fwheelangle);
|
|
|
|
+ xdecition.set_wheelspeed(300);
|
|
|
|
+ xdecition.set_torque(ftorque);
|
|
|
|
+ xdecition.set_mode(1);
|
|
|
|
+ xdecition.set_gear(1);
|
|
|
|
+ xdecition.set_handbrake(0);
|
|
|
|
+ xdecition.set_grade(1);
|
|
|
|
+ xdecition.set_engine(0);
|
|
|
|
+ xdecition.set_brakelamp(false);
|
|
|
|
+ xdecition.set_ttc(15);
|
|
|
|
+// xdecition.set_air_enable(decition->air_enable);
|
|
|
|
+// xdecition.set_air_temp(decition->air_temp);
|
|
|
|
+// xdecition.set_air_mode(decition->air_mode);
|
|
|
|
+// xdecition.set_wind_level(decition->wind_level);
|
|
|
|
+ xdecition.set_roof_light(0);
|
|
|
|
+ xdecition.set_home_light(0);
|
|
|
|
+// xdecition.set_air_worktime(decition->air_worktime);
|
|
|
|
+// xdecition.set_air_offtime(decition->air_offtime);
|
|
|
|
+// xdecition.set_air_on(decition->air_on);
|
|
|
|
+ xdecition.set_door(0);
|
|
|
|
+ xdecition.set_dippedlight(0);
|
|
|
|
+
|
|
|
|
+ xdecition.set_angle_mode(1);
|
|
|
|
+ xdecition.set_angle_active(1);
|
|
|
|
+ xdecition.set_acc_active(1);
|
|
|
|
+ xdecition.set_brake_active(1);
|
|
|
|
+// xdecition.set_brake_type(1);
|
|
|
|
+ xdecition.set_auto_mode(3);
|
|
|
|
+
|
|
|
|
+ gMutex.lock();
|
|
|
|
+ gdecition.CopyFrom(xdecition);
|
|
|
|
+ gMutex.unlock();
|
|
|
|
+
|
|
|
|
+ gnDecitionNum = gnDecitionNumMax;
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void adc_controller_shenlan_v2_core::topic_cmd_callback(const autoware_control_msgs::msg::Control & msg)
|
|
{
|
|
{
|
|
(void)msg;
|
|
(void)msg;
|
|
iv::brain::decition xdecition;
|
|
iv::brain::decition xdecition;
|
|
@@ -203,6 +297,17 @@ void adc_controller_shenlan_v2_core::topic_cmd_callback(const autoware_auto_cont
|
|
double fbrake = 0;
|
|
double fbrake = 0;
|
|
double fwheelangle = 0;
|
|
double fwheelangle = 0;
|
|
|
|
|
|
|
|
+ static int topiccmdcount = 0;
|
|
|
|
+ static int nlastprint = 0;
|
|
|
|
+ topiccmdcount++;
|
|
|
|
+ if((topiccmdcount - nlastprint)>= 100)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<" receicve topic count: "<<topiccmdcount<<std::endl;
|
|
|
|
+ nlastprint = topiccmdcount;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // std::cout<<" receive topic cmd. "<<std::endl;
|
|
|
|
+
|
|
facc = msg.longitudinal.acceleration;
|
|
facc = msg.longitudinal.acceleration;
|
|
|
|
|
|
double fVehWeight = 1800;
|
|
double fVehWeight = 1800;
|
|
@@ -220,15 +325,16 @@ void adc_controller_shenlan_v2_core::topic_cmd_callback(const autoware_auto_cont
|
|
}
|
|
}
|
|
|
|
|
|
// facc = xctrlcmd.linear_acceleration();
|
|
// facc = xctrlcmd.linear_acceleration();
|
|
|
|
+ if(ftorque > mfTorqueLim)ftorque = mfTorqueLim;
|
|
fwheelangle = msg.lateral.steering_tire_angle * (180.0/M_PI) * 15.0;
|
|
fwheelangle = msg.lateral.steering_tire_angle * (180.0/M_PI) * 15.0;
|
|
if(fwheelangle>430)fwheelangle = 430;
|
|
if(fwheelangle>430)fwheelangle = 430;
|
|
if(fwheelangle<-430)fwheelangle = -430;
|
|
if(fwheelangle<-430)fwheelangle = -430;
|
|
- std::cout<<" acc: "<<facc<<" wheel: "<<fwheelangle<<std::endl;
|
|
|
|
|
|
+ // std::cout<<" acc: "<<facc<<" wheel: "<<fwheelangle<<std::endl;
|
|
xdecition.set_accelerator(facc);
|
|
xdecition.set_accelerator(facc);
|
|
xdecition.set_brake(fbrake);
|
|
xdecition.set_brake(fbrake);
|
|
xdecition.set_leftlamp(false);
|
|
xdecition.set_leftlamp(false);
|
|
xdecition.set_rightlamp(false);
|
|
xdecition.set_rightlamp(false);
|
|
- xdecition.set_speed(msg.longitudinal.speed * 3.6);
|
|
|
|
|
|
+ xdecition.set_speed(msg.longitudinal.velocity * 3.6);
|
|
xdecition.set_wheelangle(fwheelangle);
|
|
xdecition.set_wheelangle(fwheelangle);
|
|
xdecition.set_wheelspeed(300);
|
|
xdecition.set_wheelspeed(300);
|
|
xdecition.set_torque(ftorque);
|
|
xdecition.set_torque(ftorque);
|
|
@@ -251,6 +357,13 @@ void adc_controller_shenlan_v2_core::topic_cmd_callback(const autoware_auto_cont
|
|
xdecition.set_door(0);
|
|
xdecition.set_door(0);
|
|
xdecition.set_dippedlight(0);
|
|
xdecition.set_dippedlight(0);
|
|
|
|
|
|
|
|
+ xdecition.set_angle_mode(1);
|
|
|
|
+ xdecition.set_angle_active(1);
|
|
|
|
+ xdecition.set_acc_active(1);
|
|
|
|
+ xdecition.set_brake_active(1);
|
|
|
|
+// xdecition.set_brake_type(1);
|
|
|
|
+ xdecition.set_auto_mode(3);
|
|
|
|
+
|
|
gMutex.lock();
|
|
gMutex.lock();
|
|
gdecition.CopyFrom(xdecition);
|
|
gdecition.CopyFrom(xdecition);
|
|
gMutex.unlock();
|
|
gMutex.unlock();
|