Robot Game  v1.0
Research Track part 1 - Assignment
rg_controller.cpp File Reference

C++ Controller for a smallholonomic mobile robot. More...

#include "ros/ros.h"
#include "ros/console.h"
#include "geometry_msgs/PoseWithCovariance.h"
#include "geometry_msgs/Point.h"
#include "geometry_msgs/Vector3.h"
#include "geometry_msgs/Twist.h"
#include "nav_msgs/Odometry.h"
#include "robot_game/rg_get_target_srv.h"
#include "robot_game/rg_check_srv.h"
#include "robot_game/rg_get_vel_srv.h"

Go to the source code of this file.

Macros

#define XMIN   (-6.f)
 
#define XMAX   (6.f)
 
#define YMIN   (-6.f)
 
#define YMAX   (6.f)
 

Functions

geometry_msgs::Point rg_get_new_target (ros::ServiceClient srv, double xmin, double xmax, double ymin, double ymax)
 require a new target to reach to the server. More...
 
void rg_controller_task (const nav_msgs::Odometry::ConstPtr &posemsg)
 The main function of the controller. More...
 
int main (int argc, char **argv)
 Ask for services, topics, and initialise the node. More...
 

Variables

ros::Subscriber in
 
ros::Publisher out
 
ros::ServiceClient check_tg_srv
 
ros::ServiceClient newtg_srv
 
ros::ServiceClient get_vel_srv
 
geometry_msgs::Point target
 

Detailed Description

C++ Controller for a smallholonomic mobile robot.

Author
Francesco Ganci (S4143910)
Version
1.0
Date
2021-06-25

This node implements a go-to-point behaviour using a very simple approach.
The controller listen to the topic 'base_pose_ground_truth'. When a new update about the posture comes, the controller generates a linear planar twist straight to the point, trying and approching to it.
When the target is "reached" (i.e. the robot is close enough to the target location), a new randomly generated target is required to a dedicated service.

See also
rg_controller_py.py the same controller, implemented in Python.

Definition in file rg_controller.cpp.

Macro Definition Documentation

◆ XMAX

#define XMAX   (6.f)

x max bound

Definition at line 39 of file rg_controller.cpp.

◆ XMIN

#define XMIN   (-6.f)

x min bound

Definition at line 36 of file rg_controller.cpp.

◆ YMAX

#define YMAX   (6.f)

y max bound

Definition at line 45 of file rg_controller.cpp.

◆ YMIN

#define YMIN   (-6.f)

y min bound

Definition at line 42 of file rg_controller.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Ask for services, topics, and initialise the node.

Definition at line 133 of file rg_controller.cpp.

◆ rg_controller_task()

void rg_controller_task ( const nav_msgs::Odometry::ConstPtr &  posemsg)

The main function of the controller.

Parameters
posemsgthe actual posture received by the simulator

This callback is called when a new position comes from the simulated environment via 'base_pose_ground_truth'.
It works in this way:

  1. get the actual pose from the received message
  2. check if the target was reached; if yes, ask for a new target
  3. generate the velocity to give the robot for approaching the goal
  4. publish the new velocity

Definition at line 105 of file rg_controller.cpp.

◆ rg_get_new_target()

geometry_msgs::Point rg_get_new_target ( ros::ServiceClient  srv,
double  xmin,
double  xmax,
double  ymin,
double  ymax 
)

require a new target to reach to the server.

Parameters
srvthe service
xminx min bound
xmaxx max bound
yminy min bound
ymaxy max bound
Returns
geometry_msgs::Point The new target to reach

Definition at line 73 of file rg_controller.cpp.

Variable Documentation

◆ check_tg_srv

ros::ServiceClient check_tg_srv

Definition at line 53 of file rg_controller.cpp.

◆ get_vel_srv

ros::ServiceClient get_vel_srv

Definition at line 55 of file rg_controller.cpp.

◆ in

ros::Subscriber in

subscription to base_pose_ground_truth (nav_msgs/Odometry)

Definition at line 48 of file rg_controller.cpp.

◆ newtg_srv

ros::ServiceClient newtg_srv

Definition at line 54 of file rg_controller.cpp.

◆ out

ros::Publisher out

publisher to cmd_vel (geometry_msgs/Twist)

Definition at line 51 of file rg_controller.cpp.

◆ target

geometry_msgs::Point target

the actual target

Definition at line 58 of file rg_controller.cpp.