31 #include "../common/include/test_common.h" 38 while(!isControllerAlive())
43 geometry_msgs::Twist cmd_vel;
44 cmd_vel.linear.x = 0.0;
45 cmd_vel.angular.z = 0.0;
49 nav_msgs::Odometry old_odom = getLastOdom();
51 cmd_vel.linear.x = 0.1;
56 nav_msgs::Odometry new_odom = getLastOdom();
59 const double dx = new_odom.pose.pose.position.x - old_odom.pose.pose.position.x;
60 const double dy = new_odom.pose.pose.position.y - old_odom.pose.pose.position.y;
61 const double dz = new_odom.pose.pose.position.z - old_odom.pose.pose.position.z;
63 EXPECT_LT(fabs(dz),
EPS);
66 double roll_old, pitch_old, yaw_old;
67 double roll_new, pitch_new, yaw_new;
70 EXPECT_LT(fabs(roll_new - roll_old),
EPS);
71 EXPECT_LT(fabs(pitch_new - pitch_old),
EPS);
72 EXPECT_LT(fabs(yaw_new - yaw_old),
EPS);
73 EXPECT_NEAR(fabs(new_odom.twist.twist.linear.x), cmd_vel.linear.x,
EPS);
74 EXPECT_LT(fabs(new_odom.twist.twist.linear.y),
EPS);
75 EXPECT_LT(fabs(new_odom.twist.twist.linear.z),
EPS);
77 EXPECT_LT(fabs(new_odom.twist.twist.angular.x),
EPS);
78 EXPECT_LT(fabs(new_odom.twist.twist.angular.y),
EPS);
79 EXPECT_LT(fabs(new_odom.twist.twist.angular.z),
EPS);
85 while(!isControllerAlive())
90 geometry_msgs::Twist cmd_vel;
91 cmd_vel.linear.x = 0.0;
92 cmd_vel.angular.z = 0.0;
96 nav_msgs::Odometry old_odom = getLastOdom();
98 cmd_vel.angular.z = M_PI/10.0;
101 cmd_vel.linear.x = 0.1;
106 nav_msgs::Odometry new_odom = getLastOdom();
109 double x_answer = 0.0;
110 double y_answer = 2.0 * cmd_vel.linear.x / cmd_vel.angular.z;
111 EXPECT_NEAR(fabs(new_odom.pose.pose.position.x - old_odom.pose.pose.position.x), x_answer,
POSITION_TOLERANCE);
112 EXPECT_NEAR(fabs(new_odom.pose.pose.position.y - old_odom.pose.pose.position.y), y_answer,
POSITION_TOLERANCE);
113 EXPECT_LT(fabs(new_odom.pose.pose.position.z - old_odom.pose.pose.position.z),
EPS);
116 double roll_old, pitch_old, yaw_old;
117 double roll_new, pitch_new, yaw_new;
120 EXPECT_LT(fabs(roll_new - roll_old),
EPS);
121 EXPECT_LT(fabs(pitch_new - pitch_old),
EPS);
125 EXPECT_LT(fabs(new_odom.twist.twist.linear.y),
EPS);
126 EXPECT_LT(fabs(new_odom.twist.twist.linear.z),
EPS);
128 EXPECT_LT(fabs(new_odom.twist.twist.angular.x),
EPS);
129 EXPECT_LT(fabs(new_odom.twist.twist.angular.y),
EPS);
130 EXPECT_NEAR(fabs(new_odom.twist.twist.angular.z), M_PI/10.0,
EPS);
136 while(!isControllerAlive())
147 int main(
int argc,
char** argv)
149 testing::InitGoogleTest(&argc, argv);
150 ros::init(argc, argv,
"ackermann_steering_controller_test");
155 int ret = RUN_ALL_TESTS();
const double VELOCITY_TOLERANCE
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TEST_F(AckermannSteeringControllerTest, testForward)
tf::Quaternion tfQuatFromGeomQuat(const geometry_msgs::Quaternion &quat)
void getRPY(tfScalar &roll, tfScalar &pitch, tfScalar &yaw, unsigned int solution_number=1) const
int main(int argc, char **argv)
ROSCPP_DECL void shutdown()
const double ORIENTATION_TOLERANCE
const double POSITION_TOLERANCE