Final Assignment  1.0
Research Track part 1 - Assignment 2 - RobEng A.A. 2020/2021
reach_random_pos_service Namespace Reference

Functions

def update_current_position ()
 Update the informations about the position from check_position service. More...
 
def clear_status ()
 clear the status of the node. More...
 
def new_target_to_move_base ()
 ask a new randomly-choosen target to the server points_manager, then send to MoveBase the target to reach . More...
 
def srv_reach_random_pos_switch (data)
 Turn on and off the service. More...
 
def srv_reach_random_pos_status (data)
 return the status of the service. More...
 
def main ()
 The algorithm of the node. More...
 
def cbk_on_shutdown ()
 This is called on the shutdown of the node. More...
 

Variables

string node_name = "reach_random_pos_service"
 name of this node More...
 
string name_reach_random_pos_status = "/reach_random_pos_status"
 name of the service 'reach_random_pos_status' More...
 
string name_reach_random_pos_switch = "/reach_random_pos_switch"
 name of the service 'reach_random_pos_switch' More...
 
string name_check_position = "/check_position"
 name of the service 'check_position' More...
 
string name_get_point = "/get_point"
 name of the service 'get_point' More...
 
string name_move_base = "/move_base/goal"
 name of the topic 'move_base/goal' (Publisher) More...
 
 topic_move_base = None
 handler topic 'move_base/goal' (Publisher) More...
 
bool service_active = False
 status of the node (bool; default: False) More...
 
bool is_moving = False
 the robot is moving (bool; default: False) More...
 
bool signal_last_pos = False
 last pos signal received (bool; default: False) More...
 
 actual_position = Point( )
 actual position of the robot (geometry_msgs/Point) More...
 
 target_position = None
 the target position (geometry_msgs/Point; default: None) More...
 
 last_response_check_pos = check_positionResponse( )
 response from the service 'check_position' (final_assignment/check_position) More...
 
float min_distance_from_the_target = 0.5
 tolerance on the distance from the target More...
 
 cycle_time = rospy.Duration( 0, 500 )
 time between two cycles More...
 
 srv_check_position = None
 call-point of the service 'check_position' More...
 
 srv_get_point = None
 call-point of the service 'get_point' More...
 

Function Documentation

◆ cbk_on_shutdown()

def reach_random_pos_service.cbk_on_shutdown ( )

This is called on the shutdown of the node.

Definition at line 320 of file reach_random_pos_service.py.

◆ clear_status()

def reach_random_pos_service.clear_status ( )

clear the status of the node.

This is called when the service is turned off. Simple setting of booleans to 'off' state.
(not is_moving), (not signal_last_pos), (not target_pos)

Definition at line 140 of file reach_random_pos_service.py.

◆ main()

def reach_random_pos_service.main ( )

The algorithm of the node.

This 'main' function contains the working algorithm of the node. Its functioning can be summarized as follows:

  • if the robot is moving, check the position ad evaluate the distance. If the distance is under the tolerance, set the is_moving flag to false.
  • If the robot is not moving, but no last_pos_signal is raised, gather a new position and set is_moving true; the cycle begins again.
  • If the robot is not moving and the signal_last_pos is on, turn off the node.

Definition at line 273 of file reach_random_pos_service.py.

◆ new_target_to_move_base()

def reach_random_pos_service.new_target_to_move_base ( )

ask a new randomly-choosen target to the server points_manager, then send to MoveBase the target to reach .

Definition at line 154 of file reach_random_pos_service.py.

◆ srv_reach_random_pos_status()

def reach_random_pos_service.srv_reach_random_pos_status (   data)

return the status of the service.

Definition at line 240 of file reach_random_pos_service.py.

◆ srv_reach_random_pos_switch()

def reach_random_pos_service.srv_reach_random_pos_switch (   data)

Turn on and off the service.

Parameters
data(final_assignment/switch_service) the switch.

The switch has this behaviour:

  • Any 'turn-on' signal when the service is already active will cause the cancellation of any last_pos signal previously raised.
  • If the 'turn-on' signal is received and the service is off, the request always succeeds, and the service is turned on.
  • Any 'turn-off' signal when the node is turned off results in a not-success response
  • The 'turn-off' request isn't immediately executed, because in this implementation move_base is not interruptible. The request is marked as in_progress, and resolved when the robot arrives at its destination.

Definition at line 196 of file reach_random_pos_service.py.

◆ update_current_position()

def reach_random_pos_service.update_current_position ( )

Update the informations about the position from check_position service.

if the robot is_moving, make a common request to /check_position service; else, do nothing.

Definition at line 112 of file reach_random_pos_service.py.

Variable Documentation

◆ actual_position

reach_random_pos_service.actual_position = Point( )

actual position of the robot (geometry_msgs/Point)

Definition at line 85 of file reach_random_pos_service.py.

◆ cycle_time

reach_random_pos_service.cycle_time = rospy.Duration( 0, 500 )

time between two cycles

Definition at line 99 of file reach_random_pos_service.py.

◆ is_moving

bool reach_random_pos_service.is_moving = False

the robot is moving (bool; default: False)

Definition at line 78 of file reach_random_pos_service.py.

◆ last_response_check_pos

reach_random_pos_service.last_response_check_pos = check_positionResponse( )

response from the service 'check_position' (final_assignment/check_position)

Definition at line 92 of file reach_random_pos_service.py.

◆ min_distance_from_the_target

float reach_random_pos_service.min_distance_from_the_target = 0.5

tolerance on the distance from the target

Definition at line 96 of file reach_random_pos_service.py.

◆ name_check_position

string reach_random_pos_service.name_check_position = "/check_position"

name of the service 'check_position'

Definition at line 60 of file reach_random_pos_service.py.

◆ name_get_point

string reach_random_pos_service.name_get_point = "/get_point"

name of the service 'get_point'

Definition at line 64 of file reach_random_pos_service.py.

◆ name_move_base

string reach_random_pos_service.name_move_base = "/move_base/goal"

name of the topic 'move_base/goal' (Publisher)

Definition at line 68 of file reach_random_pos_service.py.

◆ name_reach_random_pos_status

string reach_random_pos_service.name_reach_random_pos_status = "/reach_random_pos_status"

name of the service 'reach_random_pos_status'

Definition at line 52 of file reach_random_pos_service.py.

◆ name_reach_random_pos_switch

string reach_random_pos_service.name_reach_random_pos_switch = "/reach_random_pos_switch"

name of the service 'reach_random_pos_switch'

Definition at line 56 of file reach_random_pos_service.py.

◆ node_name

string reach_random_pos_service.node_name = "reach_random_pos_service"

name of this node

Definition at line 48 of file reach_random_pos_service.py.

◆ service_active

bool reach_random_pos_service.service_active = False

status of the node (bool; default: False)

Definition at line 75 of file reach_random_pos_service.py.

◆ signal_last_pos

bool reach_random_pos_service.signal_last_pos = False

last pos signal received (bool; default: False)

Definition at line 81 of file reach_random_pos_service.py.

◆ srv_check_position

reach_random_pos_service.srv_check_position = None

call-point of the service 'check_position'

Definition at line 176 of file reach_random_pos_service.py.

◆ srv_get_point

reach_random_pos_service.srv_get_point = None

call-point of the service 'get_point'

Definition at line 179 of file reach_random_pos_service.py.

◆ target_position

reach_random_pos_service.target_position = None

the target position (geometry_msgs/Point; default: None)

Definition at line 88 of file reach_random_pos_service.py.

◆ topic_move_base

reach_random_pos_service.topic_move_base = None

handler topic 'move_base/goal' (Publisher)

Definition at line 71 of file reach_random_pos_service.py.