|
Research Track 2
1.0
ROS file documentation assignment
|
Robotics control in a simulated environment. More...
#include <iostream>#include <string>#include <chrono>#include <ctime>#include "ros/ros.h"#include "geometry_msgs/Twist.h"#include "sensor_msgs/LaserScan.h"#include "actionlib_msgs/GoalID.h"#include "move_base_msgs/MoveBaseActionGoal.h"#include "move_base_msgs/MoveBaseActionFeedback.h"
Macros | |
| #define | DIST 0.35 |
| Minimum distance from the wall with the driving assistance enabled. | |
| #define | POS_ERROR 0.5 |
| Position range error. | |
| #define | MAX_TIME 120000000 |
| Maximum time to reach a goal (microseconds) | |
Functions | |
| void | drivingAssistance (const sensor_msgs::LaserScan::ConstPtr &msg) |
| Checks data from robot's laser scanner and, if the driving assistance is enabled, help the user not to crush the robot against a wall. More... | |
| void | currentStatus (const move_base_msgs::MoveBaseActionFeedback::ConstPtr &msg) |
| Checks if the robot is on the goal position and, when there is a new goal, update the current Goal ID and save it in a global variable. More... | |
| void | currentGoal (const move_base_msgs::MoveBaseActionGoal::ConstPtr &msg) |
| Checks the current goal position and saves its coordinates x and y in two global variables. More... | |
| int | main (int argc, char **argv) |
| Initializes the node and starts the logic of the robot. More... | |
Variables | |
| ros::Publisher | pub_canc |
| Publishes to /move_base/cancel. | |
| ros::Publisher | pub_vel |
| Publishes to /cmd_vel. | |
| float | x_goal |
| Current goal coordinate x. | |
| float | y_goal |
| Current goal coordinate y. | |
| int | reached_goal = 0 |
| Number of reached goals. | |
| int | non_reached_goal = 0 |
| Number of not reached goals. | |
| std::string | id = "" |
| Goal ID. | |
| std::chrono::high_resolution_clock::time_point | t_start |
| Starting time goal reaching. | |
| std::chrono::high_resolution_clock::time_point | t_end |
| Ending time goal reaching. | |
Robotics control in a simulated environment.
Server parameters:
| key_flag | defines the type of keyboard input inserted by the user (output). |
| drive_flag | defines if the manual driving assistance is enabled or not (output). |
| goal_flag | defines if a goal is set or not (input & output). |
| print_flag | defines if the warning sentence, about a wall too close to the robot, has been printed or not (input & output). |
Publishers to:
/move_base/cancel
/cmd_vel
Subscribers to:
/move_base/feedback
/move_base/goal
/scan
Description:
This node simulates the 'logic' of the robot.
Managing publishers, subscribers and server parameters it is able to avoid the crashing of the robot against a wall, if asked by the user, and register how many targets it reached and how many not.
A target is considered 'not reached' when the robot does not reach it within 2 minutes, then the goal is cancelled.
| void currentGoal | ( | const move_base_msgs::MoveBaseActionGoal::ConstPtr & | msg | ) |
Checks the current goal position and saves its coordinates x and y in two global variables.
| msg | defines the goal position values. |
| void currentStatus | ( | const move_base_msgs::MoveBaseActionFeedback::ConstPtr & | msg | ) |
Checks if the robot is on the goal position and, when there is a new goal, update the current Goal ID and save it in a global variable.
| msg | defines the robot position values. |
| void drivingAssistance | ( | const sensor_msgs::LaserScan::ConstPtr & | msg | ) |
Checks data from robot's laser scanner and, if the driving assistance is enabled, help the user not to crush the robot against a wall.
| msg | defines the laser scanner values. |
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Initializes the node and starts the logic of the robot.
| argc | |
| argv |
Subscriber on /move_base/feedback
Subscriber on /move_base/goal
Subscriber on /scan
1.8.17