Final Assignment  1.0
Research Track part 1 - Assignment 2 - RobEng A.A. 2020/2021
bug0.py File Reference

A finite sate machine for driving a mobile robot towards a target. More...

Go to the source code of this file.

Namespaces

 bug0
 

Functions

def bug0.new_random_target ()
 Get a new randomly-chosen target. More...
 
def bug0.change_state (state)
 Change the state of the node. More...
 
def bug0.normalize_angle (angle)
 Normalize an angle in [-pi, pi]. More...
 
def bug0.srv_bug0_switch (data)
 Turn on or off the node. More...
 
def bug0.srv_bug0_status (empty)
 Get the status of the service. More...
 
def bug0.clbk_odom (msg)
 Get the actual posture. More...
 
def bug0.clbk_laser (msg)
 Get the laser measurements. More...
 
def bug0.main ()
 The main section of the Bug0 algorithm. More...
 
def bug0.cbk_on_shutdown ()
 Called on the shutdown of the node. More...
 

Variables

string bug0.node_name = "bug0"
 name of this node More...
 
string bug0.name_bug0_switch = "/bug0_switch"
 name of the service 'bug0_switch' More...
 
string bug0.name_bug0_status = "/bug0_status"
 name of the service 'bug0_status' More...
 
string bug0.name_get_point = "/get_point"
 name of the service 'get_point' More...
 
 bug0.srv_get_point = None
 call-point of the service 'get_point' More...
 
bool bug0.service_active = False
 Is the service active? More...
 
bool bug0.only_once = False
 Only_once mode (see bug0_switch service) More...
 
 bug0.pub = None
 handler for the topic 'cmd_vel' (Publisher) More...
 
int bug0.yaw_ = 0
 Actual orientation wrt 'z' axis. More...
 
 bug0.position_ = Point()
 actual position More...
 
 bug0.desired_position_ = Point()
 target position More...
 
 bug0.regions_ = None
 Laser regions. More...
 
list bug0.state_desc_ = ['Go to point', 'wall following', 'target reached']
 Status labels. More...
 
int bug0.state_ = 0
 Actual status. More...
 
int bug0.err_pos = -1
 distance from the target More...
 
float bug0.max_tolerance_target = 0.5
 Tolerance on the distance from the target. More...
 
 bug0.srv_client_go_to_point_ = None
 call-point of the service 'go_to_point_switch' More...
 
 bug0.srv_client_wall_follower_ = None
 call-point of the service 'wall_follow_switch' More...
 
 bug0.sub_laser = rospy.Subscriber('/scan', LaserScan, clbk_laser)
 
 bug0.sub_odom = rospy.Subscriber('/odom', Odometry, clbk_odom)
 

Detailed Description

A finite sate machine for driving a mobile robot towards a target.

Authors
Prof. Carmine Recchiuto (first version), Francesco Ganci (S4143910) (Service version)
Version
2.0
Date
2021-06-25

The node implements a simple planning algorithm, an alternative to move_base. It works under the assumptions that a robot has a good odometry (see SLAM_gmapping) and has laser sensors.
Formally speaking, the node is a finite state machine, reacting to the sensor and to the distance from a given target:

  • State 0 : the robot goes straight until it finds a wall
  • State 1 : the robot follows the wall, see wall_follow_service_m.py
  • State 2 : the robot has "reached" the target (i.e. the robot is close enough to the target position)

The node can be turned on and off, exposing a service interface quite similar (architecturally speaking) to the node reach_random_pos_service.py .
Two behaviours are implemented here:

  • ask for a random target, then try and reach it
  • given a target via parameter server, try and reach the target.

When turned off, the service immediately blocks the robot in the actual position.
Note that this node doesn't directly publish the velocity to the simulated environment, rather it uses the nodes wall_follow_service_m.py and go_to_point_service_m.py for the low-level control.

See also
wall_follow_service_m.py the wall follower component
go_to_point_service_m.py the go to point component
reach_random_pos_service.py an alternative service using move_base

Related services:

Definition in file bug0.py.