Debug receiver, integration

This commit is contained in:
Yu Asabe 2021-11-11 05:30:21 +09:00
parent 6bc9151b8f
commit 1360510b2a
3 changed files with 49 additions and 37 deletions

View File

@ -34,6 +34,7 @@ namespace v2x
friend class Application;
V2XNode* node_;
bool tf_received_;
int tf_interval_;
bool cp_started_;
};
}

View File

@ -41,7 +41,7 @@ namespace v2x
sending_(false)
{
RCLCPP_INFO(node_->get_logger(), "CpmApplication started...");
set_interval(milliseconds(1000));
set_interval(milliseconds(100));
}
void CpmApplication::set_interval(Clock::duration interval)
@ -108,8 +108,12 @@ namespace v2x
CpmApplication::Object object;
double x1 = poc->list.array[i]->xDistance.value;
double y1 = poc->list.array[i]->yDistance.value;
object.position_x = x_mgrs - (cos(orientation) * x1 - sin(orientation) * y1);
object.position_y = y_mgrs - (sin(orientation) * x1 + cos(orientation) * y1);
RCLCPP_INFO(node_->get_logger(), "cpm object: xDistance: %f, yDistance: %f", x1, y1);
x1 = x1 / 100.0;
y1 = y1 / 100.0;
object.position_x = x_mgrs + (cos(orientation) * x1 - sin(orientation) * y1);
object.position_y = y_mgrs + (sin(orientation) * x1 + cos(orientation) * y1);
RCLCPP_INFO(node_->get_logger(), "cpm object: %f, %f, %f, %f", x1, y1, object.position_x, object.position_y);
receivedObjectsStack.push_back(object);
}
node_->publishObjects(&receivedObjectsStack);
@ -253,6 +257,8 @@ namespace v2x
for (CpmApplication::Object object : objectsStack)
{
if (object.xDistance > 10000) continue;
if (object.yDistance > 10000) continue;
PerceivedObject *pObj = vanetza::asn1::allocate<PerceivedObject>();
pObj->objectID = object.objectID;
pObj->timeOfMeasurement = object.timeOfMeasurement;

View File

@ -33,6 +33,7 @@ namespace v2x
V2XApp::V2XApp(V2XNode *node) :
node_(node),
tf_received_(false),
tf_interval_(0),
cp_started_(false)
{
}
@ -45,7 +46,8 @@ namespace v2x
}
void V2XApp::tfCallback(const tf2_msgs::msg::TFMessage::ConstSharedPtr msg) {
// RCLCPP_INFO(node_->get_logger(), "V2XApp: tf msg received");
if (tf_interval_ == 4) {
RCLCPP_INFO(node_->get_logger(), "V2XApp: tf msg received");
tf_received_ = true;
double x = msg->transforms[0].transform.translation.x;
@ -79,7 +81,7 @@ namespace v2x
// RCLCPP_INFO(node_->get_logger(), "Ego Position Lat/Lon: %f, %f", lat, lon);
// RCLCPP_INFO(node_->get_logger(), "Ego Orientation: %f, %f, %f, %f", rot_x, rot_y, rot_z, rot_w);
// RCLCPP_INFO(node_->get_logger(), "Ego Orientation: %f %f %f", roll, pitch, yaw);
RCLCPP_INFO(node_->get_logger(), "Ego Orientation: %f %f %f", roll, pitch, yaw);
// RCLCPP_INFO(node_->get_logger(), "Timestamp: %d, GDT: %d", timestamp, gdt);
if (cp && cp_started_) {
@ -88,6 +90,9 @@ namespace v2x
cp->updateHeading(&yaw);
cp->updateGenerationDeltaTime(&gdt);
}
tf_interval_ = 0;
}
tf_interval_ += 1;
}
void V2XApp::start() {