jmscslgroup / catvehicle

A macroscopic multivehicle tesbed and hardware-in-the-loop simulator for autonomous driving
https://jmscslgroup.github.io/catvehicle
41 stars 14 forks source link

Calculation of ground truth steering angle #10

Closed NovoG93 closed 2 years ago

NovoG93 commented 2 years ago

Why do you calculate the simplified steering angle (I assume you are using a bicycle model) using (see):

a0 = steering_joints[0]->Position(0);
//a1 = steering_joints[1]->GetAngle(0).Radian();
a1 = steering_joints[1]->Position(0);
// average these values, though in most modes they will be equal

steering_msg.torque.z = (a0+a1)/2.0;

In Jazar, R. N. (2017). Vehicle dynamics: theory and application. Springer. equation 7.4 the steering angle for the simplified bicycle is computed as:

formula

So imho it should be smth like

index 9fe0ea1..c7762bc 100644
--- a/src/cont.cc
+++ b/src/cont.cc
@@ -46,6 +46,7 @@ TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 #include "std_msgs/String.h"
 #include "catvehicle/cont.hh"
 #include <tf/transform_broadcaster.h>
+#include <math.h>

 using namespace std;

@@ -200,7 +201,13 @@ namespace gazebo
         a1 = steering_joints[1]->Position(0);
         // average these values, though in most modes they will be equal

-        steering_msg.torque.z = (a0+a1)/2.0;
+        // steering_msg.torque.z = (a0+a1)/2.0;
+
+        double cot_left = 1/tan(a0);
+        double cot_right = 1/tan(a1);
+        double cot_steer = (cot_left + cot_right)/2;
+        double steering_angle = atan(1/cot_steer);
+        steering_msg.torque.z = steering_angle;
         steering_pub.publish(steering_msg);
rahulbhadani commented 2 years ago

We are using Ackermann's steering model not the bicycle model.

NovoG93 commented 2 years ago

Even in your paper Fig.2 (a) you state that

The vehicle receives single value of steering angle as input which is calculated as formula

rahulbhadani commented 2 years ago

No, that's not what Figure 2a is. Figure 2a is the Ackermann Steering model. I recommend you take a look at https://www.youtube.com/watch?v=i6uBwudwA5o&t=1s for on how Ackermann steering works. The input CAT vehicle takes as if it were a bicycle model, but then cmdvel2gazebo.py translates to Ackermann steering model.

NovoG93 commented 2 years ago

That is exactly my point. And I am not talking about cmdvel2gazebo.py but the cont.cc file where you publish the GT value of the steering. If you want to publish the GT value of the steering it should be computable by the receiving the two steering angles of the front wheels, shouldn't it?

rahulbhadani commented 2 years ago

No, there is a dynamic in the play. The output is not the same as the input. It will never be. Assume that vehicle itself is a non-linear transfer function - if you want a mapping then you need to do system identification. What is being published through cont.cc is after fetching the output from the ros-gazebo-control plugin whose job is to translate inputs to motion.

NovoG93 commented 2 years ago

Ah okay, thank you for pointing that out