Final Assignment
1.0
Research Track part 1 - Assignment 2 - RobEng A.A. 2020/2021
|
Functions | |
def | new_random_target () |
Get a new randomly-chosen target. More... | |
def | change_state (state) |
Change the state of the node. More... | |
def | normalize_angle (angle) |
Normalize an angle in [-pi, pi]. More... | |
def | srv_bug0_switch (data) |
Turn on or off the node. More... | |
def | srv_bug0_status (empty) |
Get the status of the service. More... | |
def | clbk_odom (msg) |
Get the actual posture. More... | |
def | clbk_laser (msg) |
Get the laser measurements. More... | |
def | main () |
The main section of the Bug0 algorithm. More... | |
def | cbk_on_shutdown () |
Called on the shutdown of the node. More... | |
Variables | |
string | node_name = "bug0" |
name of this node More... | |
string | name_bug0_switch = "/bug0_switch" |
name of the service 'bug0_switch' More... | |
string | name_bug0_status = "/bug0_status" |
name of the service 'bug0_status' More... | |
string | name_get_point = "/get_point" |
name of the service 'get_point' More... | |
srv_get_point = None | |
call-point of the service 'get_point' More... | |
bool | service_active = False |
Is the service active? More... | |
bool | only_once = False |
Only_once mode (see bug0_switch service) More... | |
pub = None | |
handler for the topic 'cmd_vel' (Publisher) More... | |
int | yaw_ = 0 |
Actual orientation wrt 'z' axis. More... | |
position_ = Point() | |
actual position More... | |
desired_position_ = Point() | |
target position More... | |
regions_ = None | |
Laser regions. More... | |
list | state_desc_ = ['Go to point', 'wall following', 'target reached'] |
Status labels. More... | |
int | state_ = 0 |
Actual status. More... | |
int | err_pos = -1 |
distance from the target More... | |
float | max_tolerance_target = 0.5 |
Tolerance on the distance from the target. More... | |
srv_client_go_to_point_ = None | |
call-point of the service 'go_to_point_switch' More... | |
srv_client_wall_follower_ = None | |
call-point of the service 'wall_follow_switch' More... | |
sub_laser = rospy.Subscriber('/scan', LaserScan, clbk_laser) | |
sub_odom = rospy.Subscriber('/odom', Odometry, clbk_odom) | |
def bug0.cbk_on_shutdown | ( | ) |
def bug0.change_state | ( | state | ) |
Change the state of the node.
state | (Int) the next state. |
The function changes the state of the robot from the actual one to the one passed as argument.
def bug0.clbk_laser | ( | msg | ) |
def bug0.clbk_odom | ( | msg | ) |
def bug0.main | ( | ) |
The main section of the Bug0 algorithm.
The state machine works in this way:
def bug0.new_random_target | ( | ) |
Get a new randomly-chosen target.
The only purpose of this function is requiring a new target from the /get_point server, and storing it into the parameter server. See /get_point .
def bug0.normalize_angle | ( | angle | ) |
def bug0.srv_bug0_status | ( | empty | ) |
Get the status of the service.
empty | (final_assignment/bug0_status) empty request |
The function simply sends a message containing the most significant informations from the data section.
See /bug0_status .
def bug0.srv_bug0_switch | ( | data | ) |
Turn on or off the node.
data | (final_assignment/switch_serviceRequest) The request |
Here is how this switch works:
float bug0.max_tolerance_target = 0.5 |
string bug0.name_bug0_status = "/bug0_status" |
string bug0.name_bug0_switch = "/bug0_switch" |
string bug0.name_get_point = "/get_point" |
bool bug0.only_once = False |
Only_once mode (see bug0_switch service)
bug0.srv_client_go_to_point_ = None |
bug0.srv_client_wall_follower_ = None |
bug0.srv_get_point = None |
int bug0.state_ = 0 |
list bug0.state_desc_ = ['Go to point', 'wall following', 'target reached'] |
bug0.sub_laser = rospy.Subscriber('/scan', LaserScan, clbk_laser) |
bug0.sub_odom = rospy.Subscriber('/odom', Odometry, clbk_odom) |