ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The conditionals in your velocity callback aren't meaningful c++:
if (x = vel.linear.x - 1.0) //Forward move.
{
digitalWrite(24, LOW);
digitalWrite(23, HIGH);
}
else if (y = vel.linear.y - 1.0) //Backward move
{
digitalWrite(24, HIGH);
digitalWrite(23, LOW);
}
else
{
digitalWrite(24, LOW); //STOP
digitalWrite(23, LOW);
}
Since you use the single equals sign you're changing the value of x and y instead of checking it. Instead you should use the less-than and greater-than operators (and a little bit of wiggle room so you don't need to send exactly 0 to stop):
if (vel.linear.x > 0.1) //Forward move.
{
digitalWrite(24, LOW);
digitalWrite(23, HIGH);
}
else if (vel.linear.x < -0.1) //Backward move
{
digitalWrite(24, HIGH);
digitalWrite(23, LOW);
}
else
{
digitalWrite(24, LOW); //STOP
digitalWrite(23, LOW);
}