Hi, i am familiar with using Python inROS and was learning to do this in C++, using the course C++ For Robotics. I have a couple of queries regarding the course.
Question 1:
Under Unit 1, unit1_exercise.cpp
#include "rosbot_control/rosbot_class.h"
#include <ros/ros.h>
- What is the difference between " " and <> based on usage above? from my understanding the syntax is
#include <Package_name/header_file.h>
, so why are we using " " ?
Question 2:
Under Unit 1, unit1_exercise.cpp
int main(int argc, char **argv) {
ros::init(argc, argv, "rosbot_node");
-
What is **argv? is it a pointer? In the course content we talk about using pointers that use a single * to get the value at an address, but there is no mention of ** in the content? Can i know what this is intended to do?
-
I understand from the content that pointers are used in functions to avoid data duplication (like say when passing array into a function) and to make things faster. Can i know how this problem is addressed in python since i have rarely used pointer when working on ROS with python?
Question 3:
Under Unit 1, unit1_exercise.cpp
#include "rosbot_control/rosbot_class.h"
#include <ros/ros.h>
int main(int argc, char **argv) {
ros::init(argc, argv, "rosbot_node");
RosbotClass rosbot;
rosbot.move();
When working with Python files, in order to use a class, I had to specifically import the class as
from python_file_name import Class_written_in_python_file
or i had to import the entire module and use dot operator as below :
import python_module
python_module.Class_written_in_python_file
Question
When we write the line #include "rosbot_control/rosbot_class.h"
, is all its contents readily available to use directly?
We have used RosbotClass rosbot;
directly without any dot operator or anything. Also in ROS_INFO_STREAM(x_2 << " and " << y_2);
, we are able to use the function ROS_INFO_STREAM directly.
At the same time, we are using scope operator in ros::init
to access it. Why the two different approaches?
Question 4:
class Hobbit {
public:
Hobbit(string a,float b,int c) {
name = a;
height = b;
age = c;
} //constructor
string name;
float height; //in meters
int age;
When creating a constructor, why are the data types (string name; float height; //in meters int age;
), mentioned after the constructor is defined? Since the constructor is compiled first, how will the program know the datatype of say “name” when its called before its defined.
Question 5:
- What the difference between scope operator and namespace? since cout can be used using namespace std as well as std:: cout.
Question 6:
In Unit 5, rosbot_class.h,
#ifndef ROSBOT_CLASS_H
#define ROSBOT_CLASS_H
#include "geometry_msgs/Twist.h"
#include "nav_msgs/Odometry.h"
#include "sensor_msgs/LaserScan.h"
#include <list>
#include <ros/ros.h>
#include <string>
What do the first two lines mean?
I am new to C++ and these clarification would really help. thanks in advance.