Get_position() function is not changing the coordinates

hi! I noticed something strange about exercise 3.1. Pasting code below:

#include “rosbot_control/rosbot_class.h”



#include <ros/ros.h>

std::list move_and_inform(RosbotClass rosbot, int n_secs) {

float why = rosbot.get_position(1);

std::cout << why << “________” << std::endl; // MAIN PROBLEM: why and newx have the same value even though the robot moved


float newx = rosbot.get_position(1);

std::cout << newx << “________” << std::endl;

float newy = rosbot.get_position(2);

std::cout << newy << “________” << std::endl;

std::list newcoordinates({newx, newy});

return newcoordinates;


int main(int argc, char **argv) {

ros::init(argc, argv, “rosbot_node”);

RosbotClass rosbot;

float x = rosbot.get_position(1); // to see the inital coordinates

float y = rosbot.get_position(2);

ROS_INFO_STREAM(“old coordinates:” << x << ", " << y);
std::list results = move_and_inform(rosbot, 2.0);

for (float result : results) {

std::cout << result << " ,";

std::cout << std::endl
return 0;

The problem is explained in the comments, you can clearly see that get_position() does not give different positions even though the robot moved. So far, all the rosbot commands were working fine and now I cannot get the initial and final position.

I would like to know whether there is a problem with my code or the code of get_position()??

Thanks for the help!