Formula-Student-Driverless-Simulator icon indicating copy to clipboard operation
Formula-Student-Driverless-Simulator copied to clipboard

Offset between cone positions in the ground truth topic and Unreal Engine

Open davidoort opened this issue 4 years ago • 11 comments

On training map (I haven't tested other maps), commit cd0ffe64d15cdc1f5e26f8a46cc8d490e5d81fef, the following can be observed.

image

davidoort avatar Jul 13 '20 13:07 davidoort

Which commit is this?

SijmenHuizenga avatar Jul 13 '20 13:07 SijmenHuizenga

Is it coincidence that the offset looks like to be the width of the vehicle?

SijmenHuizenga avatar Jul 14 '20 11:07 SijmenHuizenga

@davidoort Do you have an idea how we can test this without the FSTD autonomous system? I would like to confirm this is a FSDS. In the picture you show it could also be an FSTD integration problem.

SijmenHuizenga avatar Jul 14 '20 16:07 SijmenHuizenga

@SijmenHuizenga the offset seems to only occur in the x direction (i.e. the direction the car is pointing to at the start). This indicates that if there is a problem, it could do with the initial x car position in unreal (or how that position is defined vs how we interpret it to be defined). In Referee.cpp we load this start_pos (which comes from the Refereeblueprint) which is subtracted from all the cone positions. I interpret that position as the CG of the car, but maybe it is another weird reference point on the vehicle. image

Do you have an idea how we can test this without the FSTD autonomous system? I would like to confirm this is a FSDS. In the picture you show it could also be an FSTD integration problem.

I can't think of an easy way that doesn't require creating a visualization publisher and a map to car frame broadcaster based on odometry.

It would be really helpful if for now you could clarify what this start pos actually is and what point of the car gets placed on top of it.

davidoort avatar Jul 14 '20 16:07 davidoort

An x-offset of 2 meters seems to match pretty well. This was just obtained through trying out, so no idea where the error lies.

smnschfr avatar Jul 21 '20 16:07 smnschfr

I found a way to test it easely:

  1. Create a map in unreal engine with only 4 cones

  2. Add the following debug lines to the wrapper:

diff --git a/ros/src/fsds_ros_bridge/src/airsim_ros_wrapper.cpp b/ros/src/fsds_ros_bridge/src/airsim_ros_wrapper.cpp
index 80dcd5c..5d764a2 100644
--- a/ros/src/fsds_ros_bridge/src/airsim_ros_wrapper.cpp
+++ b/ros/src/fsds_ros_bridge/src/airsim_ros_wrapper.cpp
@@ -83,6 +83,9 @@ void AirsimROSWrapper::publish_track() {
     // Get car initial position
     car_start_pos = state.car_start_location;

+    std::cout << "car" << " x: " << car_start_pos.x << " y: " << car_start_pos.y << std::endl;^M
     fs_msgs::Track track;
     for (const auto& cone : state.cones) {
         fs_msgs::Cone cone_object;
@@ -90,6 +93,7 @@ void AirsimROSWrapper::publish_track() {
         cone_object.location.x = cone.location.x != 0 ? (cone.location.x - car_start_pos.x)*0.01 : 0;
         // Negative sign follows ENU convention
         cone_object.location.y = cone.location.y != 0 ? -(cone.location.y - car_start_pos.y)*0.01 : 0;
+        std::cout << "cone" << " x: " << cone_object.location.x << " y: " << cone_object.location.y << " color: " << cone.color << std::endl;^M
         if (cone.color == CarApiBase::ConeColor::Yellow) {
             cone_object.color = fs_msgs::Cone::YELLOW;
         } else if (cone.color == CarApiBase::ConeColor::Blue) {
  1. Use the measuring tool in unreal editor to check the distance between car and cones
  2. profit

SijmenHuizenga avatar Jul 24 '20 14:07 SijmenHuizenga

According to recent tests, this issue does not seem to have been fixed in either map. Is there a plan to fix this before competition? image (20) image (19)

davidoort avatar Aug 02 '20 11:08 davidoort

When testing on the trainingmap with the following cones:

image

So the cones relative to the car should be at x 284

ScreenShot00000

However, they are at 4.8 (using the above print statements output the following)

car x: 4575.15 y: 8577.82
cone x: 4.82257 y: -2.06277 color: 0
cone x: 4.82257 y: 1.43723 color: 1

So yea you are right, the problem still exists.

SijmenHuizenga avatar Aug 02 '20 12:08 SijmenHuizenga

Thanks for creating this test setup! We can either find the root source of the issue in Unreal Engine or we can simply correct for this known offset (198.257 cm) in the ROS wrapper (which at least would make it ready by the competition)

davidoort avatar Aug 02 '20 12:08 davidoort

Please let us know if you change anything here before the competition. Right now, we have implemented a correction for this offset in our AS which would need to be reversed once it's fixed in the signal.

smnschfr avatar Aug 02 '20 12:08 smnschfr

Apparently the vehicle is spawned offset from the playerstart.

The arrows show the playerstart component, the vehicle is untouched. image

The offset is probably caused by void ASimModeBase::setupVehiclesAndCamera(). This all is because airsim supports changing the spawn position from settings.jon. And somewhere some offset is introduced in the default values.

This proves that the offset will stay the same as long as we do not change the rotation of the playerstart (so we won't do that). So yea, you can trust this offset stays the same during FSOnline.

SijmenHuizenga avatar Aug 05 '20 00:08 SijmenHuizenga

This was fixed in #274

mateusz-lichota avatar Aug 24 '22 19:08 mateusz-lichota