Making autonomous vehicle turn

We have train the autonomous vehicle with digits to recognise Arrows. Our tk1 default state will keep left, so when it sees the arrow it will keep right. Then when in sees the arrow again it will keep left. However the issue is when it recognise the arrows with the left and right direction. It only keeps left.

This is our codes.
if(srv.response.classification==“Arrow”){
if (classify_straight_count < 4)
{
motor_msg.data = 7;//KeepLeft
motor_pub.publish(motor_msg);
classify_straight_count = 4;
}
else if (classify_straight_count < 8 || classify_straight_count > 4 )
{
motor_msg.data = 6; //KeepRight
motor_pub.publish(motor_msg);
classify_straight_count = 8;
}

Thefore this code we are trying to do is when the car reach the junction and see the two way arrow,it will keep left as the default state is keep left. Once its see the same error again, it will go the alternate direction. This is to make it move in the figure of 8.

I am assuming this is CUDA code.

Having srv.response.classification to be a string (or char*) is highly unusual. The more efficient way is to use an enum type. For type char* the comparison operator (== “Arrow”) would not produce good results as it compares pointer values, not string contents. And std::string might not even be available on the GPU (device code).