Welcome to ros_robot_sim_pkg’s documentation!
Indices and tables
Research Track 2 - Assignment 1: Documentation
This is the documentation of the ROS package ‘ros_robot_sim_pkg’.
This package was developed for the Research Track 1 course and documented for the Research Track 2 course.
Below, you will find further descriptions of Nodes (a), (b) and (c) written in Python which were used to simulate a robot in Gazebo environment.
Node (a)
- platform:
Unix
- synopsis:
Action-Client ROS Node for robot simulator
Module author: Ami Sofia Quijano Shimizu
This node implements an action-client, allowing the user to input in the terminal a target (x, y) or to cancel it. It uses the feedback of the action-server to know when the target has been reached. The node also publishes the robot position and velocity as a custom message (x, y, vel_x, vel_z), by relying on the values published on the topic /odom.
Subscribes to:
/odom : Topic which receives the robot’s odometry as messages of type nav_msgs/Odometry, which includes header, child_frame_id, pose (xyz position, xyzw orientation, covariance),
and twist (xyz linear twist, xyz angular twist, covariance)
Publishes to:
/PosVel : Topic which receives the robot’s position (in x and y) and velocity (in x and z) as a custom message of type PosVel.
Action Client of this Action Server:
/reaching_goal
- class scripts.acNode_a.ActionClient[source]
Brief: Class for representing the Action-Client node
- __init__()[source]
- Brief:
Initialization function for the required ROS Action-Alient, Subscriber, Publisher and Message
- Detailed Description:
Creates an action-client for the action-server
/reaching_goalwith action messagePlanningCreates a goal object for the action message
PlanningCreates a subscriber for the topic
/odomCreates a publisher for the topic
/PosVel, where the custom message typePosVelis sent
- feedback_callback(feedback)[source]
- Brief:
Action callback function that displays the feedback sent by the action-server
- Detailed Description:
1. The feedback message of the action
Planningis printed. The feedback message incudes the actual pose (xyz position and xyzw orientation) and the status (which tells if the target has been reached or not)
- Parameters:
feedback – Feedback message of the action
Planning
- get_user_input()[source]
- Brief:
Function that asks the user to input a goal coordinate or to cancel the current goal.
- Detailed Description:
Prompts a message in the terminal asking the user to input ‘X Y’ coordinates or ‘c’ to cancel the goal
If ‘c’ is inputted, the function for cancelling the goal is called
If an ‘X Y’ coordinate is entered, those values are sent to the action-server
In case of invalid inputs, sends an error message and prompts again.
- odom_callback(msg)[source]
- Brief:
Subscriber callback function that publishes the x and y position and the x and z velocity of the robot
- Detailed Description:
Stores the x position, y position, x velocity and z velocity from the
/odomtopic in aPosVeltype messagePublishes these positions and velocities in the topic
/PosVel
- Parameters:
msg – Message from the
/odomtopic
Node (b)
- platform:
Unix
- synopsis:
Service ROS Node for robot simulator
Module author: Ami Sofia Quijano Shimizu
This node implements a service node that, when called, returns the coordinates of the last target sent by the user.
Subscribes to:
/reaching_goal/goal : Topic which receives coordinates of the last target sent
Service:
get_last_target : Service which replies with the x and y coordinates of the last target sent as well as a boolean which indicates if the service request was successful or not.
- class scripts.srvNode_b.GetLastTargetService[source]
- Brief:
Class for representing the GetLastTargetService node
- __init__()[source]
- Brief:
Initialization function for the ROS service, Subscriber and variables as required
- Detailed Description:
Creates a list variable
last_targetto store the last target coordinates sent as [x y]Creates the service
get_last_targetwith service message typeGetLastTargetCreates a subscriber for the topic
/reaching_goal/goal
- handle_get_last_target(req)[source]
- Brief:
Service callback function to handle requests for the last target coordinates
- Detailed Description:
Creates a response object for the service message
GetLastTargetIf at least one target has been sent by user, the x and y coordinates of the last target (obtained from the Subscriber callback function) as well as a successful request confirmation are set as the service response message
If no target has been sent at all, an unsuccessful request confirmation is sent as the service response message
- Parameters:
req – Request message sent to the server
- Returns:
GetLastTargetservice response message- Return type:
GetLastTargetResponse
- target_callback(msg)[source]
- Brief:
Subscriber callback function that updates the last target coordinates when the user enters a new target
- Detailed Description:
Saves the x and y coordinates of the last target in the variable
last_targetby splitting the message received in the/reaching_goal/goaltopic
- Parameters:
msg – Message received in the
/reaching_goal/goaltopic
Node (c)
- platform:
Unix
- synopsis:
Service ROS Node for robot simulator
Module author: Ami Sofia Quijano Shimizu
This node subscribes to the robot’s position and velocity (using the custom message) and implements a service to retrieve the distance of the robot from the target and the robot’s average speed. The size of the averaging window is set as a parameter in the launch file.
Subscribes to:
/PosVel: Topic which receives the robot’s position (in x and y) and velocity (in x and z) as a custom message of type PosVel.
/reaching_goal/goal: Topic which receives information about the last goal sent including header, goal ID, target position and target orientation
Service:
get_dist_speed: Service which replies with the x, y and euclidean distances from the robot to the current target, the average linear speed in x, the average angular speed in and z, a boolean which indicates if the service request was successful for distance calculation and another boolean which indicates if the service request was successful for velocity calculation
- class scripts.srvNode_c.GetDistSpeedService[source]
- Brief:
Class for representing the GetDistSpeedService node
- __init__()[source]
- Brief:
Initialization function for the ROS service, subscriber, and variables as required
- Detailed Description:
Creates a list variable
last_targetto store the last target coordinates sent as [x y]Creates a variable
posvelof the message typePosVelto store the robot’s current xy position and xz velocityCreates the
window_sizevariable which corresponds to the N velocities that will be averaged. It is a parameter from the launch fileCreates the variables
avg_vel_x_queueandavg_vel_z_queueto queue and store the last N velocities in x and zCreates the service
get_dist_speedwith service message typeGetDistSpeedCreates a subscriber for the
/reaching_goal/goaltopicCreates a subscriber for the
/PosVeltopic
- handle_get_dist_speed(req)[source]
- Brief:
Service callback function to handle requests for the robot’s distance from the target and average speed
- Detailed Description:
Creates a response object for the service message
GetDistSpeedIf at least one target has been sent by user, the cartesian x and y distances and euclidean distance from the robot to the target are computed (with values obtained from the previous 2 Subscriber callback functions) and sent as a service response message together with a successful request confirmation for the distance calculation
If no target has been sent at all, an unsuccessful request confirmation for the distance calculation is sent as the service response message
If there are N registered speeds according to the window size, the average of x and z velocities are computed and sent as a service response message together with a successful request confirmation for the average speed calculation
If there are less than N registered speeds according to the window size, an unsuccessful request confirmation for the average speed calculation is sent as a service response message
- Parameters:
req – Request message sent to the server
- Returns:
GetDistSpeedservice response message- Return type:
GetDistSpeedResponse
- posvel_callback(msg)[source]
- Brief:
Subscriber callback function that updates the robot’s current x,y positions and x,z velocities and stores it in the queue the velocities
- Detailed Description:
Saves the current x and y coordinates and the current x and z velocities in the variable
posvelby splitting the message received in the/PosVeltopicAppends in the queue list variables
avg_vel_x_queueandavg_vel_z_queuethe x and z velocities (for average caculation)
- Parameters:
msg – Message received in the
/PosVeltopic
- target_callback(msg)[source]
- Brief:
Subscriber callback function that updates the last target coordinates when the user enters a new target
- Detailed Description:
Saves the x and y coordinates of the last target in the variable
last_targetby splitting the message received in the/reaching_goal/goaltopic
- Parameters:
msg – Message received in the
/reaching_goal/goaltopic