# Exercise 3.1 - robot doesn't move backwards

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;
}``````

Hello @comm ,

Having a quick look at the `rosbot_class.cpp` file, I can see that in the `move_backwards` function we are actually sending positive linear velocities:

`vel_msg.linear.x = 0.5;`

This velocity should be negative in order to move the robot backward. I will fix this in the source code right now.

Best,

Thanks. I just tried it again and still having the same issue. I thought maybe I needed to re-compile, so I reran catkin_make – still just moves forward. I just looked at rosbot_class.cpp, and for `move_backwards()` it still shows

`vel_msg.linear.x = 0.5;`

Is there something else I should be doing to get the corrected copy?

Thanks,
/K

Hello @comm ,

Try the following command to get the latest changes from the repo:

`git pull origin master`

You need to execute the command from the main folder of the repo.

Best,

That worked - I ran that then re-ran `catkin_make`. Makes sense - I hadn’t thought about the fact that we cloned the code from GitHub initially.

Thanks,
/K