Robot Game
v1.0
Research Track part 1 - Assignment
|
A collection of services for the controller. More...
#include "ros/ros.h"
#include "ros/console.h"
#include "geometry_msgs/Point.h"
#include "geometry_msgs/Vector3.h"
#include "geometry_msgs/Twist.h"
#include "robot_game/rg_check_srv.h"
#include "robot_game/rg_get_target_srv.h"
#include "robot_game/rg_get_vel_srv.h"
#include <cmath>
#include <cstdlib>
#include <ctime>
Go to the source code of this file.
Macros | |
#define | TOLERANCE 0.1f |
#define | K (1.f) |
Functions | |
double | compute_eucledian_distance (geometry_msgs::Point P1, geometry_msgs::Point P2) |
Eucledian distance between two points. More... | |
double | rand_range (double min, double max) |
Generate a random value within a given range. More... | |
bool | rg_check_target_callback (robot_game::rg_check_srv::Request &initpos, robot_game::rg_check_srv::Response &r) |
Service - check target. More... | |
bool | rg_get_target_callback (robot_game::rg_get_target_srv::Request &limits, robot_game::rg_get_target_srv::Response &target) |
Service - get a new random target. More... | |
bool | rg_get_velocity_callback (robot_game::rg_get_vel_srv::Request &initpos, robot_game::rg_get_vel_srv::Response &vel) |
Service - generate a twist command. More... | |
int | main (int argc, char **argv) |
Ask for services, topics, and initialise the node. More... | |
A collection of services for the controller.
This file contains the three services the controller needs in order to work:
Definition in file rg_services.cpp.
#define K (1.f) |
the speed at which the robot reaches its position.
Definition at line 38 of file rg_services.cpp.
#define TOLERANCE 0.1f |
minimum distance from the target for considering it reached
Definition at line 35 of file rg_services.cpp.
double compute_eucledian_distance | ( | geometry_msgs::Point | P1, |
geometry_msgs::Point | P2 | ||
) |
Eucledian distance between two points.
P1 | the start point of the vector |
P2 | the final point of the vector |
Definition at line 51 of file rg_services.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Ask for services, topics, and initialise the node.
Definition at line 159 of file rg_services.cpp.
double rand_range | ( | double | min, |
double | max | ||
) |
Generate a random value within a given range.
min | the minimum number (included) |
max | the maximum number (include) |
Definition at line 64 of file rg_services.cpp.
bool rg_check_target_callback | ( | robot_game::rg_check_srv::Request & | initpos, |
robot_game::rg_check_srv::Response & | r | ||
) |
Service - check target.
initpos | X and Xt |
r | is the target reached? |
The function simply takes the distance between actual position and target, and compares this with the TOLERACE. If the distance is less than the TOLERANCE, the target is considered to be reached.
Definition at line 88 of file rg_services.cpp.
bool rg_get_target_callback | ( | robot_game::rg_get_target_srv::Request & | limits, |
robot_game::rg_get_target_srv::Response & | target | ||
) |
Service - get a new random target.
limits | bounds within to take the target |
target | the respose of the server, the target |
Definition at line 104 of file rg_services.cpp.
bool rg_get_velocity_callback | ( | robot_game::rg_get_vel_srv::Request & | initpos, |
robot_game::rg_get_vel_srv::Response & | vel | ||
) |
Service - generate a twist command.
initpos | X and Xt |
vel | the return of the server, the Twist |
Definition at line 131 of file rg_services.cpp.