My code seems to run fine, and I get [INFO] messages stating the robot is moving backwards. But in the Gazebo window the robot still moves forward, not backwards. My code below.
Any suggestions?
Thanks,
/K
#include "rosbot_control/rosbot_class.h"
#include <iostream>
#include <list>
#include <map>
#include <ros/ros.h>
#include <string>
using namespace std;
int main(int argc, char **argv) {
ros::init(argc, argv, "rosbot_node");
RosbotClass rosbot;
float X_limit = 1.0; // meters
float coordinate_x = rosbot.get_position(1);
double time = rosbot.get_time();
printf("At time %f the x postion was: %f \n", time, coordinate_x);
int travel_time;
cout << "How many seconds to move? ";
cin >> travel_time;
rosbot.move_forward(travel_time);
coordinate_x = rosbot.get_position(1);
time = rosbot.get_time();
printf("At time %f the x postion was: %f \n", time, coordinate_x);
if (coordinate_x > X_limit){
printf("Past the X_limit, need to stop.!\n");
rosbot.stop_moving();
} else {
printf("Not past the X_limit. Backing up!\n");
rosbot.stop_moving();
rosbot.move_backwards(travel_time);
rosbot.stop_moving();
}
return 0;
}