ME 405 Romi
Loading...
Searching...
No Matches
pathing_plan_task.pathing_plan Class Reference

Pathing plan task class for ROMI navigation. More...

Public Member Functions

 __init__ (self, total_dist, automatic_mode, c_state, fwd_ref, piv_ref, yaw, centroid_goal, yaw_goal, bump_on, bump_flg)
 Initialize the pathing_plan_task object.
 wrapper (self, val)
 Wrap a yaw value to the 0-2PI range.
 line_following (self, final_dist, next_state)
 Configure control task for line following and check progress.
 alignment_goal (self, yaw_goal, rot_direction, next_state)
 Configure control task for large pivoting turns.
 alignment_control (self, next_state)
 Configure control task for precise controlled turning.
 free_traverse (self, final_dist, next_state, ref)
 Configure control task for forward motion and check progress.
 run (self)
 Main task generator for cooperative scheduler.

Public Attributes

int state = LINE_FOLLOW_STATE_0
 total_dist = total_dist
 automatic_mode = automatic_mode
 c_state = c_state
 fwd_ref = fwd_ref
 yaw = yaw
int yaw_init = 0
 piv_ref = piv_ref
 centroid_goal = centroid_goal
 yaw_goal = yaw_goal
 bump_on = bump_on
 bump_flg = bump_flg
int bump_off = 0
int iteration = 0
list yaw_goals_5 = [YAWGOAL5, EXPYAWGOAL1, EXPYAWGOAL2, EXPYAWGOAL3]
list direction = [1, 1, -1, 1]
list dist = [CP4_GARAGE, 3600, 3800, 4000]

Detailed Description

Pathing plan task class for ROMI navigation.

This class implements a finite state machine for autonomous navigation of the Pololu ROMI robot through a predefined course with checkpoints and obstacles.

Definition at line 91 of file pathing_plan_task.py.

Constructor & Destructor Documentation

◆ __init__()

pathing_plan_task.pathing_plan.__init__ ( self,
total_dist,
automatic_mode,
c_state,
fwd_ref,
piv_ref,
yaw,
centroid_goal,
yaw_goal,
bump_on,
bump_flg )

Initialize the pathing_plan_task object.

Parameters
total_distFloat share containing total distance traveled by ROMI (set by observer)
automatic_modeInteger share flag to enable automatic line following mode
c_stateInteger share flag holding the expected state of control_task
fwd_refInteger share holding forward reference speed in mm/s
piv_refFloat share holding pivoting reference angular speed in rad/s
yawFloat share containing current yaw from IMU task
centroid_goalFloat share for line following centroid controller set point
yaw_goalFloat share for heading control set point (target angle)
bump_onInteger share flag to turn on bump sensors
bump_flgInteger share flag set by bump task when sensors are triggered

Definition at line 99 of file pathing_plan_task.py.

Member Function Documentation

◆ alignment_control()

pathing_plan_task.pathing_plan.alignment_control ( self,
next_state )

Configure control task for precise controlled turning.

Sets all necessary flags for controlled turning mode to achieve precise yaw alignment. Expected to be used after alignment_goal(). Does not set yaw_goal itself.

Parameters
next_stateState number to transition to when alignment is complete
Returns
True if control_task indicates proper alignment, False otherwise

Definition at line 191 of file pathing_plan_task.py.

Here is the caller graph for this function:

◆ alignment_goal()

pathing_plan_task.pathing_plan.alignment_goal ( self,
yaw_goal,
rot_direction,
next_state )

Configure control task for large pivoting turns.

Sets all necessary flags to put control_task into pivoting mode for making large, inaccurate turns. Transitions to the next state when within 0.5 rad of goal.

Parameters
yaw_goalTarget yaw value to reach
rot_directionDirection to turn (1 for CCW, -1 for CW)
next_stateState number to transition to when goal is reached
Returns
True if ROMI is within tolerance and state is updated, False otherwise

Definition at line 167 of file pathing_plan_task.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_traverse()

pathing_plan_task.pathing_plan.free_traverse ( self,
final_dist,
next_state,
ref )

Configure control task for forward motion and check progress.

Sets all necessary flags to put control_task into forward motion mode and monitors whether ROMI has traveled far enough to transition to the next state.

Parameters
final_distDistance threshold to compare against total distance traveled
next_stateState number to transition to when distance is reached
refReference speed for ROMI to traverse at in mm/s
Returns
True if ROMI has moved far enough and state is updated, False otherwise

Definition at line 207 of file pathing_plan_task.py.

Here is the caller graph for this function:

◆ line_following()

pathing_plan_task.pathing_plan.line_following ( self,
final_dist,
next_state )

Configure control task for line following and check progress.

Sets all necessary flags to put control_task into line following mode and monitors whether ROMI has traveled far enough to transition to the next state.

Parameters
final_distDistance threshold to compare against total distance traveled
next_stateState number to transition to when distance is reached
Returns
True if ROMI has moved far enough and state is updated, False otherwise

Definition at line 149 of file pathing_plan_task.py.

Here is the caller graph for this function:

◆ run()

pathing_plan_task.pathing_plan.run ( self)

Main task generator for cooperative scheduler.

Implements a 34-state finite state machine for autonomous course navigation. Each state executes once in sequence and never returns. The generator yields control after processing each state.

State sequence overview:

States execute in the following order: LINE_FOLLOW_STATE_0, CENTROID_OFFSET_STATE, ALIGNMENT_GOAL_1, ALIGNMENT_CONTROL_1, FORK, ALIGNMENT_GOAL_2, ALIGNMENT_CONTROL_2, FREE_TRAVERSE_1, CP2_PIVOT_1, CP2_PIVOT_2, LINE_FOLLOWING_2, ALIGNMENT_GOAL_3, ALIGNMENT_CONTROL_3, FREE_TRAVERSE_2, LINE_FOLLOW_3, ALIGNMENT_GOAL_4, ALIGNMENT_CONTROL_4, FREE_TRAVERSE_3, LINE_FOLLOW_GRG, ALIGNMENT_GOAL_5, ALIGNMENT_CONTROL_5, FREE_TRAVERSE_4, ALIGNMENT_GOAL_6, ALIGNMENT_CONTROL_6, FREE_TRAVERSE_5, WALL, ALIGNMENT_GOAL_7, ALIGNMENT_CONTROL_7, CUP, ALIGNMENT_GOAL_8, ALIGNMENT_CONTROL_8, FINISH, FINISH_LINE

Path overview: Start line following to the Y, move the centroid to the left to keep right, face CP1, drive directly there, face CP2, drive directly there, line follow briefly, turn to CP3, drive there pushing cup out of the way, turn to CP4, drive there and line follow at the end to align, align at garage entrance, drive through, turn towards wall, drive out, hit wall and backup, turn towards cup, drive over it, turn towards finish, drive back to the line, use line following to get into CP6.

Note
Alignments use two-stage process: goal state for large turns at set speeds, then control state for precise alignment using controller
Yaw drift is inconsistent making the path unreliable - do not run unsupervised
Returns
Yields state number after each iteration

Definition at line 228 of file pathing_plan_task.py.

Here is the call graph for this function:

◆ wrapper()

pathing_plan_task.pathing_plan.wrapper ( self,
val )

Wrap a yaw value to the 0-2PI range.

This method ensures yaw values stay within the valid range used by the IMU, preventing negative values or values exceeding 2π.

Parameters
valThe yaw value to be wrapped
Returns
The wrapped yaw value in the range [0, 2π]

Definition at line 132 of file pathing_plan_task.py.

Here is the caller graph for this function:

Member Data Documentation

◆ automatic_mode

pathing_plan_task.pathing_plan.automatic_mode = automatic_mode

Definition at line 116 of file pathing_plan_task.py.

◆ bump_flg

pathing_plan_task.pathing_plan.bump_flg = bump_flg

Definition at line 125 of file pathing_plan_task.py.

◆ bump_off

int pathing_plan_task.pathing_plan.bump_off = 0

Definition at line 126 of file pathing_plan_task.py.

◆ bump_on

pathing_plan_task.pathing_plan.bump_on = bump_on

Definition at line 124 of file pathing_plan_task.py.

◆ c_state

pathing_plan_task.pathing_plan.c_state = c_state

Definition at line 117 of file pathing_plan_task.py.

◆ centroid_goal

pathing_plan_task.pathing_plan.centroid_goal = centroid_goal

Definition at line 122 of file pathing_plan_task.py.

◆ direction

list pathing_plan_task.pathing_plan.direction = [1, 1, -1, 1]

Definition at line 129 of file pathing_plan_task.py.

◆ dist

list pathing_plan_task.pathing_plan.dist = [CP4_GARAGE, 3600, 3800, 4000]

Definition at line 130 of file pathing_plan_task.py.

◆ fwd_ref

pathing_plan_task.pathing_plan.fwd_ref = fwd_ref

Definition at line 118 of file pathing_plan_task.py.

◆ iteration

int pathing_plan_task.pathing_plan.iteration = 0

Definition at line 127 of file pathing_plan_task.py.

◆ piv_ref

pathing_plan_task.pathing_plan.piv_ref = piv_ref

Definition at line 121 of file pathing_plan_task.py.

◆ state

int pathing_plan_task.pathing_plan.state = LINE_FOLLOW_STATE_0

Definition at line 114 of file pathing_plan_task.py.

◆ total_dist

pathing_plan_task.pathing_plan.total_dist = total_dist

Definition at line 115 of file pathing_plan_task.py.

◆ yaw

pathing_plan_task.pathing_plan.yaw = yaw

Definition at line 119 of file pathing_plan_task.py.

◆ yaw_goal

pathing_plan_task.pathing_plan.yaw_goal = yaw_goal

Definition at line 123 of file pathing_plan_task.py.

◆ yaw_goals_5

list pathing_plan_task.pathing_plan.yaw_goals_5 = [YAWGOAL5, EXPYAWGOAL1, EXPYAWGOAL2, EXPYAWGOAL3]

Definition at line 128 of file pathing_plan_task.py.

◆ yaw_init

pathing_plan_task.pathing_plan.yaw_init = 0

Definition at line 120 of file pathing_plan_task.py.


The documentation for this class was generated from the following file: