I haven’t tried the answer code yet but I can’t seem to get this to work! Where is my error?
#include "rosbot_control/rosbot_class.h"
#include <ros/ros.h>
#include <iostream>
#include <list>
#include <map>
#include <string>
using namespace std;
list<float> move_and_inform(Rosbot Class rosbot, int n_secs) {
rosbot.move_forward(n_secs);
float x = rosbot.get_position(1);
float y = rosbot.get_position(2);
list<float> list_coordinates({x, y});
return list_coordinates;
}
int main(int argc, char **argv) {
ros::init(argc, argv, "rosbot_node");
Rosbotclass rosbot;
int n_secs;
cout << "Enter the number of seconds that you want the robot to move: "
<< endl;
cin << int n_secs;
list<float> list_coordinates = move_and_inform(rosbot, n_secs);
for (float number : list_coordinates) {
cout << number << ", ";
}
return 0;
}
- List item