# (C++ course) Exercise 4.1 - extremely small values for coordinates

I ran exercise 4.1. The program seemed to run fine, but the values for the X coordinate seemed extremely small. Y was 0, which makes sense because we only move in the X-axis. But after 5 seconds (at which point I ran into the counter) the X was only “2.8026e-45”. I used other values for how many seconds, and got similar results. I compared my code to the example - they’re equivalent.

So is this right - it’s just a scale issue?
/K

In exercise 4.2 I’m having the opposite issue - the X and Y values seem way too large. I’m also getting the exact same x and y value each time I check the coordinates. My code is below - you’ll see that initially I tried calling a function to print the coordinates, but when that game me the same values at every point, I thought it might be something to do with how I was passing the rosbot object. So I just checked in the same function after each turn (or going straight). Even with this I get the same values at each point. And they’re huge (X, Y coordinates: 6.7406e+22, 565990).

In the simulation it looks fine and moves as expected.

Code is below. Am I calling the `get_position` function wrong somehow?

Thanks,
/K

``````#include "rosbot_control/rosbot_class.h"
#include <ros/ros.h>
#include <list>
using namespace std;

// void print_position (RosbotClass rosbot){
//     float x_coord = rosbot.get_position(1);
//     float y_coord = rosbot.get_position(2);
//     cout << "X, Y coordinates: ";
//     cout << x_coord << ", " << y_coord << endl;
// }

string move_and_inform(RosbotClass rosbot){
// somewhat brute-force-ish, but just for demo purposes
rosbot.turn("clockwise", 3);
// print_position(rosbot);
float x_coord = rosbot.get_position(1);
float y_coord = rosbot.get_position(2);
cout << "X, Y coordinates: ";
cout << x_coord << ", " << y_coord << endl;

rosbot.move_forward(2);
// print_position(rosbot);
x_coord = rosbot.get_position(1);
y_coord = rosbot.get_position(2);
cout << "X, Y coordinates: ";
cout << x_coord << ", " << y_coord << endl;

rosbot.turn("counterclockwise", 3);
// print_position(rosbot);
x_coord = rosbot.get_position(1);
y_coord = rosbot.get_position(2);
cout << "X, Y coordinates: ";
cout << x_coord << ", " << y_coord << endl;

rosbot.move_forward(2);
// print_position(rosbot);
x_coord = rosbot.get_position(1);
y_coord = rosbot.get_position(2);
cout << "X, Y coordinates: ";
cout << x_coord << ", " << y_coord << endl;

string message = "I'm free";
return message;
}

int main(int argc, char **argv) {
ros::init(argc, argv, "rosbot_node");

RosbotClass rosbot;

string results = move_and_inform(rosbot);
cout << results << endl;

return 0;
}``````