Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp Swarm Control Package #402

Merged
merged 62 commits into from
Jan 30, 2022
Merged

Conversation

hungjn
Copy link
Contributor

@hungjn hungjn commented Nov 12, 2021

  • Change the swarm control package to run a routine which controls a swarm of rovers to level an area on the Moon map.

hungjn and others added 19 commits September 19, 2021 18:10
* Move rover functionality to the rover class.
Use rover class within the main while loop.

* Add test message.

* fixup

* Changed pos to pose

* Added self to dig_sites line 173

Co-authored-by: CoyTorreblanca <coydiego@knights.ucf.edu>
* Add dig command to swarm control constants.

* Add dump command to waypoint client.

* Add auto dig function with waypoint support.

* Add dump command to waypoint server.

* Add dump method to rover class.

Co-authored-by: CoyTorreblanca <coydiego@knights.ucf.edu>
Co-authored-by: Hung <hungjn748@gmail.com>
* Add leveling algorithm

* Added imports for level algo

Co-authored-by: CoyTorreblanca <coydiego@knights.ucf.edu>
Co-authored-by: Hung <hungjn748@gmail.com>
… below a given threshold. (FlaSpaceInst#6)

Co-authored-by: CoyTorreblanca <coydiego@knights.ucf.edu>
* Added pixel_normalize and pixel_expand methods to swarm utils

* Imported pixel normalize to swarm control
…g algorithm output. (FlaSpaceInst#8)

Co-authored-by: CoyTorreblanca <coydiego@knights.ucf.edu>
* Add rover class to control rovers.

    Rover class has instance variables which describe rover properties, including a thread object.
    Rover class has instance methods which perform basic rover functionality, e.g. get_rover_status.
    Add Rover class functionality that pertains to build pad.
    Add Rover object ability to ask Swarm Controller for instructions.
    Add to Rover class the level function which commands rover to dig and dump between two locations.
        Rover object will stop leveling once all instructed actions have been acomplished.
    Rover object threads will spin until it recieves an instruction from the SwarmController.
    Add Rover class go to function which handles getting a rover from its current destination to a target destination.

* Add Swarm Controller functionality to manage rovers.

    Swarm controller assigns rovers dig dump pairs.
    Add data structure to track actions required for each dig and dump pair.
    Add data structures to track which dig and dump locations are assigned to rovers.
    Rovers update global data structure. Rovers use locks to prevent thread race conditions.
    Swarm controller stops when map is level or when all locations left to level are blacklisted.

* Rovers calculate battery requirements.

    Rovers go and charge if they do not have enough battery to complete one assigned action.
    Rovers complete the number of actions that they have enough battery for.
    Rovers will go and charge if they were not able to complete all of the actions required by assignment.
    Rovers will update central data structures when they preempt or finish an assignment.
    Add battery checking after each sub-action in rover level function.
    Add padding to battery checking and battery calculations.
    Front end believes that the rover has 10% less battery to provide a buffer.

* Allow waypoint client to send messages to rover objects.

    Add a ROS subscriber to Rover node which gets messages from waypoint client when an action has been completed.
    The type of action completed is described by the enum Action codes.
    Rovers will wait to continue their routine until the correct integer is published by the waypoint client.


* Waypoint client will preempt pathing more often.

    Lower max veer distance before a new path is calculated in an attempt to
    stop rovers from moving too far away from desired location.


* Handle when rover routine encounters problems.

    Add rover ability to abort assignment when pathing and communicate problem to swarm controller. Swarm controller will handle rover problems.
    Rovers will diagnose problem before raising an exception.
    Create a custom exception for when rover aborts action sequence.
    Swarm controller will understand problem through RoverState enum type
    instance variable in Rover object.
    Swarm controller will blacklist problem locations so that other rovers will avoid them.

* Skip possible instructions which contain a location which have caused a rover problem.

* Crop original height map to represent the desired leveling area.

* Add landing pad auto-functions.

    Add new auto-dig, auto-dump, auto-drive-location which is specialized for the build landing pad swarm.
    Add variable to world state (carrying_dirt) which is set to true after auto-dig-land-pad is called and set to false when auto-dump-land-pad is called.
    Add extra cost to auto-drive-location_land_pad when rover is carrying dirt.
    Auto-dig-land-pad and auto-dump-land-pad turn to the same absolute angle before every execution.
    Add battery cost to auto-dump-land-pad.
    Moved additional functions to the bottom of the auto_functions file.

* Reformat to Black formatting.

* Implement a cleaner and faster leveling algorithm.

    Has the same logic as the original leveling algorithm.

* Lower obstacle buffer in an attempt to make obstacle detection less strict.
* Change dig and dump time to ensure that the rover begins and ends at the same location.

Co-authored-by: hungjn <67024640+hungjn@users.noreply.github.com>
Co-authored-by: CoyTorreblanca <coydiego@knights.ucf.edu>
Co-authored-by: Coy-Torreblanca <78828209+Coy-Torreblanca@users.noreply.github.com>
Co-authored-by: Stanley <staanleyminervini@gmail.com>
Merge branch 'mainline' of github.com:hungjn/EZ-RASSOR into mainline

# Conflicts:
#	packages/autonomy/ezrassor_swarm_control/source/ezrassor_swarm_control/swarm_control.py
Add a log for when the entire area is leveled.
@CSharpRon
Copy link
Collaborator

Great work so far with the PR. Make sure to install and run black on your cloned repository so that you can pass the lint test next time. Also, make sure that "squash and merge" is selected when the PR is final so that only one commit will get added to Mainline.

Before changing changing directions in auto_dump_land_pad and
auto_dig_land_pad, make sure the rover comes to a complete stop to avoid
the rover tipping to drastically.
To reflect that the rover moves while dumping.
@hungjn hungjn marked this pull request as ready for review November 21, 2021 19:16
Copy link
Collaborator

@CSharpRon CSharpRon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic updates since the last review. I added one comment for review but am still approving the PR. Also, there are ALOT of commits in this PR. It's not a problem in itself because that's how development works ofc, but I would like to have this entire PR squashed as one commit when it is merged back into the main branch.

Before checking the box and squashing the PR as a single commit, I recommend looking up how to add co-authors to a squashed commit in GitHub. That way everyone who worked on these changes will get credit (as opposed to just the author of the last commit which I think is the default).

dig_dump_pairs[dig_location].append((dump_location, elevation_change))

# Convert image coordinates to simulation coordinates in a Point object.
def convert_to_simulation_Point(matrix, x, y):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this package fail if the simulation is not running? If so, then logic like this should be abstracted to a sim-specific package so that this swarm control code can be arbitrary enough to run on either hardware or sim.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We convert the rover destination instructions into simulation format because the A* pathing algorithm and the autonomous package require rover destinations to be in simulation format.

What we could do is make the A* planner take regular format destinations and then convert them into simulation coordinates before sending them over to the autonomous package. Should I make an issue? I can make the change in the future.

@Coy-Torreblanca Coy-Torreblanca merged commit 0c5911b into FlaSpaceInst:mainline Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants