Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

How To Run

Patrick Creighton edited this page Feb 4, 2022 · 15 revisions

Run the installation instructions here before running.

Running Local Pathfinding Main Loop + Mock Inputs + Visualizer

The easiest way to run the local pathfinding system with ROS is to use multiple terminals. For each terminal, you will need to run source ~/catkin_ws/devel/setup.bash before running other commands (you can put this in your ~/.bashrc file as well to do this automatically). To run the full pathfinding simulation, you can run: roslaunch local_pathfinding all.launch". This runs:

  • The local pathfinding system, which includes the main_loop, ros_interface, and global_wind nodes. This systems listens to input ROS topics, decides if it needs to recalculate a new local path, and then publishes a desired heading to be used by the downstream controller.

  • The local path visualizer, which uses matplotlib to visualize the boat's position and heading, the local path, the other boats, and the wind speed and direction.

  • The mock inputs, which are a placeholder for the real inputs.

UBC Sailbot Local Pathfinding All Launch Aug 11 2021

Visualizing the simulation

The pathfinding tries to avoid large turns, avoid sailing upwind or downwind, and minimize the path length. It prefers straight line paths if possible, but when the wind does not permit, it will generate paths with tacking maneuvers. The cost function to create these tacking paths was developed from a sailboat reactive planning paper, which can be found here.

The local path visualizer creates a visualization of the system, which is shown below. The red triangle is the autonomous sailboat, the star is the next global waypoint, the light red circle/wedges are other boats, the dark blue circle/wedges are the projected positions of other boats, and the top left arrow shows the direction of the wind. Note that the local path avoid sailing upwind by sailing at a 45 degree angle with respect to the wind and that the local path only avoids the projected positions of other boats, which incentivizes it to sail behind other boats.

Figure_1-1

You can also open OpenCPN to visualize the path finding progression over the entire map. The OpenCPN set up instructions can be found here

opencpn_visualizer

OpenCPN Setup Instructions

These instructions assume that you've already got local_pathfinding set up withing the src directory of a catkin workspace. Also, the catkin_make and source commands have been omitted.

  1. Install OpenCPN

    $ sudo apt install software-properties-common
    $ sudo add-apt-repository ppa:opencpn/opencpn
    $ sudo apt update
    $ sudo apt install opencpn
  2. Configure OpenCPN to listen to UDP port localhost:65500

Press the Options button DeepinSkjermbilde_velg-område_20200125191044

Under connections, add a new UDP connection at 0.0.0.0:65500. Make sure to check Receive Input on this Port.

DeepinSkjermbilde_Navigator_20200125185322

Click OK and close the Options window. You can (but shouldn't have to) confirm that OpenCPN is listening by using netstat from the net-tools package:

$ sudo netstat -lp | grep opencpn
udp        0      0 0.0.0.0:65500           0.0.0.0:*                           14613/opencpn      
  1. Run the mock ROS nodes Run the following commands in (preferably in separate terminals, or use screen or tmux)

    roscore
    rosrun local_pathfinding MOCK_AIS.py
    rosrun local_pathfinding MOCK_controller_and_boat.py
    rosrun local_pathfinding MOCK_UDP_bridge.py
  2. Launch OpenCPN The boats should now be visible in the OpenCPN map. The yellow arrows are AIS units. DeepinSkjermbilde_Navigator_20200126225929

  3. BONUS: Configure OpenCPN to show wind direction and speed Open the Options window again, open the Plugins tab. Enable the Dashboard plugin, and hit Preferences. DeepinSkjermbilde_urxvt_20200126213457

Enable Show this dashboard, and add the True Wind Angle and Speed instrument. Remove the others. Hit OK, and finally hit OK again to close the Options window. DeepinSkjermbilde_urxvt_20200126213601

Arguments for all.launch

All of the arguments below are optional for all.launch. Below is a non-exhaustive list of the arguments.

  • speedup - Float value that changes the speed at which the simulation is run. Default: 1.0

  • global_wind_direction_degrees - Float value that sets the global wind direction.

  • global_wind_speed_kmph - Float value that sets the global wind speed.

  • obstacle_type - String value that changes the obstacle representation of AIS ships. Accepted types are: "ellipse", "wedge","circles", "hybrid_circle", and "hybrid_ellipse". Default: "hybrid_circle"

  • screenshot - Bool value that sets if screenshots should be taken each time createPath is run. Default: false.

  • plot_pathfinding_problem - Bool value that sets if a plot of the pathfinding problem should shown each time createPath is run. Default: false.

  • random_seed - Int value that we set the random seed to. Default: "", which results in the random seed being set by time.

  • wandb - Bool value that sets if data should be logged to wandb for analysis. Need to login with UBC Sailbot credentials to log. Default: false.

Run a specific saved pathfinding scenario

Instructions to run pathfinding unit tests can be found here.

Interacting with the simulator

During a simulation, you can run:

  • rostopic pub /requestLocalPathUpdate then press TAB repeatedly to get a default messsage. Then send it to request a local path change, which will only actually change if the new path is lower cost than the current one.

  • rostopic pub /forceLocalPathUpdate then press TAB repeatedly to get a default messsage. Then send it to force a local path change, which will change the path, regardless if the new path is lower cost than the current one or not.

  • rostopic pub /changeGPS then press TAB repeatedly to get a default message. Edit the message to get sailbot position and speed that you want. This will change the sailbot position.

  • rosparam set /global_wind_direction_degrees 70 to update the global wind direction.

  • rosparam set /global_wind_speed_kmph 5 to update the global wind speed.

  • rosparam set /plot_pathfinding_problem true to start plotting the pathfinding problem at each call to createPath. Can change true to false to turn it off.

  • rosparam set /screenshot true to start screenshotting at each call to createPath. Can change true to false to turn it off.

  • rosparam set /obstacle_type <selected_obstacle_type> (replace <selected_obstacle_type> with the one you want) to change the obstacle representation type. Accepted values are described in the arguments section above.

  • To add or remove AIS boats, you can refer to the instructions here.

Seeing more information about a simulation

You can run rostopic echo / then press TAB repeatedly to see the available topics for listening. One of the most useful is rostopic echo /localPathCostBreakdown to see how the local path cost is being calculated.

Clone this wiki locally