diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..22c8236 --- /dev/null +++ b/COPYING @@ -0,0 +1,1555 @@ +~~~~~~~~~~~~~~ +Copying IvPico +~~~~~~~~~~~~~~ + +IvPico is copyright as listed in the individual source files. + +Distribution of libraries (src/lib) is allowed under the terms of the +GNU Lesser General Public License, version 2.1 or (at your option) any later +version, and distribution of binaries and tests (src/bin, src/test) under the +terms of the GNU General Public License, version 2 or (at your option) any +later version. + +Exceptions: + + - src/lib/helm/helm.cpp and src/lib/helm/contact_manager.{h,cpp} port logic + from MOOS-IvP's pHelmIvP and pContactMgrV20, and are distributed under the + GNU General Public License, version 3 or (at your option) any later + version. + - src/lib/helm/contacts holds files copied unchanged from MOOS-IvP's + pContactMgrV20, under MOOS-IvP's license (GNU General Public License, + version 3 or later). + - The mission files in src/test/missions/fixtures and + launch/goby/alpha/config/alpha.bhv come from MOOS-IvP's missions, under + MOOS-IvP's license (GNU General Public License, version 3 or later). + +IvPico links MOOS-IvP's helm libraries, which are distributed under the +GNU General Public License, version 3 or later, so libivpico_helm and the +binaries that use it are, as built, distributed under the GNU General Public +License, version 3. + +The text of the relevant licenses follows: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + diff --git a/README.md b/README.md index 3e8d15f..625ce35 100644 --- a/README.md +++ b/README.md @@ -44,5 +44,11 @@ ctest --test-dir build `goby_helm_ivp` runs the helm in Goby3. It publishes and subscribes the `ivp.interface` messages on the `ivpico::helm::*` groups (`src/bin/goby/groups.h`), and can stand in for the MOOS helm behind `goby_frontseat_interface` (`frontseat { enable: true }`). `goby_helm_ivp -e` prints an example configuration. +Contacts come in as `Navigation` with `self: false`, or as `NODE_REPORT` variables. The helm raises pContactMgrV20's alerts itself (configured in `helm.contact_manager`), so contact behaviors such as collision avoidance spawn without a separate contact manager. + `launch/goby/alpha` runs the alpha mission against Goby's basic frontseat simulator, with OpenCPN as a chart display: see its [README](launch/goby/alpha/README.md). + +## License + +The libraries (`src/lib`) are LGPL 2.1 or later, and the binaries and tests (`src/bin`, `src/test`) are GPL 2 or later. The helm's ports of pHelmIvP and pContactMgrV20 (`src/lib/helm/helm.cpp`, `contact_manager.{h,cpp}` and `contacts/`) are GPL 3 or later, as is MOOS-IvP, whose helm libraries IvPico links. See [COPYING](COPYING). diff --git a/src/bin/goby/groups.h b/src/bin/goby/groups.h index 4aae45a..1c15a0f 100644 --- a/src/bin/goby/groups.h +++ b/src/bin/goby/groups.h @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + #ifndef IVPICO_GOBY_GROUPS_H #define IVPICO_GOBY_GROUPS_H diff --git a/src/bin/goby/helm_ivp/helm_ivp.cpp b/src/bin/goby/helm_ivp/helm_ivp.cpp index 0b7a35c..35483c8 100644 --- a/src/bin/goby/helm_ivp/helm_ivp.cpp +++ b/src/bin/goby/helm_ivp/helm_ivp.cpp @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + #include #include diff --git a/src/bin/goby/helm_ivp/helm_ivp_config.proto b/src/bin/goby/helm_ivp/helm_ivp_config.proto index 0754f7d..d0aeb5e 100644 --- a/src/bin/goby/helm_ivp/helm_ivp_config.proto +++ b/src/bin/goby/helm_ivp/helm_ivp_config.proto @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + syntax = "proto2"; import "goby/protobuf/option_extensions.proto"; diff --git a/src/bin/goby/moos_gateway/moos_gateway.cpp b/src/bin/goby/moos_gateway/moos_gateway.cpp index c28d507..c578c3f 100644 --- a/src/bin/goby/moos_gateway/moos_gateway.cpp +++ b/src/bin/goby/moos_gateway/moos_gateway.cpp @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + // goby_moos_gateway plugin that gives a MOOS community what pHelmIvP and its // navigation would post (NAV_*, the helm's postings, IVPHELM_*), so MOOS-IvP // tools such as pNodeReporter and pMarineViewer work with goby_helm_ivp. diff --git a/src/bin/goby/moos_gateway/moos_gateway_config.proto b/src/bin/goby/moos_gateway/moos_gateway_config.proto index 81ee3f2..1b5c0e6 100644 --- a/src/bin/goby/moos_gateway/moos_gateway_config.proto +++ b/src/bin/goby/moos_gateway/moos_gateway_config.proto @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + syntax = "proto2"; import "goby/moos/protobuf/moos_gateway_config.proto"; diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index c16ed7a..10ad4df 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -8,12 +8,13 @@ protobuf_generate( target_include_directories(ivpico_interface PUBLIC $) target_link_libraries(ivpico_interface PUBLIC openocean_messages::openocean_messages) -add_library(ivpico_helm helm/helm.cpp helm/conversions.cpp helm/status_strings.cpp) +add_library(ivpico_helm helm/helm.cpp helm/conversions.cpp helm/status_strings.cpp + helm/contact_manager.cpp helm/contacts/CMAlert.cpp helm/contacts/PlatformAlertRecord.cpp) target_include_directories(ivpico_helm PUBLIC $) target_link_libraries(ivpico_helm PUBLIC ivpico_interface PRIVATE IVP::helmivp IVP::geodaid IVP::behaviors IVP::contacts IVP::logic IVP::ivpbuild - IVP::ivpsolve IVP::ivpcore IVP::mbutil) + IVP::ivpsolve IVP::ivpcore IVP::geometry IVP::mbutil) install(TARGETS ivpico_interface ivpico_helm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/src/lib/helm/contact_manager.cpp b/src/lib/helm/contact_manager.cpp new file mode 100644 index 0000000..dcd028b --- /dev/null +++ b/src/lib/helm/contact_manager.cpp @@ -0,0 +1,605 @@ +// Copyright 2026: +// GobySoft, LLC +// Ports logic from MOOS-IvP's pContactMgrV20 (ContactMgrV20.cpp), by Michael +// Benjamin, Dept of Mechanical Engineering, MIT. +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 3 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + +#include "contact_manager.h" + +#include +#include + +#include "CPAEngine.h" +#include "LinearExtrapolator.h" +#include "MBUtils.h" +#include "MacroUtils.h" +#include "NodeRecordUtils.h" +#include "VarDataPairUtils.h" + +namespace ivpico +{ +namespace helm +{ +ContactManager::ContactManager(const ivp::interface::HelmConfig::ContactManager& cfg, + const std::string& ownship, + std::vector& config_warnings) + : ownship_(ownship) +{ + auto warn_unless = [&](bool ok, const std::string& what) + { + if (!ok) + config_warnings.push_back("Bad contact_manager " + what); + }; + + filter_set_.addIgnoreName(ownship_); + for (const auto& v : cfg.ignore_name()) + warn_unless(filter_set_.addIgnoreName(v), "ignore_name: " + v); + for (const auto& v : cfg.match_name()) + warn_unless(filter_set_.addMatchName(v), "match_name: " + v); + for (const auto& v : cfg.ignore_group()) + warn_unless(filter_set_.addIgnoreGroup(v), "ignore_group: " + v); + for (const auto& v : cfg.match_group()) + warn_unless(filter_set_.addMatchGroup(v), "match_group: " + v); + for (const auto& v : cfg.ignore_type()) + warn_unless(filter_set_.addIgnoreType(v), "ignore_type: " + v); + for (const auto& v : cfg.match_type()) + warn_unless(filter_set_.addMatchType(v), "match_type: " + v); + for (const auto& v : cfg.ignore_region()) + warn_unless(filter_set_.addIgnoreRegion(v), "ignore_region: " + v); + for (const auto& v : cfg.match_region()) + warn_unless(filter_set_.addMatchRegion(v), "match_region: " + v); + filter_set_.setStrictIgnore(cfg.strict_ignore()); + if (!cfg.ownship_group().empty()) + filter_set_.setOwnshipGroup(cfg.ownship_group()); + if (!cfg.ownship_type().empty()) + filter_set_.setOwnshipType(cfg.ownship_type()); + + if (cfg.has_contact_max_age()) + { + warn_unless(cfg.contact_max_age() > 0, "contact_max_age"); + if (cfg.contact_max_age() > 0) + contact_max_age_ = cfg.contact_max_age(); + } + if (cfg.has_reject_range()) + reject_range_ = cfg.reject_range() > 0 ? cfg.reject_range() : -1; + if (cfg.has_max_contacts()) + max_contacts_ = cfg.max_contacts(); + if (cfg.has_decay_start() || cfg.has_decay_end()) + { + const double start = cfg.has_decay_start() ? cfg.decay_start() : decay_start_; + const double end = cfg.has_decay_end() ? cfg.decay_end() : decay_end_; + warn_unless(start >= 0 && start <= end, "decay"); + if (start >= 0 && start <= end) + decay_start_ = start, decay_end_ = end; + } + hold_alerts_for_helm_ = cfg.hold_alerts_for_helm(); + alert_verbose_ = cfg.alert_verbose(); + + disable_var_ = cfg.disable_var(); + enable_var_ = cfg.enable_var(); + expunge_var_ = cfg.expunge_var(); + auto add_flags = [&](std::vector& flags, const auto& specs, const char* what) + { + for (const auto& spec : specs) + warn_unless(addVarDataPairOnString(flags, spec), what + (": " + spec)); + }; + add_flags(able_flags_, cfg.able_flag(), "able_flag"); + add_flags(disable_flags_, cfg.disable_flag(), "disable_flag"); + add_flags(enable_flags_, cfg.enable_flag(), "enable_flag"); + early_warning_time_ = cfg.early_warning_time() > 0 ? cfg.early_warning_time() : -1; + add_flags(early_warning_flags_, cfg.early_warning_flag(), "early_warning_flag"); + add_flags(cease_warning_flags_, cfg.cease_warning_flag(), "cease_warning_flag"); + add_flags(retire_flags_, cfg.retire_flag(), "retire_flag"); + + // an alert may be incomplete until a behavior's request completes it + for (const auto& alert : cfg.alert()) + warn_unless(handle_alert(alert, "general"), "alert: " + alert); + + // retirement here does the culling + ledger_.setMaxContacts(0); +} + +bool ContactManager::handle_mail(const std::string& var, const std::string& value, + const std::string& source) +{ + if (var == "NODE_REPORT") + handle_node_record(string2NodeRecord(value)); + else if (var == "BCM_ALERT_REQUEST") + handle_alert(value, source); + else if (!disable_var_.empty() && var == disable_var_) + handle_mod_enable_contact(value, "disable"); + else if (!enable_var_.empty() && var == enable_var_) + handle_mod_enable_contact(value, "enable"); + else if (!expunge_var_.empty() && var == expunge_var_) + handle_mod_enable_contact(value, "expunge"); + else + return false; + return true; +} + +void ContactManager::handle_node_record(const NodeRecord& record) +{ + const std::string vname = record.getName(); + if (vname.empty() || tolower(vname) == tolower(ownship_)) + return; + + // a contact that fails the filter now is retired on the next iteration, + // even if it passed before (e.g. it left a match region) + if (!filter_set_.filterCheck(record, osx_, osy_)) + { + filtered_vnames_.insert(vname); + return; + } + + const bool known = ledger_.hasVName(vname); + std::string whynot; + if (ledger_.processNodeRecord(record, whynot) != vname) + return; + + if (!known) + { + ranges_actual_[vname] = 0; + ranges_extrap_[vname] = 0; + cpa_[vname] = 0; + roc_[vname] = 0; + par_.addVehicle(vname); + if (alert_verbose_) + notify("ALERT_VERBOSE", "new_contact=" + vname); + } + contacts_retired_.remove(vname); +} + +void ContactManager::set_ownship(double x, double y, double heading, double speed) +{ + osx_ = x; + osy_ = y; + osh_ = heading; + osv_ = speed; +} + +std::vector ContactManager::iterate(double time, bool helm_in_drive) +{ + curr_time_ = time; + if (helm_in_drive) + helm_in_drive_noted_ = true; + + ledger_.setCurrTimeUTC(time); + ledger_.extrapolate(); + update_ranges(); + check_for_early_warnings(); + check_for_cease_warnings(); + if (!hold_alerts_for_helm_ || helm_in_drive_noted_) + check_for_alerts(); + check_for_new_retired_contacts(); + + return std::move(posts_); +} + +bool ContactManager::handle_alert(const std::string& alert_str, const std::string& source) +{ + std::string alert_id = tokStringParse(alert_str, "id", ',', '='); + if (alert_id.empty()) + alert_id = "no_id"; + + if (strContains(tolower(alert_str), "action=disable")) + { + if (alert_id != "no_id") + alerts_disabled_.insert(alert_id); + return true; + } + if (strContains(tolower(alert_str), "action=enable")) + { + if (alert_id != "no_id") + alerts_disabled_.erase(alert_id); + return true; + } + + par_.addAlertID(alert_id); + CMAlert& alert = alerts_[alert_id]; + if (!source.empty()) + alert.setAlertSource(source); + + std::string var, pattern; + for (std::string component : parseStringQ(alert_str, ',')) + { + const std::string left = tolower(biteStringX(component, '=')); + std::string right = component; + const double dval = atof(right.c_str()); + if (isQuoted(right)) + right = stripQuotes(right); + + bool ok = true; + if (left == "id") + continue; + else if (left == "var") + var = right; + else if (left == "val" || left == "pattern") + pattern = right; + else if (left == "on_flag" || left == "onflag") + ok = alert.addAlertOnFlag(right); + else if (left == "off_flag" || left == "offflag") + ok = alert.addAlertOffFlag(right); + else if (left == "alert_range" && isNumber(right)) + ok = alert.setAlertRange(dval); + else if (left == "cpa_range" && isNumber(right)) + ok = alert.setAlertRangeFar(dval); + else if (left == "match_name" || left == "ignore_name" || left == "match_group" || + left == "ignore_group" || left == "match_type" || left == "ignore_type" || + left == "match_region" || left == "ignore_region" || left == "strict_ignore") + ok = alert.configFilter(left, right); + else + ok = false; + + if (!ok) + return false; + } + + // the older form, with separate var and val + if (!var.empty() && !pattern.empty()) + alert.addAlertOnFlag(var + "=" + pattern); + return true; +} + +void ContactManager::handle_mod_enable_contact(const std::string& str, const std::string& action) +{ + std::string contact_id, msg; + if (!strContains(str, "=") && !strContains(str, ",")) + msg = "contact=" + str; + else + { + contact_id = tokStringParse(str, "contact"); + if (!contact_id.empty()) + msg = "contact=" + contact_id; + else + { + const std::string vsource = tokStringParse(str, "vsource"); + if (!vsource.empty()) + msg = "vsource=" + vsource; + } + } + if (msg.empty()) + return; + + notify("BHV_ABLE_FILTER", msg + ",action=" + action); + + if (contact_id.empty()) + return; + if (action == "enable") + { + post_flags(able_flags_); + post_flags(enable_flags_); + } + else if (action == "disable") + { + post_flags(able_flags_); + post_flags(disable_flags_); + } +} + +void ContactManager::update_ranges() +{ + // ten hours, so CPA is the closest the two tracks ever get + const double cpa_time = 36000; + + for (const auto& contact : ledger_.getVNames()) + { + double cnx = ledger_.getX(contact); + double cny = ledger_.getY(contact); + const double cnh = ledger_.getHeading(contact); + const double cns = ledger_.getSpeed(contact); + const double cnt = ledger_.getUTC(contact); + + const double range_actual = hypot(osx_ - cnx, osy_ - cny); + ranges_actual_[contact] = range_actual; + + LinearExtrapolator linex; + linex.setDecay(decay_start_, decay_end_); + linex.setPosition(cnx, cny, cns, cnh, cnt); + double extrap_x = cnx, extrap_y = cny; + double range_extrap = range_actual; + if (linex.getPosition(extrap_x, extrap_y, curr_time_)) + { + cnx = extrap_x; + cny = extrap_y; + range_extrap = hypot(osx_ - cnx, osy_ - cny); + } + ranges_extrap_[contact] = range_extrap; + + CPAEngine engine(cny, cnx, cnh, cns, osy_, osx_); + cpa_[contact] = engine.evalCPA(osh_, osv_, cpa_time); + roc_[contact] = engine.evalROC(osh_, osv_); + } +} + +void ContactManager::check_for_alerts() +{ + for (const auto& contact : ledger_.getVNames()) + { + const NodeRecord record = ledger_.getRecord(contact); + for (const auto& [id, alert] : alerts_) + { + if (alerts_disabled_.count(id)) + continue; + + const bool applies = check_alert_applies(contact, id); + std::string transition; + if (applies && !par_.getAlertedValue(contact, id)) + { + for (const auto& pair : alert.getAlertOnFlags()) post_alert(record, pair); + par_.setAlertedValue(contact, id, true); + transition = "off-->alerted"; + } + else if (!applies && par_.getAlertedValue(contact, id)) + { + for (const auto& pair : alert.getAlertOffFlags()) post_alert(record, pair); + par_.setAlertedValue(contact, id, false); + transition = "alerted-->off"; + } + + if (!alert_verbose_ || transition.empty()) + continue; + std::string msg = "contact=" + contact + ",alert_id=" + id + "," + transition; + msg += ",alert_range=" + doubleToStringX(alert.getAlertRange(), 1); + msg += ",alert_range_cpa=" + doubleToStringX(alert.getAlertRangeFar(), 1); + msg += ",range_actual=" + doubleToString(ranges_actual_[contact], 1); + if (par_.getAlertedValue(contact, id)) + msg += ",range_cpa=" + doubleToString(cpa_[contact], 1); + if (early_warning_time_ > 0 && transition == "off-->alerted" && + utc_was_warned_.count(contact)) + msg += + ",after_warning=" + doubleToStringX(curr_time_ - utc_was_warned_[contact], 2); + notify("ALERT_VERBOSE", msg); + } + } +} + +bool ContactManager::check_alert_applies(const std::string& contact, const std::string& id) +{ + const auto it = alerts_.find(id); + if (it == alerts_.end() || !it->second.valid() || !ledger_.hasVName(contact)) + return false; + const CMAlert& alert = it->second; + + const NodeRecord record = ledger_.getRecord(contact); + if (curr_time_ - record.getTimeStamp() > contact_max_age_) + return false; + if (!alert.filterCheck(record, osx_, osy_)) + return false; + + // without a range, the alert depends only on its filters (e.g. a region) + const double alert_range = alert.getAlertRange(); + if (alert_range > 0) + { + const double range = ranges_actual_[contact]; + const double range_cpa = cpa_[contact]; + if (range > alert.getAlertRangeFar()) + return false; + if (range > alert_range && range_cpa > alert_range) + return false; + } + return true; +} + +double ContactManager::max_alert_range() const +{ + double max_range = -1; + for (const auto& [id, alert] : alerts_) + if (!alerts_disabled_.count(id)) + max_range = std::max(max_range, alert.getAlertRangeFar()); + return max_range; +} + +void ContactManager::check_for_early_warnings() +{ + if (early_warning_time_ <= 0) + return; + + for (const auto& contact : ledger_.getVNames()) + { + if (range_was_warned_.count(contact) || !ranges_extrap_.count(contact) || + !roc_.count(contact)) + continue; + const double roc = roc_[contact]; + if (roc <= 0) + continue; + + const double alert_range = max_alert_range(); + if (alert_range <= 0) + continue; + if (ranges_extrap_[contact] < alert_range + roc * early_warning_time_) + { + post_warning_flags(early_warning_flags_, contact); + range_was_warned_[contact] = ranges_extrap_[contact]; + utc_was_warned_[contact] = curr_time_; + } + } +} + +void ContactManager::check_for_cease_warnings() +{ + for (const auto& contact : ledger_.getVNames()) + { + auto it = range_was_warned_.find(contact); + if (it == range_was_warned_.end()) + continue; + if (ranges_extrap_[contact] > it->second * 1.05) + { + range_was_warned_.erase(it); + utc_was_warned_.erase(contact); + post_warning_flags(cease_warning_flags_, contact); + } + } +} + +std::list ContactManager::range_ordered_contacts() const +{ + std::vector> ordered; + for (const auto& [contact, range] : ranges_actual_) ordered.emplace_back(range, contact); + std::stable_sort(ordered.begin(), ordered.end(), + [](const auto& a, const auto& b) { return a.first < b.first; }); + std::list contacts; + for (const auto& [range, contact] : ordered) contacts.push_back(contact); + return contacts; +} + +void ContactManager::check_for_new_retired_contacts() +{ + const unsigned starting_count = ledger_.size(); + std::set to_be_retired = filtered_vnames_; + + for (const auto& contact : ledger_.getVNames()) + { + const double age = curr_time_ - ledger_.getRecord(contact).getTimeStamp(); + if (age > contact_max_age_) + to_be_retired.insert(contact); + // 5% beyond the reject range, so a contact near it doesn't come and go + else if (ranges_actual_.count(contact) && reject_range_ > 0 && + ranges_actual_[contact] > reject_range_ * 1.05) + to_be_retired.insert(contact); + } + + // too many contacts: retire at half the max age, then keep only the closest + if (to_be_retired.size() + max_contacts_ < starting_count) + for (const auto& contact : ledger_.getVNames()) + if (curr_time_ - ledger_.getRecord(contact).getTimeStamp() > contact_max_age_ / 2) + to_be_retired.insert(contact); + if (to_be_retired.size() + max_contacts_ < starting_count) + { + const unsigned to_cull = starting_count - (to_be_retired.size() + max_contacts_); + unsigned culled = 0; + const auto ordered = range_ordered_contacts(); + for (auto it = ordered.rbegin(); it != ordered.rend() && culled < to_cull; ++it) + if (to_be_retired.insert(*it).second) + ++culled; + } + + for (const auto& contact : to_be_retired) + { + if (ledger_.hasVName(contact)) + contacts_retired_.push_front(contact); + ledger_.clearNode(contact); + ranges_actual_.erase(contact); + ranges_extrap_.erase(contact); + cpa_.erase(contact); + roc_.erase(contact); + par_.removeVehicle(contact); + post_retire_flags(retire_flags_, contact); + range_was_warned_.erase(contact); + utc_was_warned_.erase(contact); + } + filtered_vnames_.clear(); +} + +void ContactManager::post_alert(const NodeRecord& record, const VarDataPair& pair) +{ + const std::string x = record.getStringValue("x"); + const std::string y = record.getStringValue("y"); + const std::string lat = record.getStringValue("lat"); + const std::string lon = record.getStringValue("lon"); + const std::string spd = record.getStringValue("speed"); + const std::string hdg = record.getStringValue("heading"); + const std::string dep = record.getStringValue("depth"); + const std::string utime = record.getStringValue("time"); + const std::string name = record.getName(); + const std::string type = record.getType(); + const std::string group = record.getGroup(); + + // "$[SPD}" is pContactMgrV20's spelling + auto expand = [&](std::string s, bool with_group) + { + s = findReplace(s, "$[X]", x); + s = findReplace(s, "$[Y]", y); + s = findReplace(s, "$[LAT]", lat); + s = findReplace(s, "$[LON]", lon); + s = findReplace(s, "$[SPD}", spd); + s = findReplace(s, "$[HDG]", hdg); + s = findReplace(s, "$[DEP]", dep); + s = findReplace(s, "$[VNAME]", name); + s = findReplace(s, "$[VTYPE]", type); + if (with_group) + s = findReplace(s, "$[GROUP]", group); + s = findReplace(s, "$[UTIME]", utime); + if (!with_group) + s = findReplace(s, "$[UTC]", utime); + s = findReplace(s, "%[VNAME]", name); + s = findReplace(s, "%[VTYPE]", tolower(type)); + if (with_group) + s = findReplace(s, "%[GROUP]", tolower(group)); + return s; + }; + + const std::string var = expand(pair.get_var(), false); + if (!pair.is_string()) + notify(var, pair.get_ddata()); + else + notify(var, expand(pair.get_sdata(), true)); +} + +void ContactManager::post_flags(const std::vector& flags) +{ + for (const auto& pair : flags) + { + if (!pair.is_string()) + notify(pair.get_var(), pair.get_ddata()); + else + notify(pair.get_var(), pair.get_sdata()); + } +} + +void ContactManager::post_warning_flags(const std::vector& flags, + const std::string& contact) +{ + for (const auto& pair : flags) + { + if (!pair.is_string()) + { + notify(pair.get_var(), pair.get_ddata()); + continue; + } + std::string value = macroExpand(stripBlankEnds(pair.get_sdata()), "CONTACT", contact); + if (ranges_extrap_.count(contact)) + value = macroExpand(value, "RNG_EXT", ranges_extrap_[contact]); + if (ranges_actual_.count(contact)) + value = macroExpand(value, "RNG", ranges_actual_[contact]); + if (cpa_.count(contact)) + value = macroExpand(value, "CPA", cpa_[contact]); + if (roc_.count(contact)) + value = macroExpand(value, "ROC", roc_[contact]); + value = macroExpand(value, "UTC", curr_time_); + if (!value.empty()) + notify(pair.get_var(), value); + } +} + +void ContactManager::post_retire_flags(const std::vector& flags, + const std::string& contact) +{ + for (const auto& pair : flags) + { + if (!pair.is_string()) + { + notify(pair.get_var(), pair.get_ddata()); + continue; + } + std::string value = macroExpand(stripBlankEnds(pair.get_sdata()), "CONTACT", contact); + value = macroExpand(value, "UTC", curr_time_); + if (!value.empty()) + notify(pair.get_var(), value); + } +} + +} // namespace helm +} // namespace ivpico diff --git a/src/lib/helm/contact_manager.h b/src/lib/helm/contact_manager.h new file mode 100644 index 0000000..eea25a7 --- /dev/null +++ b/src/lib/helm/contact_manager.h @@ -0,0 +1,124 @@ +// Copyright 2026: +// GobySoft, LLC +// Ports logic from MOOS-IvP's pContactMgrV20 (ContactMgrV20.cpp), by Michael +// Benjamin, Dept of Mechanical Engineering, MIT. +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 3 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + +#ifndef IVPICO_HELM_CONTACT_MANAGER_H +#define IVPICO_HELM_CONTACT_MANAGER_H + +#include +#include +#include +#include +#include + +#include "ContactLedger.h" +#include "ExFilterSet.h" +#include "NodeRecord.h" +#include "VarDataPair.h" +#include "contacts/CMAlert.h" +#include "contacts/PlatformAlertRecord.h" +#include "interface/config.pb.h" + +namespace ivpico +{ +namespace helm +{ +// pContactMgrV20's alerts, early warnings and retirement, without its reports +class ContactManager +{ + public: + struct Post + { + std::string var; + bool is_string{false}; + double d{0}; + std::string s; + }; + + ContactManager(const ivp::interface::HelmConfig::ContactManager& cfg, + const std::string& ownship, std::vector& config_warnings); + + ContactLedger& ledger() { return ledger_; } + + // Returns false if the variable isn't one the contact manager reads + bool handle_mail(const std::string& var, const std::string& value, + const std::string& source = ""); + void handle_node_record(const NodeRecord& record); + + void set_ownship(double x, double y, double heading, double speed); + std::vector iterate(double time, bool helm_in_drive); + + private: + bool handle_alert(const std::string& alert, const std::string& source); + void handle_mod_enable_contact(const std::string& value, const std::string& action); + + void update_ranges(); + void check_for_alerts(); + void check_for_early_warnings(); + void check_for_cease_warnings(); + void check_for_new_retired_contacts(); + bool check_alert_applies(const std::string& contact, const std::string& id); + double max_alert_range() const; + std::list range_ordered_contacts() const; + + void post_alert(const NodeRecord& record, const VarDataPair& pair); + void post_flags(const std::vector& flags); + void post_warning_flags(const std::vector& flags, const std::string& contact); + void post_retire_flags(const std::vector& flags, const std::string& contact); + void notify(const std::string& var, const std::string& s) + { + posts_.push_back({var, true, 0, s}); + } + void notify(const std::string& var, double d) { posts_.push_back({var, false, d, {}}); } + + std::string ownship_; + ContactLedger ledger_; + ExFilterSet filter_set_; + PlatformAlertRecord par_; + std::map alerts_; + std::set alerts_disabled_; + + double contact_max_age_{60}; + double reject_range_{2000}; + unsigned max_contacts_{500}; + double decay_start_{15}; + double decay_end_{30}; + bool hold_alerts_for_helm_{false}; + bool helm_in_drive_noted_{false}; + bool alert_verbose_{false}; + double early_warning_time_{-1}; + + std::string disable_var_, enable_var_, expunge_var_; + std::vector able_flags_, disable_flags_, enable_flags_; + std::vector early_warning_flags_, cease_warning_flags_, retire_flags_; + + double curr_time_{0}; + double osx_{0}, osy_{0}, osh_{0}, osv_{0}; + + std::map ranges_actual_, ranges_extrap_, cpa_, roc_; + std::map range_was_warned_, utc_was_warned_; + std::set filtered_vnames_; + std::list contacts_retired_; + + std::vector posts_; +}; + +} // namespace helm +} // namespace ivpico + +#endif diff --git a/src/lib/helm/contacts/CMAlert.cpp b/src/lib/helm/contacts/CMAlert.cpp new file mode 100644 index 0000000..032e014 --- /dev/null +++ b/src/lib/helm/contacts/CMAlert.cpp @@ -0,0 +1,336 @@ +/*****************************************************************/ +/* NAME: Michael Benjamin */ +/* ORGN: Dept of Mechanical Engineering, MIT, Cambridge MA */ +/* FILE: CMAlert.cpp */ +/* DATE: Oct 11th 2017 */ +/* */ +/* This file is part of MOOS-IvP */ +/* */ +/* MOOS-IvP is free software: you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation, either version */ +/* 3 of the License, or (at your option) any later version. */ +/* */ +/* MOOS-IvP is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty */ +/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with MOOS-IvP. If not, see */ +/* . */ +/*****************************************************************/ + +#include +#include "XYFormatUtilsPoly.h" +#include "CMAlert.h" + +using namespace std; + +//--------------------------------------------------------------- +// Constructor + +CMAlert::CMAlert() +{ + m_range = -1; + m_range_far = -1; +} + +//--------------------------------------------------------------- +// Procedure: configFilter() + +bool CMAlert::configFilter(string param, string value) +{ + if(param == "match_name") + return(m_filter_set.addMatchName(value)); + else if(param == "ignore_name") + return(m_filter_set.addIgnoreName(value)); + + else if(param == "match_group") + return(m_filter_set.addMatchGroup(value)); + else if(param == "ignore_group") + return(m_filter_set.addIgnoreGroup(value)); + + else if(param == "match_type") + return(m_filter_set.addMatchType(value)); + else if(param == "ignore_type") + return(m_filter_set.addIgnoreType(value)); + + else if(param == "match_region") + return(m_filter_set.addMatchRegion(value)); + else if(param == "ignore_region") + return(m_filter_set.addIgnoreRegion(value)); + + else if(param == "strict_ignore") + return(m_filter_set.setStrictIgnore(value)); + + return(false); +} + +//--------------------------------------------------------------- +// Procedure: filterCheck() + +bool CMAlert::filterCheck(NodeRecord record) const +{ + return(m_filter_set.filterCheck(record)); +} + +//--------------------------------------------------------------- +// Procedure: filterCheck() + +bool CMAlert::filterCheck(NodeRecord record, double osx, double osy) const +{ + return(m_filter_set.filterCheck(record, osx, osy)); +} + + +//--------------------------------------------------------------- +// Procedure: setAlertSource() + +bool CMAlert::setAlertSource(string str) +{ + if(str == "") + return(false); + + m_alert_source = str; + return(true); +} + +//--------------------------------------------------------------- +// Procedure: setAlertRange() +// Note: We ensure that m_range_far is always greater than or +// equal to m_range. + +bool CMAlert::setAlertRange(string str) +{ + if(tolower(str) == "off") { + // The -2 value indicates it has been purposely set to off + m_range = -2; + m_range_far = -2; + return(true); + } + + if(!isNumber(str)) + return(false); + + double dval = atof(str.c_str()); + return(setAlertRange(dval)); +} + +//--------------------------------------------------------------- +// Procedure: setAlertRangeFar() +// Note: We ensure that m_range_far is always greater than or +// equal to m_range. + +bool CMAlert::setAlertRangeFar(string str) +{ + if(tolower(str) == "off") { + // The -2 value indicates it has been purposely set to off + m_range_far = -2; + return(true); + } + if(!isNumber(str)) + return(false); + + double dval = atof(str.c_str()); + + return(setAlertRangeFar(dval)); +} + +//--------------------------------------------------------------- +// Procedure: setAlertRange +// Note: We ensure that m_range_far is always greater than or +// equal to m_range. + +bool CMAlert::setAlertRange(double dval) +{ + if(dval < 0) + return(false); + m_range = dval; + if(m_range_far < m_range) + m_range_far = m_range; + + return(true); +} + +//--------------------------------------------------------------- +// Procedure: setAlertRangeFar +// Note: We ensure that m_range_far is always greater than or +// equal to m_range. + +bool CMAlert::setAlertRangeFar(double dval) +{ + if(dval < 0) + return(false); + m_range_far = dval; + if(m_range > m_range_far) + m_range = m_range_far; + + return(true); +} + + +//--------------------------------------------------------------- +// Procedure: addAlertOnFlag + +bool CMAlert::addAlertOnFlag(string str) +{ + // Sanity check: Make sure this isn't a duplicate + str = stripBlankEnds(str); + if(m_on_flags_raw.count(str)) + return(true); + m_on_flags_raw.insert(str); + + // Ok, create and add the VarDataPair + string lft = biteStringX(str, '='); + string rgt = str; + + if((lft == "") || (rgt == "")) + return(false); + + VarDataPair pair(lft, rgt, "auto"); + m_on_flags.push_back(pair); + return(true); +} + +#if 0 +bool CMAlert::addAlertOnFlag(string str) +{ + vector svector = parseString(str, '#'); + for(unsigned int i=0; i. + #include "helm.h" #include @@ -26,6 +45,7 @@ #include "Populator_BehaviorSet.h" #include "VarDataPair.h" +#include "contact_manager.h" #include "conversions.h" using ivp::interface::AllStop; @@ -158,6 +178,7 @@ class Helm::Impl void post_initial_variables(bool deferred); void post_helm_start_messages(); void update_ledger_snap(); + void run_contact_manager(); void update_plat_model(); void post_mode_messages(); void post_behavior_messages(); @@ -185,6 +206,7 @@ class Helm::Impl InfoBuffer info_buffer_; LedgerSnap ledger_snap_; ContactLedger ledger_; + std::unique_ptr contact_manager_; PlatModelGenerator pmgen_; std::unique_ptr engine_; BehaviorSet* bhv_set_{nullptr}; @@ -211,7 +233,6 @@ class Helm::Impl std::string allstop_msg_; std::string allstop_reason_; unsigned no_decisions_{0}; - unsigned no_goal_decisions_{0}; std::string comms_policy_{"open"}; unsigned iteration_{0}; std::vector missing_decision_vars_; @@ -270,6 +291,14 @@ void Helm::Impl::configure() if (cfg_.has_contact_max_count()) ledger_.setMaxContacts(cfg_.contact_max_count()); + if (!cfg_.has_contact_alerts() || cfg_.contact_alerts()) + { + contact_manager_ = + std::make_unique(cfg_.contact_manager(), ownship_, config_warnings_); + if (geodesy_) + contact_manager_->ledger().setGeodesy(geodesy_->to_local, geodesy_->to_global); + } + const auto& pm = cfg_.platform_model(); std::string pmgen = pm.algorithm() == HelmConfig::PlatformModel::DUBINS ? "alg=dubins" : "alg=holo"; @@ -365,14 +394,20 @@ const Output& Helm::Impl::iterate(double time) if (status_ != Status::MALCONFIG) { for (const auto& [var, value] : echo) + { if (registered_.count(var)) apply_variable(var, value, echo_time); + else if (contact_manager_) + contact_manager_->handle_mail(var, value.s); + } apply_pending(time); info_buffer_.setValue("COMMS_POLICY", comms_policy_, time); } pending_.clear(); update_status(); + if (status_ != Status::MALCONFIG) + run_contact_manager(); notify("IVPHELM_STATE", Status::State_Name(status_)); fill_status(); if (!enabled()) @@ -422,9 +457,6 @@ const Output& Helm::Impl::iterate(double time) post_life_events(); post_decisions(); - if (allstop_msg_ != "clear" && allow_park_ && park_on_allstop_) - has_control_ = false; - fill_status(); info_buffer_.clearDeltaVectors(); return output_; @@ -461,6 +493,8 @@ void Helm::Impl::apply(const Navigation& nav, double time) if (record.getName().empty()) return; process_node_record(record); + if (contact_manager_) + contact_manager_->handle_node_record(record); info_buffer_.setValue("NODE_REPORT", record.getSpec(), t); return; } @@ -548,6 +582,9 @@ void Helm::Impl::apply_variable(const std::string& var, const Value& value, doub }; const std::string sval = value.s; + if (contact_manager_) + contact_manager_->handle_mail(var, sval); + if (var == "MOOS_MANUAL_OVERRIDE" || var == "MOOS_MANUAL_OVERIDE") { if (toupper(sval) == "FALSE") @@ -746,6 +783,25 @@ void Helm::Impl::update_ledger_snap() ledger_snap_.setCurrTimeUTC(curr_time_); } +void Helm::Impl::run_contact_manager() +{ + if (!contact_manager_) + return; + bool ok1, ok2, ok3, ok4; + const double osx = info_buffer_.dQuery("NAV_X", ok1); + const double osy = info_buffer_.dQuery("NAV_Y", ok2); + const double osh = info_buffer_.dQuery("NAV_HEADING", ok3); + const double osv = info_buffer_.dQuery("NAV_SPEED", ok4); + contact_manager_->set_ownship(ok1 ? osx : 0, ok2 ? osy : 0, ok3 ? osh : 0, ok4 ? osv : 0); + + for (const auto& post : contact_manager_->iterate(curr_time_, status_ == Status::DRIVE)) + { + const Value value{post.is_string, post.d, post.s}; + add_posting(Posting::CONTACT_MANAGER, "", post.var, value); + notify(post.var, value); + } +} + void Helm::Impl::update_plat_model() { bool ok1, ok2, ok3, ok4; @@ -910,8 +966,9 @@ void Helm::Impl::post_allstop(const std::string& msg) allstop_msg_ = msg; allstop_reason_ = msg; no_decisions_ = - (msg == "NothingToDo" || strBegins(msg, "MissingDecVars")) ? no_decisions_ + 1 : 0; - no_goal_decisions_ = msg == "NoGoalBehavior" ? no_goal_decisions_ + 1 : 0; + (msg == "NothingToDo" || msg == "NoGoalBehavior" || strBegins(msg, "MissingDecVars")) + ? no_decisions_ + 1 + : 0; notify("IVPHELM_ALLSTOP", msg); if (msg == "clear") @@ -919,15 +976,12 @@ void Helm::Impl::post_allstop(const std::string& msg) // one iteration's grace to let the helm move between modes if (no_decisions_ == 1) - { - allstop_msg_ = "IncompleteOrEmptyDecision"; return; - } - if (no_goal_decisions_ == 1) - { - allstop_msg_ = "NoActiveGoalBehavior"; - return; - } + + // other allstops keep control, and the helm decides again once they clear + if (allow_park_ && park_on_allstop_ && + (msg == "BehaviorError" || msg == "DisabledByStandbyHelm")) + has_control_ = false; ivp::interface::Solution solution; solution.set_allstop(allstop_enum(msg)); @@ -974,11 +1028,12 @@ void Helm::Impl::fill_status() if (!name.empty()) run_states[name] = state; }; + // first, since a respawned behavior keeps the name of one that completed + add_states(report_.getCompletedBehaviors(false), Status::Behavior::COMPLETED); add_states(report_.getIdleBehaviors(false), Status::Behavior::IDLE); add_states(report_.getRunningBehaviors(false), Status::Behavior::RUNNING); add_states(report_.getActiveBehaviors(false), Status::Behavior::ACTIVE); add_states(report_.getDisabledBehaviors(false), Status::Behavior::DISABLED); - add_states(report_.getCompletedBehaviors(false), Status::Behavior::COMPLETED); for (unsigned i = 0; i < bhv_set_->size(); ++i) { diff --git a/src/lib/helm/helm.h b/src/lib/helm/helm.h index 1e50684..e4eb681 100644 --- a/src/lib/helm/helm.h +++ b/src/lib/helm/helm.h @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free Software +// Foundation, either version 2.1 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with IvPico. If not, see . + #ifndef IVPICO_HELM_HELM_H #define IVPICO_HELM_HELM_H diff --git a/src/lib/helm/status_strings.cpp b/src/lib/helm/status_strings.cpp index 680396d..c3ab186 100644 --- a/src/lib/helm/status_strings.cpp +++ b/src/lib/helm/status_strings.cpp @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free Software +// Foundation, either version 2.1 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with IvPico. If not, see . + #include "status_strings.h" namespace ivpico diff --git a/src/lib/helm/status_strings.h b/src/lib/helm/status_strings.h index 5827f3f..ed0ebad 100644 --- a/src/lib/helm/status_strings.h +++ b/src/lib/helm/status_strings.h @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free Software +// Foundation, either version 2.1 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with IvPico. If not, see . + #ifndef IVPICO_HELM_STATUS_STRINGS_H #define IVPICO_HELM_STATUS_STRINGS_H diff --git a/src/lib/interface/config.proto b/src/lib/interface/config.proto index 17258ab..2a9a190 100644 --- a/src/lib/interface/config.proto +++ b/src/lib/interface/config.proto @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free Software +// Foundation, either version 2.1 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with IvPico. If not, see . + syntax = "proto3"; package ivp.interface; @@ -33,7 +50,7 @@ message HelmConfig bool start_in_drive = 4; // default true optional bool allow_park = 5; - // default true + // park on an allstop from a behavior error; default true optional bool park_on_allstop = 6; // seconds before warning that NAV_X, NAV_Y, etc. are still missing; default 5 optional double nav_grace = 7; @@ -74,6 +91,63 @@ message HelmConfig // with this mode openocean.SpeedMode speed_mode = 110 [(ivp.field).level = ADVANCED]; + // pContactMgrV20's configuration, for the alerts the helm raises itself + message ContactManager + { + // e.g. "id=avd, on_flag=CONTACT_INFO=name=$[VNAME] # contact=$[VNAME], + // alert_range=15, cpa_range=25", alongside behaviors' own requests + repeated string alert = 1; + + // contacts the contact manager ignores altogether + repeated string ignore_name = 2; + repeated string match_name = 3; + repeated string ignore_group = 4; + repeated string match_group = 5; + repeated string ignore_type = 6; + repeated string match_type = 7; + // "pts={x,y:x,y:...}" + repeated string ignore_region = 8; + repeated string match_region = 9; + bool strict_ignore = 10; + string ownship_group = 11; + string ownship_type = 12; + + // seconds; default 60 + optional double contact_max_age = 20; + // meters, beyond which contacts are retired; 0 is off; default 2000 + optional double reject_range = 21; + // default 500 + optional uint32 max_contacts = 22; + // seconds since a contact's last report over which its extrapolation + // decays to a stop; default 15 to 30 + optional double decay_start = 23; + optional double decay_end = 24; + // raise no alerts until the helm has been in DRIVE + bool hold_alerts_for_helm = 25; + // post ALERT_VERBOSE on each alert change + bool alert_verbose = 26; + + // a post to one of these with a contact's name disables, enables or + // expunges the behaviors for that contact (through BHV_ABLE_FILTER) + string disable_var = 30; + string enable_var = 31; + string expunge_var = 32; + // "VAR=value" posts on any enable or disable, a disable, or an enable + repeated string able_flag = 33; + repeated string disable_flag = 34; + repeated string enable_flag = 35; + + // seconds of warning before a contact closing on ownship reaches the + // largest alert range; off unless positive + double early_warning_time = 40; + // "VAR=value", expanding $[CONTACT], $[RNG], $[RNG_EXT], $[CPA], $[ROC], $[UTC] + repeated string early_warning_flag = 41; + repeated string cease_warning_flag = 42; + // "VAR=value" on retiring a contact, expanding $[CONTACT] and $[UTC] + repeated string retire_flag = 43; + } + ContactManager contact_manager = 111 [(ivp.field).level = ADVANCED]; + bool report_objective_functions = 200 [(ivp.field).level = DEVELOPER]; // default true; false leaves alerts to an outside contact manager optional bool contact_alerts = 201 [(ivp.field).level = DEVELOPER]; diff --git a/src/lib/interface/ivp.proto b/src/lib/interface/ivp.proto index abd249b..d73deff 100644 --- a/src/lib/interface/ivp.proto +++ b/src/lib/interface/ivp.proto @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free Software +// Foundation, either version 2.1 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with IvPico. If not, see . + syntax = "proto3"; package ivp.interface; @@ -146,6 +163,8 @@ message Posting INITIALIZE = 3; // aux "HELM_VAR_INIT" HELM_START = 100 [(ivp.ev).level = ADVANCED]; // aux "HELM_STARTUP_MSG" DEFAULT = 101 [(ivp.ev).level = ADVANCED]; + // what pContactMgrV20 would post: alert flags, warnings, BHV_ABLE_FILTER + CONTACT_MANAGER = 102 [(ivp.ev).level = ADVANCED]; } Origin origin = 2; string behavior = 3; diff --git a/src/lib/interface/options.proto b/src/lib/interface/options.proto index ac0ac33..a150fb0 100644 --- a/src/lib/interface/options.proto +++ b/src/lib/interface/options.proto @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the Free Software +// Foundation, either version 2.1 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with IvPico. If not, see . + syntax = "proto3"; package ivp; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index d4582d1..e627d9b 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -13,20 +13,27 @@ foreach(fixture ${fixtures}) if(IS_DIRECTORY ${fixture}) get_filename_component(mission ${fixture} NAME) add_test(NAME replay_${mission} COMMAND replay ${fixture}) + file(GLOB moos_file ${fixture}/*.moos) + file(STRINGS ${moos_file} contact_manager REGEX "ProcessConfig *= *pContactMgrV20") + if(contact_manager) + add_test(NAME replay_${mission}_alerts COMMAND replay ${fixture} --alerts) + endif() endif() endforeach() # 'goby test' is in Goby builds after 3.6.1, which set GOBY_EXECUTABLE if(GOBY_FOUND AND GOBY_EXECUTABLE) + add_subdirectory(goby/ghost) set(goby_test_defines - -D HELM=$ -D INTERFACE_LIB=$) + -D HELM=$ -D INTERFACE_LIB=$ + -D GHOST=$) add_test(NAME goby_helm_ivp COMMAND ${GOBY_EXECUTABLE} test run ${CMAKE_CURRENT_SOURCE_DIR}/goby/helm_ivp/test.yml ${goby_test_defines}) set(simulator_port 54400) - foreach(mission s1_alpha s2_bravo s3_charlie s4_delta) + foreach(mission s1_alpha s2_bravo s3_charlie s4_delta m2_berta) add_test(NAME closed_loop_${mission} COMMAND ${GOBY_EXECUTABLE} test run ${CMAKE_CURRENT_SOURCE_DIR}/missions/goby/${mission}/test.yml ${goby_test_defines} -D MISSION=${mission} -D PORT=${simulator_port}) diff --git a/src/test/check_helm_libs.cpp b/src/test/check_helm_libs.cpp index 0168326..01cecd0 100644 --- a/src/test/check_helm_libs.cpp +++ b/src/test/check_helm_libs.cpp @@ -1,4 +1,21 @@ -// Checks that IvPico can use MOOS-IvP's helm libraries (external/moos-ivp, built by build.sh): +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + +// Checks that IvPico can use MOOS-IvP's helm libraries (libivp-helm-dev): // // 1. The static behavior factory creates behaviors from lib_behaviors-marine // and lib_behaviors-colregs, which loads every helm library. diff --git a/src/test/goby/ghost/CMakeLists.txt b/src/test/goby/ghost/CMakeLists.txt new file mode 100644 index 0000000..96e05ec --- /dev/null +++ b/src/test/goby/ghost/CMakeLists.txt @@ -0,0 +1,11 @@ +# a test app, so not goby_add_app, which installs it +add_executable(ivpico_ghost ghost.cpp) +protobuf_generate( + TARGET ivpico_ghost + LANGUAGE cpp + PROTOS ghost_config.proto + IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${GOBY_INCLUDE_DIR} ${GOBY_DCCL_PROTO_DIR} + PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(ivpico_ghost PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/src/bin/goby) +target_link_libraries(ivpico_ghost goby goby_zeromq ivpico_interface) diff --git a/src/test/goby/ghost/ghost.cpp b/src/test/goby/ghost/ghost.cpp new file mode 100644 index 0000000..f4fac46 --- /dev/null +++ b/src/test/goby/ghost/ghost.cpp @@ -0,0 +1,197 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + +// Replays contacts' recorded NODE_REPORTs to goby_helm_ivp, for the closed-loop +// mission tests. The recording's first IVPHELM_STATE = DRIVE lines up with the +// helm's first DRIVE, and each report goes out at its recorded offset from +// there (in warped time), restamped with the current time. The contacts don't +// react to ownship. +// +// Publishes each contact's range to ownship (frontseat NodeStatus) as a +// Variable "_RANGE" on ivpico::test::ghost_range. + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "ghost_config.pb.h" +#include "groups.h" +#include "interface/ivp.pb.h" + +namespace ivpico +{ +namespace goby +{ +namespace groups +{ +constexpr ::goby::middleware::Group ghost_range{"ivpico::test::ghost_range"}; +} + +class Ghost : public ::goby::zeromq::SingleThreadApplication +{ + public: + Ghost(); + + private: + struct Report + { + double offset; + std::string name; + std::map fields; + std::vector keys; + }; + + void read_alog(); + void loop() override; + double now() const; + std::string restamp(const Report& report) const; + + std::deque reports_; + std::optional start_; + std::map> contact_xy_; +}; +} // namespace goby +} // namespace ivpico + +int main(int argc, char* argv[]) { return goby::run(argc, argv); } + +ivpico::goby::Ghost::Ghost() + : ::goby::zeromq::SingleThreadApplication(20 * boost::units::si::hertz) +{ + read_alog(); + + interprocess().subscribe( + [this](const ivp::interface::Status& status) + { + if (!start_ && status.state() == ivp::interface::Status::DRIVE) + start_ = now(); + }); + + interprocess().subscribe<::goby::middleware::frontseat::groups::node_status>( + [this](const ::goby::middleware::frontseat::protobuf::NodeStatus& status) + { + for (const auto& [name, xy] : contact_xy_) + { + ivp::interface::Variable range; + range.set_time(static_cast(now() * 1e6)); + range.set_key(name + "_RANGE"); + range.set_dval(std::hypot(status.local_fix().x() - xy.first, + status.local_fix().y() - xy.second)); + interprocess().publish(range); + } + }); +} + +double ivpico::goby::Ghost::now() const +{ + return ::goby::time::SystemClock::now<::goby::time::SITime>().value(); +} + +void ivpico::goby::Ghost::read_alog() +{ + std::unique_ptr pipe( + popen(("xz -dc '" + cfg().alog() + "'").c_str(), "r"), pclose); + if (!pipe) + throw std::runtime_error("can't run xz on " + cfg().alog()); + std::string text; + char buffer[65536]; + for (size_t n; (n = fread(buffer, 1, sizeof(buffer), pipe.get())) > 0;) text.append(buffer, n); + + const std::set vehicles(cfg().vehicle().begin(), cfg().vehicle().end()); + std::optional drive; + std::istringstream lines(text); + for (std::string line; std::getline(lines, line);) + { + std::istringstream fields(line); + double time; + std::string var, source, value; + if (!(fields >> time >> var >> source)) + continue; + std::getline(fields, value); + const auto begin = value.find_first_not_of(" \t"); + value = begin == std::string::npos + ? "" + : value.substr(begin, value.find_last_not_of(" \t") - begin + 1); + + if (!drive && var == "IVPHELM_STATE" && value == "DRIVE") + drive = time; + if (var != "NODE_REPORT" || !drive) + continue; + + Report report; + report.offset = time - *drive; + std::istringstream pairs(value); + for (std::string pair; std::getline(pairs, pair, ',');) + { + const auto eq = pair.find('='); + if (eq == std::string::npos) + continue; + const std::string key = pair.substr(0, eq); + report.keys.push_back(key); + report.fields[key] = pair.substr(eq + 1); + } + report.name = report.fields["NAME"]; + if (vehicles.count(report.name)) + reports_.push_back(report); + } + if (reports_.empty()) + throw std::runtime_error("no NODE_REPORTs after DRIVE for the vehicles in " + cfg().alog()); +} + +std::string ivpico::goby::Ghost::restamp(const Report& report) const +{ + std::string spec; + for (const auto& key : report.keys) + { + // the helm places the contact from X and Y with its own datum + if (key == "LAT" || key == "LON") + continue; + const std::string value = key == "TIME" ? std::to_string(now()) : report.fields.at(key); + spec += (spec.empty() ? "" : ",") + key + "=" + value; + } + return spec; +} + +void ivpico::goby::Ghost::loop() +{ + if (!start_) + return; + const double elapsed = now() - *start_; + while (!reports_.empty() && reports_.front().offset <= elapsed) + { + const Report& report = reports_.front(); + ivp::interface::Variable v; + v.set_time(static_cast(now() * 1e6)); + v.set_key("NODE_REPORT"); + v.set_sval(restamp(report)); + interprocess().publish(v); + contact_xy_[report.name] = {std::stod(report.fields.at("X")), + std::stod(report.fields.at("Y"))}; + reports_.pop_front(); + } +} diff --git a/src/test/goby/ghost/ghost_config.proto b/src/test/goby/ghost/ghost_config.proto new file mode 100644 index 0000000..d4809c3 --- /dev/null +++ b/src/test/goby/ghost/ghost_config.proto @@ -0,0 +1,34 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + +syntax = "proto2"; + +import "goby/middleware/protobuf/app_config.proto"; +import "goby/zeromq/protobuf/interprocess_config.proto"; +import "goby/protobuf/option_extensions.proto"; + +package ivpico.goby.protobuf; + +message GhostConfig +{ + optional .goby.middleware.protobuf.AppConfig app = 1; + optional .goby.zeromq.protobuf.InterProcessPortalConfig interprocess = 2 + [(.goby.field) = { cfg { env: "GOBY_INTERPROCESS" } }]; + + required string alog = 10 [(.goby.field).description = "xz-compressed alog with the contacts' NODE_REPORTs"]; + repeated string vehicle = 11 [(.goby.field).description = "Contacts to replay (NODE_REPORT NAME)"]; +} diff --git a/src/test/helm/test_helm.cpp b/src/test/helm/test_helm.cpp index b5da4f2..a20c255 100644 --- a/src/test/helm/test_helm.cpp +++ b/src/test/helm/test_helm.cpp @@ -1,3 +1,20 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + // Scenario tests for ivpico::helm::Helm, the MOOS-free port of pHelmIvP. // // Each scenario writes a small .bhv file, configures a helm with a course and @@ -140,10 +157,10 @@ std::string mode(const Output& out) // - after DEPLOY and the override, DRIVE in mode ACTIVE:SURVEYING, heading north; // - reaching the waypoint posts RETURN=true. // On the iteration the survey completes, no behavior produces an objective -// function, so the helm declares NothingToDo. With park_on_allstop (the -// default) it then parks, as pHelmIvP does at the end of s1_alpha's survey. -// Without it, RETURN=true switches to ACTIVE:RETURNING and turns the vehicle -// around. +// function, so the helm declares NothingToDo. That's an allstop pHelmIvP +// rides out for an iteration, and park_on_allstop only parks on errors, so +// with it set or not, RETURN=true then switches to ACTIVE:RETURNING and turns +// the vehicle around without parking. void waypoint_mission(bool park_on_allstop) { const std::string scenario = @@ -222,10 +239,8 @@ Behavior = BHV_Waypoint } check(surveying, scenario, "never surveyed north in DRIVE"); check(returned, scenario, "waypt_survey never posted its endflag RETURN=true"); - if (park_on_allstop) - check(parked && !turned, scenario, "didn't park when the survey completed"); - else - check(turned && !parked, scenario, "never turned south in mode ACTIVE:RETURNING"); + check(turned, scenario, "never turned south in mode ACTIVE:RETURNING"); + check(!parked, scenario, "parked after the survey"); } // One behavior posts an update for another: a timer's endflag posts @@ -324,11 +339,124 @@ Behavior = BHV_ConstantHeading check(decided, scenario, "the spawned behavior never decided course 45"); } +Navigation contact(const std::string& name, double x, double y, double heading, double speed, + double t) +{ + Navigation nav; + nav.set_self(false); + nav.set_type("kayak"); + auto& n = *nav.mutable_nav(); + n.mutable_vehicle()->set_name(name); + n.set_time(static_cast(t * 1e6)); + n.mutable_enu()->set_e(x); + n.mutable_enu()->set_n(y); + n.mutable_attitude()->set_heading(heading * M_PI / 180); + n.add_speed()->set_value(speed); + return nav; +} + +// The built-in contact manager (pContactMgrV20's alerts) spawns a collision +// avoidance behavior. The avd_ template posts a BCM_ALERT_REQUEST on helm +// start (alert_range 40, cpa_range 60). Ownship holds course 90 at 1 m/s +// from the origin; "bob" starts 150 m east heading west at 2 m/s, and "ann" +// stays 500 m north. Checks: +// - the CONTACT_INFO alert for bob, as a CONTACT_MANAGER posting, once bob +// is inside the cpa_range, and none for ann; +// - a SPAWN life event for avd_bob after that; +// - a post to the configured disable_var gives BHV_ABLE_FILTER; +// - with contact_alerts false, neither the alert nor the spawn. +void contact_alert(bool contact_alerts) +{ + const std::string scenario = + std::string("contact_alert") + (contact_alerts ? "" : " (contact_alerts false)"); + auto cfg = config(write_bhv("contact_alert", R"( +Behavior = BHV_ConstantHeading +{ + name = ch + pwt = 100 + heading = 90 + duration = no-time-limit +} +Behavior = BHV_ConstantSpeed +{ + name = cs + pwt = 100 + speed = 1 + duration = no-time-limit +} +Behavior = BHV_AvoidCollision +{ + name = avd_ + pwt = 200 + templating = spawn + updates = CONTACT_INFO + contact = to-be-set + on_no_contact_ok = true + pwt_outer_dist = 40 + pwt_inner_dist = 20 + completed_dist = 60 + min_util_cpa_dist = 8 + max_util_cpa_dist = 25 +} +)")); + cfg.set_start_in_drive(true); + cfg.set_contact_alerts(contact_alerts); + cfg.mutable_contact_manager()->set_disable_var("XYZ_DISABLE_TARGET"); + Helm helm(cfg); + check(helm.config_warnings().empty(), scenario, "config warnings"); + + Vehicle vehicle; + double t = t0; + double bob_x = 150; + int alert_tick = -1, spawn_tick = -1; + bool ann_alerted = false, able_filter = false; + for (int i = 0; i < 200; ++i) + { + helm.handle(vehicle.navigation(t)); + helm.handle(contact("bob", bob_x, 0, 270, 2, t)); + helm.handle(contact("ann", 0, 500, 90, 0, t)); + if (i == 150) + helm.handle(variable("XYZ_DISABLE_TARGET", "bob")); + const Output& out = helm.iterate(t); + for (const auto& p : out.postings) + { + if (p.origin() != Posting::CONTACT_MANAGER) + continue; + if (p.key() == "CONTACT_INFO" && p.sval() == "name=bob # contact=bob" && alert_tick < 0) + alert_tick = i; + if (p.key() == "CONTACT_INFO" && p.sval().find("ann") != std::string::npos) + ann_alerted = true; + if (p.key() == "BHV_ABLE_FILTER" && p.sval() == "contact=bob,action=disable") + able_filter = true; + } + for (const auto& e : out.life_events) + if (e.type() == ivp::interface::LifeEvent::SPAWN && e.behavior() == "avd_bob") + spawn_tick = i; + if (out.solution) + vehicle.follow(*out.solution); + bob_x -= 2 * dt; + t += dt; + } + + check(!ann_alerted, scenario, "alerted on ann, 500 m away"); + if (!contact_alerts) + { + check(alert_tick < 0, scenario, "the helm raised an alert itself"); + check(spawn_tick < 0, scenario, "spawned avd_bob without an alert"); + return; + } + // bob closes at 3 m/s from 150 m, so he's inside 60 m after 30 s (120 iterations) + check(alert_tick > 100 && alert_tick < 130, scenario, + "CONTACT_INFO for bob at iteration " + std::to_string(alert_tick)); + check(spawn_tick > alert_tick, scenario, "no SPAWN for avd_bob after the alert"); + check(able_filter, scenario, "no BHV_ABLE_FILTER from XYZ_DISABLE_TARGET"); +} + // Allstop reasons and park-on-allstop: // - no speed decision with a required speed domain gives -// MISSING_DECISION_VARIABLES and PARK, since park_on_allstop defaults to -// true. pHelmIvP parks during the one iteration's grace it gives a missing -// decision, so the zero solution comes with MANUAL_OVERRIDE; +// MISSING_DECISION_VARIABLES. pHelmIvP gives a missing decision an +// iteration's grace, and park_on_allstop parks only on errors, so the helm +// stays in DRIVE and posts no solution while the decision is missing; // - with speed optional, the same behaviors give a CLEAR solution; // - manual override in DRIVE gives MANUAL_OVERRIDE and PARK. void allstop() @@ -348,7 +476,7 @@ Behavior = BHV_ConstantHeading Helm helm(cfg); Vehicle vehicle; double t = t0; - bool missing = false, zeroed = false; + bool missing = false, solution = false; for (int i = 0; i < 12; ++i) { helm.handle(vehicle.navigation(t)); @@ -357,14 +485,13 @@ Behavior = BHV_ConstantHeading out.status.missing_decision_variables_size() == 1 && out.status.missing_decision_variables(0) == "speed") missing = true; - if (out.solution && out.solution->allstop() != ivp::interface::CLEAR && - out.solution->desired().speed().value() == 0) - zeroed = true; + if (out.solution) + solution = true; t += dt; } check(missing, scenario, "no MISSING_DECISION_VARIABLES for speed"); - check(zeroed, scenario, "no zero solution for the missing speed"); - check(helm.state() == Status::PARK, scenario, "didn't park on allstop"); + check(!solution, scenario, "a solution without a speed decision"); + check(helm.state() == Status::DRIVE, scenario, "parked on a missing decision"); } { auto cfg = config(bhv); @@ -459,6 +586,8 @@ int main() waypoint_mission(false); update_through_echo(); spawn(); + contact_alert(true); + contact_alert(false); allstop(); malconfig(); deferred_initialize(); diff --git a/src/test/missions/README.md b/src/test/missions/README.md index eb610fe..7f5efb9 100644 --- a/src/test/missions/README.md +++ b/src/test/missions/README.md @@ -13,8 +13,9 @@ flowchart LR ``` - `missions.txt` lists the missions and the variables poked to start them. -- `record.sh [mission...]` builds all of MOOS-IvP from GobySoft's `ivp-without-moos` branch (the source of the `libivp-helm-dev` package) into `build/missions`, runs each mission under pHelmIvP with time warp, and keeps each vehicle's helm inputs and outputs in `fixtures/`. The "Record missions" workflow runs it on GitHub and uploads the fixtures as an artifact. +- `record.sh [mission...]` builds all of MOOS-IvP from GobySoft's `ivp-without-moos` branch (the source of the `libivp-helm-dev` package) into `build/missions`, runs each mission under pHelmIvP with time warp, and keeps each vehicle's helm inputs and outputs in `fixtures/`. Missions with several vehicles run from their own `launch.sh --just_make`, with a fixture per vehicle, `fixtures/.`. The "Record missions" workflow runs it on GitHub and uploads the fixtures as an artifact. - `replay ` feeds the recorded inputs to the IvPico helm at pHelmIvP's iteration times and compares what each helm posted. `replay.cpp` describes what's compared and the tolerances. +- `replay --alerts` (ctest: `replay__alerts`, for vehicles that ran pContactMgrV20) leaves out pContactMgrV20's recorded posts and has the helm raise contact alerts itself, from the `.moos` file's pContactMgrV20 block. Re-record the fixtures whenever `libivp-helm-dev` moves to a new MOOS-IvP. @@ -34,5 +35,6 @@ flowchart LR - `goby/closed_loop.yml` starts the fixtures (`gobyd`, the simulator, the frontseat interface and the helm) and waits for them; each `test.yml` includes it. - `goby//test.yml` sends the pokes and expects postings by a deadline. Its times are real seconds, a tenth of mission time. -- `goby//helm.pb.cfg` is the helm configuration (the `.moos` file's pHelmIvP block). +- `goby//helm.pb.cfg` is the helm configuration (the `.moos` file's pHelmIvP block, and its pContactMgrV20 block as `contact_manager`). +- In `m2_berta`, `ivpico_ghost` (`src/test/goby/ghost`) replays the other vehicle's recorded NODE_REPORTs from the helm's first DRIVE. The ghost doesn't react to ownship. It publishes its range to ownship, which the test keeps above a minimum. - `goby test visualize -D MISSION= ...` draws the plan; a failed run's report names each fixture's log. diff --git a/src/test/missions/fixtures/berta_cmgr.abe/berta_cmgr.abe.alog.xz b/src/test/missions/fixtures/berta_cmgr.abe/berta_cmgr.abe.alog.xz new file mode 100644 index 0000000..bc681d7 Binary files /dev/null and b/src/test/missions/fixtures/berta_cmgr.abe/berta_cmgr.abe.alog.xz differ diff --git a/src/test/missions/fixtures/berta_cmgr.abe/berta_cmgr.abe.moos b/src/test/missions/fixtures/berta_cmgr.abe/berta_cmgr.abe.moos new file mode 100644 index 0000000..a0ab10e --- /dev/null +++ b/src/test/missions/fixtures/berta_cmgr.abe/berta_cmgr.abe.moos @@ -0,0 +1,371 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_ABE_13_11_2026_____03_14_28/LOG_ABE_13_11_2026_____03_14_28._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178158672.845328 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//---------------------------------------------------- +// Vehicle MOOS config file +// M. Benjamin, MIT + +ServerHost = localhost +ServerPort = 9001 +Community = abe + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//---------------------------------------------------- +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 50 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePIDV22 @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = uMemWatch @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false + Run = pRealm @ NewConsole = false + + Run = uSimMarineV22 @ NewConsole = false + } + +//------------------------------------------------------ +// uSimMarineV22 Config Block + +ProcessConfig = uSimMarineV22 +{ + AppTick = 10 + CommsTick = 10 + + start_pos = x=170,y=-80,heading=270, 0 + prefix = NAV + + //app_logging = true + max_speed = 2 + + turn_rate = 95 + turn_spd_loss = 0.6 + + post_des_thrust = DESIRED_THRUSTX + post_des_rudder = DESIRED_RUDDERX + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + + + +//-------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9201, white_list=DEPLOY & MOOS_MANUAL_OVERRIDE & NODE_BROKER_ACK & APPCAST_REQ +} + +//-------------------------------------------------- +// pHostInfo Config Block + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + default_hostip_force = localhost +} + +//-------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + nowatch = uMAC* + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB* + + summary_wait = 12 +} + + + +//---------------------------------------------------- +// pHelmIvP Config Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + behaviors = targ_abe.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:2:21 + + app_logging = true + + hold_on_apps = pContactMgrV20 +} + +//---------------------------------------------------- +// pNodeReporter Config Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + platform_color = yellow + vessel_type = kayak + //terse_reports = true + + coord_policy_global = true +} + +//-------------------------------------------------------- +// pContactMgrV20 Config Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + app_logging = true + + alert_verbose = true + + contact_local_coords = force_lat_lon + + contact_max_age = 35 + display_radii = true + display_radii_id = avd + alert_range_color = gray70 + cpa_range_color = gray30 + + early_warning_range = 60 + early_warning_flag = CMGR_WARNING = Warning=$[CONTACT], at $[RNG] + early_warning_ref_spd = 3.4 + early_warning_radii = true + + cease_warning_flag = CMGR_WARNING = off + + disable_var = XYZ_DISABLE_TARGET + enable_var = XYZ_REENABLE_TARGET + + post_closest_range = true + hold_alerts_for_helm = true +} + +//-------------------------------------------------- +// uFldNodeBroker Config Block + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + //shadow_shore = ip=192.168.7.22, name=henry, dur=45000 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=CMGR_WARNING + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//-------------------------------------------------- +// uLoadWatch Config Block + +ProcessConfig = uLoadWatch +{ + AppTick = 1 + CommsTick = 1 + + thresh = app=pHelmIvP, gapthresh=3 + thresh = app=pHostInfo, gapthresh=5 + thresh = app=any, gapthresh=2.0 + thresh = app=uMemWatch, gapthresh=50 + thresh = app=uSimMarineV22, gapthresh=3 + + breach_trigger = 5 +} + +//-------------------------------------------------------- +// uMemWatch Config Block + +ProcessConfig = uMemWatch +{ + AppTick = 0.4 + CommsTick = 0.4 + + absolute_time_gap = 2 + watch_only = pHelmIvP +} + +//----------------------------------------------------- +// pMarinePIDV22 Config Block + +ProcessConfig = pMarinePIDV22 +{ + AppTick = 10 + CommsTick = 10 + + verbose = true + depth_control = false + active_start = true + + // Yaw PID controller + yaw_pid_kp = 1.2 + yaw_pid_kd = 0.1 + yaw_pid_ki = 0.3 + yaw_pid_integral_limit = 0.07 + + // Speed PID controller + speed_pid_kp = 1.0 + speed_pid_kd = 0.0 + speed_pid_ki = 0.0 + speed_pid_integral_limit = 0.07 + + // Maximums + maxrudder = 100 + maxthrust = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + speed_factor = 20 +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CONTACT_INFO @ 0 NOSYNC + Log = CYCLE_INDEX @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = DIST_TO_STATION @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = PHELMIVP_ITER_GAP @ 0 NOSYNC + Log = PHELMIVP_ITER_LEN @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = PSKEEP_MODE @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATIONING @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = TRANSIT @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + Log = WPT_INDEX @ 0 NOSYNC + Log = WPT_ODO @ 0 NOSYNC + Log = WPT_STAT @ 0 NOSYNC + Log = WPT_UPDATE @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_ABE + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = BCM_ALERT_REQUEST @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true +// WildCardOmitPattern = DB_RWSUMMARY + + //WildCardOmitPattern = NAV_LAT, NAV_LONG + //WildCardOmitPattern = NODE_BROKER_PING_0, PSHARE* + + // WildCardOmitPattern = DB_CLIENTS + // WildCardOmitPattern = PHI_HOST*, NODE_REPORT_LOCAL +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/berta_cmgr.abe/targ_abe.bhv b/src/test/missions/fixtures/berta_cmgr.abe/targ_abe.bhv new file mode 100644 index 0000000..d5e7875 --- /dev/null +++ b/src/test/missions/fixtures/berta_cmgr.abe/targ_abe.bhv @@ -0,0 +1,126 @@ +//------------------------------------------------- +// Vehicle Helm config file +// M. Benjamin, MIT + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize TRANSIT = true +initialize AVOID = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = TRANSITING { + MODE = ACTIVE + TRANSIT = true +} + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_transit + pwt = 100 + condition = MODE == TRANSITING + endflag = STATION_KEEP = true + + updates = WPT_UPDATE + perpetual = true + + speed = 3 // meters per second + capture_line = true + capture_radius = 5.0 + slip_radius = 15.0 + point = x=-30,y=-80 + + repeat = 0 + + visual_hints = nextpt_color=yellow + visual_hints = nextpt_vertex_size=8 +// visual_hints = nextpt_lcolor=gray70 + visual_hints = nextpt_lcolor=off + visual_hints = vertex_color=dodger_blue, edge_color=white + visual_hints = vertex_size=5, edge_size=1 +} + +//---------------------------------------------- +Behavior = BHV_AvdColregsV22 +{ + name = avdcol_ + pwt = 150 + condition = AVOID = true + condition = MODE==ACTIVE + updates = CONTACT_INFO + templating = spawn + + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + + can_disable = true + exit_on_filter_group = true + + post_per_contact_info = true + + use_refinery = true + pwt_outer_dist = 30 + pwt_inner_dist = 20 + completed_dist = 35 + + min_util_cpa_dist = 12 + max_util_cpa_dist = 18 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 + bearing_line_label_show = false + } + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + spawnx_flag = RETURN_UPDATES=point=$[OSX],$[OSY] + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + point = 0,0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + inactiveflag = STATIONING = false + activeflag = STATIONING = true + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50, label_color=off +} + + diff --git a/src/test/missions/fixtures/berta_cmgr.ben/berta_cmgr.ben.alog.xz b/src/test/missions/fixtures/berta_cmgr.ben/berta_cmgr.ben.alog.xz new file mode 100644 index 0000000..ccc2103 Binary files /dev/null and b/src/test/missions/fixtures/berta_cmgr.ben/berta_cmgr.ben.alog.xz differ diff --git a/src/test/missions/fixtures/berta_cmgr.ben/berta_cmgr.ben.moos b/src/test/missions/fixtures/berta_cmgr.ben/berta_cmgr.ben.moos new file mode 100644 index 0000000..8a94746 --- /dev/null +++ b/src/test/missions/fixtures/berta_cmgr.ben/berta_cmgr.ben.moos @@ -0,0 +1,371 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_BEN_13_11_2026_____03_14_28/LOG_BEN_13_11_2026_____03_14_28._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178158672.84752 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//---------------------------------------------------- +// Vehicle MOOS config file +// M. Benjamin, MIT + +ServerHost = localhost +ServerPort = 9002 +Community = ben + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//---------------------------------------------------- +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 50 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePIDV22 @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = uMemWatch @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false + Run = pRealm @ NewConsole = false + + Run = uSimMarineV22 @ NewConsole = false + } + +//------------------------------------------------------ +// uSimMarineV22 Config Block + +ProcessConfig = uSimMarineV22 +{ + AppTick = 10 + CommsTick = 10 + + start_pos = x=-30,y=-80,heading=90, 0 + prefix = NAV + + //app_logging = true + max_speed = 2 + + turn_rate = 95 + turn_spd_loss = 0.6 + + post_des_thrust = DESIRED_THRUSTX + post_des_rudder = DESIRED_RUDDERX + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + + + +//-------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9202, white_list=DEPLOY & MOOS_MANUAL_OVERRIDE & NODE_BROKER_ACK & APPCAST_REQ +} + +//-------------------------------------------------- +// pHostInfo Config Block + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + default_hostip_force = localhost +} + +//-------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + nowatch = uMAC* + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB* + + summary_wait = 12 +} + + + +//---------------------------------------------------- +// pHelmIvP Config Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + behaviors = targ_ben.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:2:21 + + app_logging = true + + hold_on_apps = pContactMgrV20 +} + +//---------------------------------------------------- +// pNodeReporter Config Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + platform_color = red + vessel_type = kayak + //terse_reports = true + + coord_policy_global = true +} + +//-------------------------------------------------------- +// pContactMgrV20 Config Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + app_logging = true + + alert_verbose = true + + contact_local_coords = force_lat_lon + + contact_max_age = 35 + display_radii = true + display_radii_id = avd + alert_range_color = gray70 + cpa_range_color = gray30 + + early_warning_range = 60 + early_warning_flag = CMGR_WARNING = Warning=$[CONTACT], at $[RNG] + early_warning_ref_spd = 3.4 + early_warning_radii = true + + cease_warning_flag = CMGR_WARNING = off + + disable_var = XYZ_DISABLE_TARGET + enable_var = XYZ_REENABLE_TARGET + + post_closest_range = true + hold_alerts_for_helm = true +} + +//-------------------------------------------------- +// uFldNodeBroker Config Block + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + //shadow_shore = ip=192.168.7.22, name=henry, dur=45000 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=CMGR_WARNING + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//-------------------------------------------------- +// uLoadWatch Config Block + +ProcessConfig = uLoadWatch +{ + AppTick = 1 + CommsTick = 1 + + thresh = app=pHelmIvP, gapthresh=3 + thresh = app=pHostInfo, gapthresh=5 + thresh = app=any, gapthresh=2.0 + thresh = app=uMemWatch, gapthresh=50 + thresh = app=uSimMarineV22, gapthresh=3 + + breach_trigger = 5 +} + +//-------------------------------------------------------- +// uMemWatch Config Block + +ProcessConfig = uMemWatch +{ + AppTick = 0.4 + CommsTick = 0.4 + + absolute_time_gap = 2 + watch_only = pHelmIvP +} + +//----------------------------------------------------- +// pMarinePIDV22 Config Block + +ProcessConfig = pMarinePIDV22 +{ + AppTick = 10 + CommsTick = 10 + + verbose = true + depth_control = false + active_start = true + + // Yaw PID controller + yaw_pid_kp = 1.2 + yaw_pid_kd = 0.1 + yaw_pid_ki = 0.3 + yaw_pid_integral_limit = 0.07 + + // Speed PID controller + speed_pid_kp = 1.0 + speed_pid_kd = 0.0 + speed_pid_ki = 0.0 + speed_pid_integral_limit = 0.07 + + // Maximums + maxrudder = 100 + maxthrust = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + speed_factor = 20 +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CONTACT_INFO @ 0 NOSYNC + Log = CYCLE_INDEX @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = DIST_TO_STATION @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = PHELMIVP_ITER_GAP @ 0 NOSYNC + Log = PHELMIVP_ITER_LEN @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = PSKEEP_MODE @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATIONING @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = TRANSIT @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + Log = WPT_INDEX @ 0 NOSYNC + Log = WPT_ODO @ 0 NOSYNC + Log = WPT_STAT @ 0 NOSYNC + Log = WPT_UPDATE @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_BEN + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = BCM_ALERT_REQUEST @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true +// WildCardOmitPattern = DB_RWSUMMARY + + //WildCardOmitPattern = NAV_LAT, NAV_LONG + //WildCardOmitPattern = NODE_BROKER_PING_0, PSHARE* + + // WildCardOmitPattern = DB_CLIENTS + // WildCardOmitPattern = PHI_HOST*, NODE_REPORT_LOCAL +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/berta_cmgr.ben/targ_ben.bhv b/src/test/missions/fixtures/berta_cmgr.ben/targ_ben.bhv new file mode 100644 index 0000000..01bc625 --- /dev/null +++ b/src/test/missions/fixtures/berta_cmgr.ben/targ_ben.bhv @@ -0,0 +1,126 @@ +//------------------------------------------------- +// Vehicle Helm config file +// M. Benjamin, MIT + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize TRANSIT = true +initialize AVOID = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = TRANSITING { + MODE = ACTIVE + TRANSIT = true +} + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_transit + pwt = 100 + condition = MODE == TRANSITING + endflag = STATION_KEEP = true + + updates = WPT_UPDATE + perpetual = true + + speed = 3 // meters per second + capture_line = true + capture_radius = 5.0 + slip_radius = 15.0 + point = x=170,y=-80 + + repeat = 0 + + visual_hints = nextpt_color=yellow + visual_hints = nextpt_vertex_size=8 +// visual_hints = nextpt_lcolor=gray70 + visual_hints = nextpt_lcolor=off + visual_hints = vertex_color=dodger_blue, edge_color=white + visual_hints = vertex_size=5, edge_size=1 +} + +//---------------------------------------------- +Behavior = BHV_AvdColregsV22 +{ + name = avdcol_ + pwt = 150 + condition = AVOID = true + condition = MODE==ACTIVE + updates = CONTACT_INFO + templating = spawn + + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + + can_disable = true + exit_on_filter_group = true + + post_per_contact_info = true + + use_refinery = true + pwt_outer_dist = 30 + pwt_inner_dist = 20 + completed_dist = 35 + + min_util_cpa_dist = 12 + max_util_cpa_dist = 18 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 + bearing_line_label_show = false + } + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + spawnx_flag = RETURN_UPDATES=point=$[OSX],$[OSY] + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + point = 0,0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + inactiveflag = STATIONING = false + activeflag = STATIONING = true + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50, label_color=off +} + + diff --git a/src/test/missions/fixtures/m15_pursuit.chaser/m15_pursuit.chaser.alog.xz b/src/test/missions/fixtures/m15_pursuit.chaser/m15_pursuit.chaser.alog.xz new file mode 100644 index 0000000..711ebca Binary files /dev/null and b/src/test/missions/fixtures/m15_pursuit.chaser/m15_pursuit.chaser.alog.xz differ diff --git a/src/test/missions/fixtures/m15_pursuit.chaser/m15_pursuit.chaser.moos b/src/test/missions/fixtures/m15_pursuit.chaser/m15_pursuit.chaser.moos new file mode 100644 index 0000000..7ea0bbf --- /dev/null +++ b/src/test/missions/fixtures/m15_pursuit.chaser/m15_pursuit.chaser.moos @@ -0,0 +1,360 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_CHASER_13_11_2026_____03_19_37/LOG_CHASER_13_11_2026_____03_19_37._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178159910.395224 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//------------------------------------------------- +// NAME: M. Benjamin, MIT +// FILE: chaser.moos +//------------------------------------------------- + +ServerHost = localhost +ServerPort = 9001 +Community = chaser + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//------------------------------------------------------------ +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 100 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = uSimMarineV22 @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePID @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = uMemWatch @ NewConsole = false + Run = iSay @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false +} + +//-------------------------------------------------------- +// uMemWatch Configuration Block (Created from Plugin) + +ProcessConfig = uMemWatch +{ + AppTick = 0.4 + CommsTick = 0.4 + + absolute_time_gap = 2 + watch_only = pHelmIvP +} + + + +//--------------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9201 +} + + +//-------------------------------------------------- +// pHostInfo configuration block from plugin + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + DEFAULT_HOSTIP_FORCE = localhost +} + + +//------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + + nowatch = uMAC* + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB + + summary_wait = 10 +} + + + + +//---------------------------------------------------- +// pHelmIvP Configuration Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + app_logging = true + + behaviors = targ_chaser.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:5:26 + + hold_on_apps = pContactMgrV20 +} + +//-------------------------------------------------------- +// pNodeReporter Configuration Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + vessel_type = kayak + terse_reports = true +} + +//-------------------------------------------------------- +// pContactMgrV20 Configuration Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + alert_verbose = true + + contact_max_age = 35 + display_radii = true + display_radii_id = avd + + match_region = pts = {60,-40 : 60,-160 : 150,-160 : 180,-100 : 150,-40} + match_type = kayak, uuv + + alert = id=say, onflag=SAY_MOOS=hello, + alert = id=say, offflag=SAY_MOOS=bye, + alert = id=say, alert_range=180, cpa_range=200 + + display_radii = true + alert_range_color = gray70 + cpa_range_color = gray30 +} + +//-------------------------------------------------- +// uFldNodeBroker configuration block from plugin + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=APPCAST + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//----------------------------------------------------- +// pMarinePID Config Block + +ProcessConfig = pMarinePID +{ + AppTick = 10 + CommsTick = 10 + + deprecated_ok = true + + VERBOSE = true + DEPTH_CONTROL = false + ACTIVE_START = true + + // Yaw PID controller + YAW_PID_KP = 0.4 + YAW_PID_KD = 0.1 + YAW_PID_KI = 0.0 + YAW_PID_INTEGRAL_LIMIT = 0.07 + + // Speed PID controller + SPEED_PID_KP = 1.0 + SPEED_PID_KD = 0.0 + SPEED_PID_KI = 0.0 + SPEED_PID_INTEGRAL_LIMIT = 0.07 + + // Maximums + MAXRUDDER = 100 + MAXTHRUST = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + SPEED_FACTOR = 20 +} + +//---------------------------------------- +// uSimMarineV22 Config Block + +ProcessConfig = uSimMarineV22 +{ + AppTick = 10 + CommsTick = 10 + + start_pos = 0,0, 180, 0 + prefix = NAV + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + +//-------------------------------------------------------- +// iSay Config Block + +ProcessConfig = iSay +{ + AppTick = 4 + CommsTick = 4 + + default_voice = alex // iSay --voices for others + default_rate = 200 + //interval_policy = from_end // or from_start + interval_policy = from_start // or from_start + min_utter_interval = 1 + + os_mode = osx // Default is "osx" +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_ERROR @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CHASE @ 0 NOSYNC + Log = CYCLE_INDEX @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = DIST_TO_STATION @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_COUNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CONTACT_SUMMARY @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = MAX_SPEED_UPDATES @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = PSKEEP_MODE @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATIONING @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = SURVEY @ 0 NOSYNC + Log = TAGGED_EVADER @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = UPDATES_CUT @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + Log = WPT_EFF_DIST_ALL @ 0 NOSYNC + Log = WPT_EFF_DIST_LEG @ 0 NOSYNC + Log = WPT_EFF_SUMM_ALL @ 0 NOSYNC + Log = WPT_EFF_SUMM_LEG @ 0 NOSYNC + Log = WPT_EFF_TIME_ALL @ 0 NOSYNC + Log = WPT_EFF_TIME_LEG @ 0 NOSYNC + Log = WPT_INDEX @ 0 NOSYNC + Log = WPT_ODO @ 0 NOSYNC + Log = WPT_STAT @ 0 NOSYNC + Log = WPT_UPDATE @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_CHASER + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = BCM_ALERT_REQUEST @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true + + +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/m15_pursuit.chaser/targ_chaser.bhv b/src/test/missions/fixtures/m15_pursuit.chaser/targ_chaser.bhv new file mode 100644 index 0000000..32c701a --- /dev/null +++ b/src/test/missions/fixtures/m15_pursuit.chaser/targ_chaser.bhv @@ -0,0 +1,102 @@ +//--------------------------------------------------- +// Helm Behavior file + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize CHASE = true +initialize AVOID = true +initialize TAGGED_EVADER = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = CHASING { + MODE = ACTIVE + CHASE = true +} + +//---------------------------------------------- +Behavior = BHV_CutRange +{ + name = cut_range + pwt = 100 + condition = MODE==CHASING + condition = TAGGED_$[CONTACT] = true + + templating = spawn + + updates = UPDATES_CUT + + duration = 10 + //contact = evader + + pursueflag = SAY_MOOS=go + giveupflag = SAY_MOOS=dang + + pwt_outer_dist = 100 + pwt_inner_dist = 5 + giveup_dist = 110 + patience = 100 +} + +//---------------------------------------------- +Behavior = BHV_MaxSpeed +{ + name = max_spd + pwt = 500 + updates = MAX_SPEED_UPDATES + condition = MODE==ACTIVE + + max_speed = 3.6 + tolerance = 0.2 +} + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + points = 0,0 + repeat = 0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + inactiveflag = STATIONING = false + activeflag = STATIONING = true + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50 +} + diff --git a/src/test/missions/fixtures/m15_pursuit.evader/m15_pursuit.evader.alog.xz b/src/test/missions/fixtures/m15_pursuit.evader/m15_pursuit.evader.alog.xz new file mode 100644 index 0000000..5fb914c Binary files /dev/null and b/src/test/missions/fixtures/m15_pursuit.evader/m15_pursuit.evader.alog.xz differ diff --git a/src/test/missions/fixtures/m15_pursuit.evader/m15_pursuit.evader.moos b/src/test/missions/fixtures/m15_pursuit.evader/m15_pursuit.evader.moos new file mode 100644 index 0000000..df73e16 --- /dev/null +++ b/src/test/missions/fixtures/m15_pursuit.evader/m15_pursuit.evader.moos @@ -0,0 +1,360 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_EVADER_13_11_2026_____03_19_37/LOG_EVADER_13_11_2026_____03_19_37._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178159910.40008 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//------------------------------------------------- +// NAME: M. Benjamin, MIT +// FILE: evader.moos +//------------------------------------------------- + +ServerHost = localhost +ServerPort = 9002 +Community = evader + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//------------------------------------------------------------ +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 100 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = uSimMarineV22 @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePID @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = uMemWatch @ NewConsole = false + Run = iSay @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false +} + +//-------------------------------------------------------- +// uMemWatch Configuration Block (Created from Plugin) + +ProcessConfig = uMemWatch +{ + AppTick = 0.4 + CommsTick = 0.4 + + absolute_time_gap = 2 + watch_only = pHelmIvP +} + + + +//--------------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9202 +} + + +//-------------------------------------------------- +// pHostInfo configuration block from plugin + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + DEFAULT_HOSTIP_FORCE = localhost +} + + +//------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + + nowatch = uMAC* + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB + + summary_wait = 10 +} + + + + +//---------------------------------------------------- +// pHelmIvP Configuration Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + app_logging = true + + behaviors = targ_evader.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:5:26 + + hold_on_apps = pContactMgrV20 +} + +//-------------------------------------------------------- +// pNodeReporter Configuration Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + vessel_type = kayak + terse_reports = true +} + +//-------------------------------------------------------- +// pContactMgrV20 Configuration Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + alert_verbose = true + + contact_max_age = 35 + display_radii = true + display_radii_id = avd + + match_region = pts = {60,-40 : 60,-160 : 150,-160 : 180,-100 : 150,-40} + match_type = kayak, uuv + + alert = id=say, onflag=SAY_MOOS=hello, + alert = id=say, offflag=SAY_MOOS=bye, + alert = id=say, alert_range=180, cpa_range=200 + + display_radii = true + alert_range_color = gray70 + cpa_range_color = gray30 +} + +//-------------------------------------------------- +// uFldNodeBroker configuration block from plugin + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=APPCAST + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//----------------------------------------------------- +// pMarinePID Config Block + +ProcessConfig = pMarinePID +{ + AppTick = 10 + CommsTick = 10 + + deprecated_ok = true + + VERBOSE = true + DEPTH_CONTROL = false + ACTIVE_START = true + + // Yaw PID controller + YAW_PID_KP = 0.4 + YAW_PID_KD = 0.1 + YAW_PID_KI = 0.0 + YAW_PID_INTEGRAL_LIMIT = 0.07 + + // Speed PID controller + SPEED_PID_KP = 1.0 + SPEED_PID_KD = 0.0 + SPEED_PID_KI = 0.0 + SPEED_PID_INTEGRAL_LIMIT = 0.07 + + // Maximums + MAXRUDDER = 100 + MAXTHRUST = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + SPEED_FACTOR = 20 +} + +//---------------------------------------- +// uSimMarineV22 Config Block + +ProcessConfig = uSimMarineV22 +{ + AppTick = 10 + CommsTick = 10 + + start_pos = 180,0, 180, 0 + prefix = NAV + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + +//-------------------------------------------------------- +// iSay Config Block + +ProcessConfig = iSay +{ + AppTick = 4 + CommsTick = 4 + + default_voice = alex // iSay --voices for others + default_rate = 200 + //interval_policy = from_end // or from_start + interval_policy = from_start // or from_start + min_utter_interval = 1 + + os_mode = osx // Default is "osx" +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_ERROR @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CHASE @ 0 NOSYNC + Log = CYCLE_INDEX @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = DIST_TO_STATION @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_COUNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CONTACT_SUMMARY @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = MAX_SPEED_UPDATES @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = PSKEEP_MODE @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATIONING @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = SURVEY @ 0 NOSYNC + Log = TAGGED_EVADER @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = UPDATES_CUT @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + Log = WPT_EFF_DIST_ALL @ 0 NOSYNC + Log = WPT_EFF_DIST_LEG @ 0 NOSYNC + Log = WPT_EFF_SUMM_ALL @ 0 NOSYNC + Log = WPT_EFF_SUMM_LEG @ 0 NOSYNC + Log = WPT_EFF_TIME_ALL @ 0 NOSYNC + Log = WPT_EFF_TIME_LEG @ 0 NOSYNC + Log = WPT_INDEX @ 0 NOSYNC + Log = WPT_ODO @ 0 NOSYNC + Log = WPT_STAT @ 0 NOSYNC + Log = WPT_UPDATE @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_EVADER + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = BCM_ALERT_REQUEST @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true + + +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/m15_pursuit.evader/targ_evader.bhv b/src/test/missions/fixtures/m15_pursuit.evader/targ_evader.bhv new file mode 100644 index 0000000..f57ca5a --- /dev/null +++ b/src/test/missions/fixtures/m15_pursuit.evader/targ_evader.bhv @@ -0,0 +1,100 @@ +//--------------------------------------------------- +// Helm Behavior file + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize SURVEY = true +initialize AVOID = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = SURVEYING { + MODE = ACTIVE + SURVEY = true +} + + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_survey + pwt = 100 + condition = RETURN = false + condition = DEPLOY = true + endflag = RETURN = true + + updates = WPT_UPDATE + perpetual = true + + lead = 8 + lead_damper = 1 + lead_to_start = true + speed = 4 // meters per second + capture_line = true + capture_radius = 5.0 + slip_radius = 15.0 + efficiency_measure = all + + polygon = 60,-40 : 60,-160 : 150,-160 : 180,-100 : 150,-40 + + order = normal + repeat = 3 + + visual_hints = nextpt_color=yellow + visual_hints = nextpt_vertex_size=8 + visual_hints = nextpt_lcolor=gray70 + visual_hints = vertex_color=dodger_blue, edge_color=white + visual_hints = vertex_size=5, edge_size=1 +} + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + points = 180,0 + repeat = 0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + inactiveflag = STATIONING = false + activeflag = STATIONING = true + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50 +} + + diff --git a/src/test/missions/fixtures/m2_berta.abe/m2_berta.abe.alog.xz b/src/test/missions/fixtures/m2_berta.abe/m2_berta.abe.alog.xz new file mode 100644 index 0000000..76a252c Binary files /dev/null and b/src/test/missions/fixtures/m2_berta.abe/m2_berta.abe.alog.xz differ diff --git a/src/test/missions/fixtures/m2_berta.abe/m2_berta.abe.moos b/src/test/missions/fixtures/m2_berta.abe/m2_berta.abe.moos new file mode 100644 index 0000000..e55de3d --- /dev/null +++ b/src/test/missions/fixtures/m2_berta.abe/m2_berta.abe.moos @@ -0,0 +1,405 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_ABE_13_11_2026_____03_09_15/LOG_ABE_13_11_2026_____03_09_15._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178157422.238072 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//------------------------------------------------- +// Vehicle MOOS config file +// M. Benjamin, MIT + +ServerHost = localhost +ServerPort = 9001 +Community = abe + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//---------------------------------------------------- +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 50 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePIDV22 @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = uMemWatch @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false + Run = pRealm @ NewConsole = false + + Run = uSimMarineV22 @ NewConsole = false + } + +//------------------------------------------------------ +// uSimMarineV22 Config Block + +ProcessConfig = uSimMarineV22 +{ + AppTick = 10 + CommsTick = 10 + + start_pos = x=0,y=0,heading=180, 0 + prefix = NAV + + //app_logging = true + max_speed = 2 + + turn_rate = 95 + turn_spd_loss = 0.6 + + post_des_thrust = DESIRED_THRUSTX + post_des_rudder = DESIRED_RUDDERX + + post_navpos_summary = true + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + + + +//-------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9201 +// input = route = localhost:9201, white_list=DEPLOY & MOOS_MANUAL_OVERRIDE & NODE_BROKER_ACK & APPCAST_REQ +} + +//-------------------------------------------------- +// pHostInfo Config Block + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + default_hostip_force = localhost +} + +//-------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + nowatch = uMAC* + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB* + + summary_wait = 12 +} + + + +//---------------------------------------------------- +// pHelmIvP Config Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + behaviors = targ_abe.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:2:21 + + app_logging = true + + hold_on_apps = pContactMgrV20 +} + +//---------------------------------------------------- +// pNodeReporter Config Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + platform_color = yellow + vessel_type = kayak + //terse_reports = true + + //json_report = NODE_REPORT_JSON + + coord_policy_global = true +} + +//-------------------------------------------------------- +// pContactMgrV20 Config Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + app_logging = true + + alert_verbose = true + + contact_local_coords = force_lat_lon + + contact_max_age = 35 + display_radii = true + display_radii_id = avd + alert_range_color = gray70 + cpa_range_color = gray30 + + alert = id=avdcol_, var=CONTACT_INFO, val="name=$[VNAME] # contact=$[VNAME]" + alert = id=avdcol_, alert_range=15, cpa_range=5 + + //match_region = pts = {60,-40 : 60,-160 : 150,-160 : 180,-100 : 150,-40} + //match_type = kayak, uuv + + disable_var = XYZ_DISABLE_TARGET + enable_var = XYZ_REENABLE_TARGET + + post_closest_range = true + hold_alerts_for_helm = true +} + +//-------------------------------------------------- +// uFldNodeBroker Config Block + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + //shadow_shore = ip=192.168.7.22, name=henry, dur=45000 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//-------------------------------------------------- +// uLoadWatch Config Block + +ProcessConfig = uLoadWatch +{ + AppTick = 1 + CommsTick = 1 + + thresh = app=pHelmIvP, gapthresh=3 + thresh = app=pHostInfo, gapthresh=5 + thresh = app=any, gapthresh=2.0 + thresh = app=uMemWatch, gapthresh=50 + thresh = app=uSimMarineV22, gapthresh=3 + + breach_trigger = 5 +} + +//-------------------------------------------------------- +// uMemWatch Config Block + +ProcessConfig = uMemWatch +{ + AppTick = 0.4 + CommsTick = 0.4 + + absolute_time_gap = 2 + watch_only = pHelmIvP +} + +//----------------------------------------------------- +// pMarinePIDV22 Config Block + +ProcessConfig = pMarinePIDV22 +{ + AppTick = 10 + CommsTick = 10 + + verbose = true + depth_control = false + active_start = true + + // Yaw PID controller + yaw_pid_kp = 1.2 + yaw_pid_kd = 0.1 + yaw_pid_ki = 0.3 + yaw_pid_integral_limit = 0.07 + + // Speed PID controller + speed_pid_kp = 1.0 + speed_pid_kd = 0.0 + speed_pid_ki = 0.0 + speed_pid_integral_limit = 0.07 + + // Maximums + maxrudder = 100 + maxthrust = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + speed_factor = 20 +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVDCOL_RANGE_ABE @ 0 NOSYNC + Log = AVDCOL_RANGE_BEN @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CN_CROSSED_OS_PORT_STAR_ABE @ 0 NOSYNC + Log = CN_CROSSED_OS_PORT_STAR_BEN @ 0 NOSYNC + Log = CN_FORE_OF_OS_ABE @ 0 NOSYNC + Log = CN_FORE_OF_OS_BEN @ 0 NOSYNC + Log = CN_PORT_OF_OS__ABE @ 0 NOSYNC + Log = CN_PORT_OF_OS__BEN @ 0 NOSYNC + Log = COL22_AVOID_MODE_ABE @ 0 NOSYNC + Log = COL22_AVOID_MODE_BEN @ 0 NOSYNC + Log = COL22_RELEVANCE_ABE @ 0 NOSYNC + Log = COL22_RELEVANCE_BEN @ 0 NOSYNC + Log = COLREGS_AVOID_IX_ABE @ 0 NOSYNC + Log = COLREGS_AVOID_IX_BEN @ 0 NOSYNC + Log = COLREGS_AVOID_MODE_ABE @ 0 NOSYNC + Log = COLREGS_AVOID_MODE_BEN @ 0 NOSYNC + Log = COLREGS_AVOID_PWT_ABE @ 0 NOSYNC + Log = COLREGS_AVOID_PWT_BEN @ 0 NOSYNC + Log = COLREGS_CONTACT_HDG_ABE @ 0 NOSYNC + Log = COLREGS_CONTACT_HDG_BEN @ 0 NOSYNC + Log = COLREGS_SUMMARY_ABE @ 0 NOSYNC + Log = COLREGS_SUMMARY_BEN @ 0 NOSYNC + Log = CONTACT_INFO @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = HEADON_DEBUG_ABE @ 0 NOSYNC + Log = HEADON_DEBUG_BEN @ 0 NOSYNC + Log = INFO @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_COUNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CONTACT_SUMMARY @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = LOITER @ 0 NOSYNC + Log = LOITER_ACQUIRE_A @ 0 NOSYNC + Log = LOITER_DIST_TO_POLY_A @ 0 NOSYNC + Log = LOITER_DIST_TO_VERT @ 0 NOSYNC + Log = LOITER_ETA_TO_POLY_A @ 0 NOSYNC + Log = LOITER_INDEX_A @ 0 NOSYNC + Log = LOITER_MODE_A @ 0 NOSYNC + Log = LOITER_REPORT_A @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_HEADING @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = PHELMIVP_ITER_GAP @ 0 NOSYNC + Log = PHELMIVP_ITER_LEN @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATIONING @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = STATUS @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = UP_LOITER @ 0 NOSYNC + Log = VEHICLE_UNDERWAY @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_ABE + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = BCM_ALERT_REQUEST @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true +// WildCardOmitPattern = DB_RWSUMMARY + + //WildCardOmitPattern = NAV_LAT, NAV_LONG + //WildCardOmitPattern = NODE_BROKER_PING_0, PSHARE* + + // WildCardOmitPattern = DB_CLIENTS + // WildCardOmitPattern = PHI_HOST*, NODE_REPORT_LOCAL +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/m2_berta.abe/targ_abe.bhv b/src/test/missions/fixtures/m2_berta.abe/targ_abe.bhv new file mode 100644 index 0000000..4216efb --- /dev/null +++ b/src/test/missions/fixtures/m2_berta.abe/targ_abe.bhv @@ -0,0 +1,172 @@ +//------------------------------------------------- +// Vehicle Helm config file +// M. Benjamin, MIT + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize LOITER = true +initialize AVOID = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = LOITERING { + MODE = ACTIVE + LOITER = true +} + + +//---------------------------------------------- +Behavior = BHV_Loiter +{ + name = loiter + pwt = 100 + condition = MODE==LOITERING + updates = UP_LOITER + runflag = VEHICLE_UNDERWAY = TRUE + endflag = VEHICLE_UNDERWAY = FALSE + + ipf_type = zaic_spd + + post_suffix = A + speed = 2 + clockwise = false + radius = 8.0 + nm_radius = 15.0 + polygon = radial:: x=0,y=-75, radius=20, pts=8, snap=1, label=abe_LOITER + visual_hints = nextpt_color=white, nextpt_lcolor=khaki + visual_hints = edge_color=orange, vertex_color=white + visual_hints = edge_size=1, vertex_size=2 +} + +//---------------------------------------------- +Behavior = BHV_AvdColregsV22 +{ + name = avdcol_ + pwt = 150 + condition = AVOID = true + condition = MODE==ACTIVE + updates = CONTACT_INFO + templating = spawn + + spawnxflag = INFO=os=$[OWNSHIP],utc=$[UTC],range=$[RANGE],contact=$[CONTACT],cn_os_rel_bng=$[CN_OS_REL_BNG],os_cn_rel_bng=$[OS_CN_REL_BNG] + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + + runxflag = STATUS={"TargetId":"$[CN_NAME]", "Priority":"$[APWT]", "Mode":"$[FULL_MODE]", "ModeId":"$[MODE_ID]"} + + //match_group = alpha + // match_type = mokai + + can_disable = true + + exit_on_filter_group = true + + post_per_contact_info = true + + use_refinery = true + + // pwt_outer_dist = 15 + // pwt_inner_dist = 5 + // completed_dist = 20 + pwt_outer_dist = 80 + pwt_inner_dist = 50 + completed_dist = 85 + + min_util_cpa_dist = 10 + max_util_cpa_dist = 18 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 +} + +//---------------------------------------------- +//Behavior = BHV_AvoidCollision +{ + name = ac_ + pwt = 500 + condition = AVOID = true + updates = CONTACT_INFO + + activeflag = AVOIDING = active + inactiveflag = AVOIDING = inactive + runflag = AVOIDING = running + endflag = AVOIDING = end + + templating = spawn + + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + +// cnflag = @<20 SAY_MOOS=hello + cnflag = @<20 ROC=$[ROC] + cnflag = @<20 OS_PORT_OF_CN = $[OS_PORT_OF_CN] + cnflag = @<20 OS_STAR_OF_CN = $[OS_STAR_OF_CN] + cnflag = @<20 OS_AFT_OF_CN = $[OS_AFT_OF_CN] + cnflag = @<20 OS_FORE_OF_CN = $[OS_FORE_OF_CN] +// cnflag = @>39 SAY_MOOS=bye + + use_refinery = true + + pwt_outer_dist = 75 + pwt_inner_dist = 11 + completed_dist = 80 + min_util_cpa_dist = 8 + max_util_cpa_dist = 15 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 +} + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + spawnx_flag = RETURN_UPDATES=point=$[OSX],$[OSY] + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + point = 0,0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + inactiveflag = STATIONING = false + activeflag = STATIONING = true + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50 +} + + diff --git a/src/test/missions/fixtures/m2_berta.ben/m2_berta.ben.alog.xz b/src/test/missions/fixtures/m2_berta.ben/m2_berta.ben.alog.xz new file mode 100644 index 0000000..d49786e Binary files /dev/null and b/src/test/missions/fixtures/m2_berta.ben/m2_berta.ben.alog.xz differ diff --git a/src/test/missions/fixtures/m2_berta.ben/m2_berta.ben.moos b/src/test/missions/fixtures/m2_berta.ben/m2_berta.ben.moos new file mode 100644 index 0000000..ca7b05a --- /dev/null +++ b/src/test/missions/fixtures/m2_berta.ben/m2_berta.ben.moos @@ -0,0 +1,405 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_BEN_13_11_2026_____03_09_15/LOG_BEN_13_11_2026_____03_09_15._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178157422.238176 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//------------------------------------------------- +// Vehicle MOOS config file +// M. Benjamin, MIT + +ServerHost = localhost +ServerPort = 9002 +Community = ben + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//---------------------------------------------------- +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 50 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePIDV22 @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = uMemWatch @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false + Run = pRealm @ NewConsole = false + + Run = uSimMarineV22 @ NewConsole = false + } + +//------------------------------------------------------ +// uSimMarineV22 Config Block + +ProcessConfig = uSimMarineV22 +{ + AppTick = 10 + CommsTick = 10 + + start_pos = x=180,y=0,heading=180, 0 + prefix = NAV + + //app_logging = true + max_speed = 2 + + turn_rate = 95 + turn_spd_loss = 0.6 + + post_des_thrust = DESIRED_THRUSTX + post_des_rudder = DESIRED_RUDDERX + + post_navpos_summary = true + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + + + +//-------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9202 +// input = route = localhost:9202, white_list=DEPLOY & MOOS_MANUAL_OVERRIDE & NODE_BROKER_ACK & APPCAST_REQ +} + +//-------------------------------------------------- +// pHostInfo Config Block + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + default_hostip_force = localhost +} + +//-------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + nowatch = uMAC* + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB* + + summary_wait = 12 +} + + + +//---------------------------------------------------- +// pHelmIvP Config Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + behaviors = targ_ben.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:2:21 + + app_logging = true + + hold_on_apps = pContactMgrV20 +} + +//---------------------------------------------------- +// pNodeReporter Config Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + platform_color = red + vessel_type = kayak + //terse_reports = true + + //json_report = NODE_REPORT_JSON + + coord_policy_global = true +} + +//-------------------------------------------------------- +// pContactMgrV20 Config Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + app_logging = true + + alert_verbose = true + + contact_local_coords = force_lat_lon + + contact_max_age = 35 + display_radii = true + display_radii_id = avd + alert_range_color = gray70 + cpa_range_color = gray30 + + alert = id=avdcol_, var=CONTACT_INFO, val="name=$[VNAME] # contact=$[VNAME]" + alert = id=avdcol_, alert_range=15, cpa_range=5 + + //match_region = pts = {60,-40 : 60,-160 : 150,-160 : 180,-100 : 150,-40} + //match_type = kayak, uuv + + disable_var = XYZ_DISABLE_TARGET + enable_var = XYZ_REENABLE_TARGET + + post_closest_range = true + hold_alerts_for_helm = true +} + +//-------------------------------------------------- +// uFldNodeBroker Config Block + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + //shadow_shore = ip=192.168.7.22, name=henry, dur=45000 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//-------------------------------------------------- +// uLoadWatch Config Block + +ProcessConfig = uLoadWatch +{ + AppTick = 1 + CommsTick = 1 + + thresh = app=pHelmIvP, gapthresh=3 + thresh = app=pHostInfo, gapthresh=5 + thresh = app=any, gapthresh=2.0 + thresh = app=uMemWatch, gapthresh=50 + thresh = app=uSimMarineV22, gapthresh=3 + + breach_trigger = 5 +} + +//-------------------------------------------------------- +// uMemWatch Config Block + +ProcessConfig = uMemWatch +{ + AppTick = 0.4 + CommsTick = 0.4 + + absolute_time_gap = 2 + watch_only = pHelmIvP +} + +//----------------------------------------------------- +// pMarinePIDV22 Config Block + +ProcessConfig = pMarinePIDV22 +{ + AppTick = 10 + CommsTick = 10 + + verbose = true + depth_control = false + active_start = true + + // Yaw PID controller + yaw_pid_kp = 1.2 + yaw_pid_kd = 0.1 + yaw_pid_ki = 0.3 + yaw_pid_integral_limit = 0.07 + + // Speed PID controller + speed_pid_kp = 1.0 + speed_pid_kd = 0.0 + speed_pid_ki = 0.0 + speed_pid_integral_limit = 0.07 + + // Maximums + maxrudder = 100 + maxthrust = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + speed_factor = 20 +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVDCOL_RANGE_ABE @ 0 NOSYNC + Log = AVDCOL_RANGE_BEN @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CN_CROSSED_OS_PORT_STAR_ABE @ 0 NOSYNC + Log = CN_CROSSED_OS_PORT_STAR_BEN @ 0 NOSYNC + Log = CN_FORE_OF_OS_ABE @ 0 NOSYNC + Log = CN_FORE_OF_OS_BEN @ 0 NOSYNC + Log = CN_PORT_OF_OS__ABE @ 0 NOSYNC + Log = CN_PORT_OF_OS__BEN @ 0 NOSYNC + Log = COL22_AVOID_MODE_ABE @ 0 NOSYNC + Log = COL22_AVOID_MODE_BEN @ 0 NOSYNC + Log = COL22_RELEVANCE_ABE @ 0 NOSYNC + Log = COL22_RELEVANCE_BEN @ 0 NOSYNC + Log = COLREGS_AVOID_IX_ABE @ 0 NOSYNC + Log = COLREGS_AVOID_IX_BEN @ 0 NOSYNC + Log = COLREGS_AVOID_MODE_ABE @ 0 NOSYNC + Log = COLREGS_AVOID_MODE_BEN @ 0 NOSYNC + Log = COLREGS_AVOID_PWT_ABE @ 0 NOSYNC + Log = COLREGS_AVOID_PWT_BEN @ 0 NOSYNC + Log = COLREGS_CONTACT_HDG_ABE @ 0 NOSYNC + Log = COLREGS_CONTACT_HDG_BEN @ 0 NOSYNC + Log = COLREGS_SUMMARY_ABE @ 0 NOSYNC + Log = COLREGS_SUMMARY_BEN @ 0 NOSYNC + Log = CONTACT_INFO @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = HEADON_DEBUG_ABE @ 0 NOSYNC + Log = HEADON_DEBUG_BEN @ 0 NOSYNC + Log = INFO @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_COUNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CONTACT_SUMMARY @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = LOITER @ 0 NOSYNC + Log = LOITER_ACQUIRE_A @ 0 NOSYNC + Log = LOITER_DIST_TO_POLY_A @ 0 NOSYNC + Log = LOITER_DIST_TO_VERT @ 0 NOSYNC + Log = LOITER_ETA_TO_POLY_A @ 0 NOSYNC + Log = LOITER_INDEX_A @ 0 NOSYNC + Log = LOITER_MODE_A @ 0 NOSYNC + Log = LOITER_REPORT_A @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_HEADING @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = PHELMIVP_ITER_GAP @ 0 NOSYNC + Log = PHELMIVP_ITER_LEN @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATIONING @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = STATUS @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = UP_LOITER @ 0 NOSYNC + Log = VEHICLE_UNDERWAY @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_BEN + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = BCM_ALERT_REQUEST @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true +// WildCardOmitPattern = DB_RWSUMMARY + + //WildCardOmitPattern = NAV_LAT, NAV_LONG + //WildCardOmitPattern = NODE_BROKER_PING_0, PSHARE* + + // WildCardOmitPattern = DB_CLIENTS + // WildCardOmitPattern = PHI_HOST*, NODE_REPORT_LOCAL +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/m2_berta.ben/targ_ben.bhv b/src/test/missions/fixtures/m2_berta.ben/targ_ben.bhv new file mode 100644 index 0000000..4598808 --- /dev/null +++ b/src/test/missions/fixtures/m2_berta.ben/targ_ben.bhv @@ -0,0 +1,172 @@ +//------------------------------------------------- +// Vehicle Helm config file +// M. Benjamin, MIT + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize LOITER = true +initialize AVOID = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = LOITERING { + MODE = ACTIVE + LOITER = true +} + + +//---------------------------------------------- +Behavior = BHV_Loiter +{ + name = loiter + pwt = 100 + condition = MODE==LOITERING + updates = UP_LOITER + runflag = VEHICLE_UNDERWAY = TRUE + endflag = VEHICLE_UNDERWAY = FALSE + + ipf_type = zaic_spd + + post_suffix = A + speed = 2 + clockwise = false + radius = 8.0 + nm_radius = 15.0 + polygon = radial:: x=125,y=-50, radius=20, pts=8, snap=1, label=ben_LOITER + visual_hints = nextpt_color=white, nextpt_lcolor=khaki + visual_hints = edge_color=orange, vertex_color=white + visual_hints = edge_size=1, vertex_size=2 +} + +//---------------------------------------------- +Behavior = BHV_AvdColregsV22 +{ + name = avdcol_ + pwt = 150 + condition = AVOID = true + condition = MODE==ACTIVE + updates = CONTACT_INFO + templating = spawn + + spawnxflag = INFO=os=$[OWNSHIP],utc=$[UTC],range=$[RANGE],contact=$[CONTACT],cn_os_rel_bng=$[CN_OS_REL_BNG],os_cn_rel_bng=$[OS_CN_REL_BNG] + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + + runxflag = STATUS={"TargetId":"$[CN_NAME]", "Priority":"$[APWT]", "Mode":"$[FULL_MODE]", "ModeId":"$[MODE_ID]"} + + //match_group = alpha + // match_type = mokai + + can_disable = true + + exit_on_filter_group = true + + post_per_contact_info = true + + use_refinery = true + + // pwt_outer_dist = 15 + // pwt_inner_dist = 5 + // completed_dist = 20 + pwt_outer_dist = 80 + pwt_inner_dist = 50 + completed_dist = 85 + + min_util_cpa_dist = 10 + max_util_cpa_dist = 18 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 +} + +//---------------------------------------------- +//Behavior = BHV_AvoidCollision +{ + name = ac_ + pwt = 500 + condition = AVOID = true + updates = CONTACT_INFO + + activeflag = AVOIDING = active + inactiveflag = AVOIDING = inactive + runflag = AVOIDING = running + endflag = AVOIDING = end + + templating = spawn + + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + +// cnflag = @<20 SAY_MOOS=hello + cnflag = @<20 ROC=$[ROC] + cnflag = @<20 OS_PORT_OF_CN = $[OS_PORT_OF_CN] + cnflag = @<20 OS_STAR_OF_CN = $[OS_STAR_OF_CN] + cnflag = @<20 OS_AFT_OF_CN = $[OS_AFT_OF_CN] + cnflag = @<20 OS_FORE_OF_CN = $[OS_FORE_OF_CN] +// cnflag = @>39 SAY_MOOS=bye + + use_refinery = true + + pwt_outer_dist = 75 + pwt_inner_dist = 11 + completed_dist = 80 + min_util_cpa_dist = 8 + max_util_cpa_dist = 15 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 +} + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + spawnx_flag = RETURN_UPDATES=point=$[OSX],$[OSY] + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + point = 0,0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + inactiveflag = STATIONING = false + activeflag = STATIONING = true + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50 +} + + diff --git a/src/test/missions/fixtures/m34_bo_alpha.abe/m34_bo_alpha.abe.alog.xz b/src/test/missions/fixtures/m34_bo_alpha.abe/m34_bo_alpha.abe.alog.xz new file mode 100644 index 0000000..cfc64ac Binary files /dev/null and b/src/test/missions/fixtures/m34_bo_alpha.abe/m34_bo_alpha.abe.alog.xz differ diff --git a/src/test/missions/fixtures/m34_bo_alpha.abe/m34_bo_alpha.abe.moos b/src/test/missions/fixtures/m34_bo_alpha.abe/m34_bo_alpha.abe.moos new file mode 100644 index 0000000..fe53a02 --- /dev/null +++ b/src/test/missions/fixtures/m34_bo_alpha.abe/m34_bo_alpha.abe.moos @@ -0,0 +1,361 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_ABE_13_11_2026_____03_29_55/LOG_ABE_13_11_2026_____03_29_55._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178162379.435092 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//------------------------------------------------- +// NAME: M. Benjamin, MIT +// FILE: abe.moos +//------------------------------------------------- +ServerHost = localhost +ServerPort = 9001 +Community = abe + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//------------------------------------------------- +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 50 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = pRealm @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = uSimMarine @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePID @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = pObstacleMgr @ NewConsole = false +} + +//-------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9201 +} + +//-------------------------------------------------- +// pHostInfo Config block + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + default_hostip_force = localhost +} + +//-------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB* + nowatch = uMAC* + + summary_wait = 12 +} + +//-------------------------------------------------- +// uLoadWatch Config block + +ProcessConfig = uLoadWatch +{ + AppTick = 1 + CommsTick = 1 + + thresh = app=pHelmIvP, gapthresh=3 + thresh = app=pHostInfo, gapthresh=5 + thresh = app=any, gapthresh=2.0 + + breach_trigger = 5 +} + + +//---------------------------------------------------- +// pHelmIvP Config Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + behaviors = targ_abe.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:4:21 + + app_logging = true + + pmgen = alg=dubins # radius=5 # degs=2 +} + +//-------------------------------------------------- +// uFldNodeBroker config block + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=VIEW_SEGLR + bridge = src=VEHICLE_CONNECT + bridge = src=APPCAST + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//-------------------------------------------------------- +// pBasicContactMgr Config Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + alert_verbose = true + + contact_max_age = 3600 + display_radii = false + //default_alert_region = pts={60,10:60,-100:170,-100:170,10} + + alert_range_color = gray70 + cpa_range_color = gray30 +} + + //------------------------------------------------------ +// uSimMarine Config Block + +ProcessConfig = uSimMarine +{ + AppTick = 10 + CommsTick = 10 + + START_POS = x=-10,y=-30,heading=180, 0 + PREFIX = NAV + + deprecated_ok = true + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + +//------------------------------------------------- +// pNodeReporter Config Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + platform_type = kayak + terse_reports = true + + platform_color = yellow +} + +//----------------------------------------------------- +// pMarinePID Config Block + +ProcessConfig = pMarinePID +{ + AppTick = 10 + CommsTick = 10 + + VERBOSE = true + DEPTH_CONTROL = false + ACTIVE_START = true + + deprecated_ok = true + + // Yaw PID controller + YAW_PID_KP = 0.4 + YAW_PID_KD = 0.1 + YAW_PID_KI = 0.0 + YAW_PID_INTEGRAL_LIMIT = 0.07 + + // Speed PID controller + SPEED_PID_KP = 1.0 + SPEED_PID_KD = 0.0 + SPEED_PID_KI = 0.0 + SPEED_PID_INTEGRAL_LIMIT = 0.07 + + // Maximums + MAXRUDDER = 100 + MAXTHRUST = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + SPEED_FACTOR = 20 +} + +//------------------------------------------------------- +// pObstacleMgr Config Block + +ProcessConfig = pObstacleMgr +{ + AppTick = 4 + CommsTick = 4 + + point_var = TRACKED_FEATURE + + + //obstacles_color = $(VCOLOR) + obstacles_color = invisible + + post_view_polys = false + + given_max_duration = 1000 + + general_alert = update_var=GEN_ALERT, alert_range=40000 + +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVD_DEBUG @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = AVOIDING @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CONTACT_INFO @ 0 NOSYNC + Log = CONTACT_RESOLVED @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_COUNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CONTACT_SUMMARY @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = LOITER @ 0 NOSYNC + Log = LOITER_ACQUIRE_A @ 0 NOSYNC + Log = LOITER_DIST_TO_POLY_A @ 0 NOSYNC + Log = LOITER_DIST_TO_VERT @ 0 NOSYNC + Log = LOITER_ETA_TO_POLY_A @ 0 NOSYNC + Log = LOITER_INDEX_A @ 0 NOSYNC + Log = LOITER_MODE_A @ 0 NOSYNC + Log = LOITER_REPORT_A @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_HEADING @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = OBM_ALERT_REQUEST @ 0 NOSYNC + Log = OBM_RESOLVED @ 0 NOSYNC + Log = OBSTACLE_ALERT @ 0 NOSYNC + Log = PHELMIVP_ITER_GAP @ 0 NOSYNC + Log = PHELMIVP_ITER_LEN @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = UP_LOITER @ 0 NOSYNC + Log = UP_PMVIEW @ 0 NOSYNC + Log = VEHICLE_UNDERWAY @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + Log = VIEW_SEGLR @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_ABE + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = GEN_ALERT @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true + //WildCardOmitPattern = *_STATUS + +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/m34_bo_alpha.abe/targ_abe.bhv b/src/test/missions/fixtures/m34_bo_alpha.abe/targ_abe.bhv new file mode 100644 index 0000000..188be35 --- /dev/null +++ b/src/test/missions/fixtures/m34_bo_alpha.abe/targ_abe.bhv @@ -0,0 +1,145 @@ +//--------------------------------------------------- +// Helm Behavior file + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize LOITER = true +initialize AVOID = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = LOITERING { + MODE = ACTIVE + LOITER = true +} + + +//---------------------------------------------- +Behavior = BHV_PModelView +{ + name = pmview + pwt = 100 + condition = (MODE==LOITERING) or (MODE==RETURNING) + updates = UP_PMVIEW +} + +//---------------------------------------------- +Behavior = BHV_Loiter +{ + name = loiter + pwt = 100 + condition = MODE==LOITERING + updates = UP_LOITER + runflag = VEHICLE_UNDERWAY = TRUE + endflag = VEHICLE_UNDERWAY = FALSE + + post_suffix = A + speed = 1.4 + clockwise = false + radius = 8.0 + nm_radius = 15.0 + polygon = radial:: x=0,y=-75, radius=15, pts=8, snap=1, label=abe_LOITER + visual_hints = nextpt_color=white, nextpt_lcolor=khaki + visual_hints = edge_color=orange, vertex_color=white + visual_hints = edge_size=1, vertex_size=2 +} + + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + spawnx_flag = RETURN_UPDATES=point=$[OSX],$[OSY] + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + point = 0,0 + repeat = 0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50 +} + +//---------------------------------------------- +Behavior = BHV_AvoidCollision +{ + name = ac_ + pwt = 200 + condition = AVOID = true + updates = CONTACT_INFO + idleflag = AVOIDING = idle + activeflag = AVOIDING = active + inactiveflag = AVOIDING = inactive + runflag = AVOIDING = running + endflag = AVOIDING = end + endflag = CONTACT_RESOLVED = $[CONTACT] + templating = spawn + + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + + pwt_outer_dist = 20 + pwt_inner_dist = 11 + completed_dist = 40 + min_util_cpa_dist = 8 + max_util_cpa_dist = 15 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 +} + + +//---------------------------------------------- +Behavior=BHV_AvoidObstacleV24 +{ + name = avd_ob_ + pwt = 500 + condition = DEPLOY = true + templating = spawn + updates = OBSTACLE_ALERT + + use_refinery = true + allowable_ttc = 5 + min_util_cpa_dist = 3 + max_util_cpa_dist = 7 + pwt_outer_dist = 15 + pwt_inner_dist = 5 + completed_dist = 15 +} + + diff --git a/src/test/missions/fixtures/m34_bo_alpha.ben/m34_bo_alpha.ben.alog.xz b/src/test/missions/fixtures/m34_bo_alpha.ben/m34_bo_alpha.ben.alog.xz new file mode 100644 index 0000000..c158070 Binary files /dev/null and b/src/test/missions/fixtures/m34_bo_alpha.ben/m34_bo_alpha.ben.alog.xz differ diff --git a/src/test/missions/fixtures/m34_bo_alpha.ben/m34_bo_alpha.ben.moos b/src/test/missions/fixtures/m34_bo_alpha.ben/m34_bo_alpha.ben.moos new file mode 100644 index 0000000..af5bd28 --- /dev/null +++ b/src/test/missions/fixtures/m34_bo_alpha.ben/m34_bo_alpha.ben.moos @@ -0,0 +1,361 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./LOG_BEN_13_11_2026_____03_29_55/LOG_BEN_13_11_2026_____03_29_55._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 7178162379.43906 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//------------------------------------------------- +// NAME: M. Benjamin, MIT +// FILE: ben.moos +//------------------------------------------------- +ServerHost = localhost +ServerPort = 9002 +Community = ben + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 4 (default) +MOOSTimeWarp = 4 +LatOrigin = 43.825300 +LongOrigin = -70.330400 + + +//------------------------------------------------- +Processconfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 50 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = pRealm @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pShare @ NewConsole = false + Run = uSimMarine @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pMarinePID @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pContactMgrV20 @ NewConsole = false + Run = pHostInfo @ NewConsole = false + Run = uFldNodeBroker @ NewConsole = false + Run = uLoadWatch @ NewConsole = false + Run = pObstacleMgr @ NewConsole = false +} + +//-------------------------------------------------- +// pShare Config Block + +ProcessConfig = pShare +{ + AppTick = 2 + CommsTick = 2 + + input = route = localhost:9202 +} + +//-------------------------------------------------- +// pHostInfo Config block + +ProcessConfig = pHostInfo +{ + AppTick = 1 + CommsTick = 1 + + default_hostip_force = localhost +} + +//-------------------------------------------------- +// uProcessWatch Config Block + +ProcessConfig = uProcessWatch +{ + AppTick = 1 + CommsTick = 1 + + allow_retractions = true + + watch_all = true // default is true + + nowatch = uXMS* + nowatch = uPokeDB* + nowatch = uQueryDB* + nowatch = uMAC* + + summary_wait = 12 +} + +//-------------------------------------------------- +// uLoadWatch Config block + +ProcessConfig = uLoadWatch +{ + AppTick = 1 + CommsTick = 1 + + thresh = app=pHelmIvP, gapthresh=3 + thresh = app=pHostInfo, gapthresh=5 + thresh = app=any, gapthresh=2.0 + + breach_trigger = 5 +} + + +//---------------------------------------------------- +// pHelmIvP Config Block + +ProcessConfig = pHelmIvP +{ + AppTick = 4 + CommsTick = 4 + + behaviors = targ_ben.bhv + verbose = false + domain = course:0:359:360 + domain = speed:0:4:21 + + app_logging = true + + pmgen = alg=dubins # radius=5 # degs=2 +} + +//-------------------------------------------------- +// uFldNodeBroker config block + +ProcessConfig = uFldNodeBroker +{ + AppTick = 1 + CommsTick = 1 + + try_shore_host = pshare_route=localhost:9200 + + bridge = src=VIEW_POLYGON + bridge = src=VIEW_CIRCLE + bridge = src=VIEW_POINT + bridge = src=VIEW_SEGLIST + bridge = src=VIEW_SEGLR + bridge = src=VEHICLE_CONNECT + bridge = src=APPCAST + bridge = src=NODE_REPORT_LOCAL, alias=NODE_REPORT + bridge = src=NODE_MESSAGE_LOCAL, alias=NODE_MESSAGE +} + +//-------------------------------------------------------- +// pBasicContactMgr Config Block + +ProcessConfig = pContactMgrV20 +{ + AppTick = 2 + CommsTick = 2 + + decay = 30,60 + + alert_verbose = true + + contact_max_age = 3600 + display_radii = false + //default_alert_region = pts={60,10:60,-100:170,-100:170,10} + + alert_range_color = gray70 + cpa_range_color = gray30 +} + + //------------------------------------------------------ +// uSimMarine Config Block + +ProcessConfig = uSimMarine +{ + AppTick = 10 + CommsTick = 10 + + START_POS = x=150,y=-130,heading=0, 0 + PREFIX = NAV + + deprecated_ok = true + + //rotate_speed = 0.012 + //drift_x = 0.0045 + + //thrust_map = -100:-2, 0:0, 20:1, 40:2, 60:3, 80:5, 100:5 +} + +//------------------------------------------------- +// pNodeReporter Config Block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + platform_type = kayak + terse_reports = true + + platform_color = red +} + +//----------------------------------------------------- +// pMarinePID Config Block + +ProcessConfig = pMarinePID +{ + AppTick = 10 + CommsTick = 10 + + VERBOSE = true + DEPTH_CONTROL = false + ACTIVE_START = true + + deprecated_ok = true + + // Yaw PID controller + YAW_PID_KP = 0.4 + YAW_PID_KD = 0.1 + YAW_PID_KI = 0.0 + YAW_PID_INTEGRAL_LIMIT = 0.07 + + // Speed PID controller + SPEED_PID_KP = 1.0 + SPEED_PID_KD = 0.0 + SPEED_PID_KI = 0.0 + SPEED_PID_INTEGRAL_LIMIT = 0.07 + + // Maximums + MAXRUDDER = 100 + MAXTHRUST = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + SPEED_FACTOR = 20 +} + +//------------------------------------------------------- +// pObstacleMgr Config Block + +ProcessConfig = pObstacleMgr +{ + AppTick = 4 + CommsTick = 4 + + point_var = TRACKED_FEATURE + + + //obstacles_color = $(VCOLOR) + obstacles_color = invisible + + post_view_polys = false + + given_max_duration = 1000 + + general_alert = update_var=GEN_ALERT, alert_range=40000 + +} + +//-------------------------------------------------- +// pLogger Config Block + +ProcessConfig = pLogger +{ + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = AVD_DEBUG @ 0 NOSYNC + Log = AVOID @ 0 NOSYNC + Log = AVOIDING @ 0 NOSYNC + Log = BCM_ALERT_REQUEST @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CONTACT_INFO @ 0 NOSYNC + Log = CONTACT_RESOLVED @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_COUNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CONTACT_SUMMARY @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = LOITER @ 0 NOSYNC + Log = LOITER_ACQUIRE_A @ 0 NOSYNC + Log = LOITER_DIST_TO_POLY_A @ 0 NOSYNC + Log = LOITER_DIST_TO_VERT @ 0 NOSYNC + Log = LOITER_ETA_TO_POLY_A @ 0 NOSYNC + Log = LOITER_INDEX_A @ 0 NOSYNC + Log = LOITER_MODE_A @ 0 NOSYNC + Log = LOITER_REPORT_A @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = NAV_HEADING @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = OBM_ALERT_REQUEST @ 0 NOSYNC + Log = OBM_RESOLVED @ 0 NOSYNC + Log = OBSTACLE_ALERT @ 0 NOSYNC + Log = PHELMIVP_ITER_GAP @ 0 NOSYNC + Log = PHELMIVP_ITER_LEN @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = RETURN_UPDATES @ 0 NOSYNC + Log = STATION_KEEP @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = UP_LOITER @ 0 NOSYNC + Log = UP_PMVIEW @ 0 NOSYNC + Log = VEHICLE_UNDERWAY @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + Log = VIEW_SEGLR @ 0 NOSYNC + AppTick = 5 + CommsTick = 5 + + File = LOG_BEN + PATH = ./ + AsyncLog = true + FileTimeStamp = true + + + Log = IVPHELM_LIFE_EVENT @ 0 nosync + Log = GEN_ALERT @ 0 nosync + + LogAuxSrc = true + + // Log it all!!!!! + WildCardLogging = true + //WildCardOmitPattern = *_STATUS + +} + + +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/m34_bo_alpha.ben/targ_ben.bhv b/src/test/missions/fixtures/m34_bo_alpha.ben/targ_ben.bhv new file mode 100644 index 0000000..01dd3a1 --- /dev/null +++ b/src/test/missions/fixtures/m34_bo_alpha.ben/targ_ben.bhv @@ -0,0 +1,145 @@ +//--------------------------------------------------- +// Helm Behavior file + +initialize DEPLOY = false +initialize RETURN = false +initialize STATION_KEEP = false +initialize LOITER = true +initialize AVOID = true + +set MODE = ACTIVE { + DEPLOY = true +} INACTIVE + +set MODE = STATION-KEEPING { + MODE = ACTIVE + STATION_KEEP = true +} + +set MODE = RETURNING { + MODE = ACTIVE + RETURN = true +} + +set MODE = LOITERING { + MODE = ACTIVE + LOITER = true +} + + +//---------------------------------------------- +Behavior = BHV_PModelView +{ + name = pmview + pwt = 100 + condition = (MODE==LOITERING) or (MODE==RETURNING) + updates = UP_PMVIEW +} + +//---------------------------------------------- +Behavior = BHV_Loiter +{ + name = loiter + pwt = 100 + condition = MODE==LOITERING + updates = UP_LOITER + runflag = VEHICLE_UNDERWAY = TRUE + endflag = VEHICLE_UNDERWAY = FALSE + + post_suffix = A + speed = 1.4 + clockwise = false + radius = 8.0 + nm_radius = 15.0 + polygon = radial:: x=145,y=-70, radius=15, pts=8, snap=1, label=ben_LOITER + visual_hints = nextpt_color=white, nextpt_lcolor=khaki + visual_hints = edge_color=orange, vertex_color=white + visual_hints = edge_size=1, vertex_size=2 +} + + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + updates = RETURN_UPDATES + condition = MODE==RETURNING + endflag = STATION_KEEP = true + endflag = AVOID = false + spawnx_flag = RETURN_UPDATES=point=$[OSX],$[OSY] + + speed = 1.3 + radius = 3.0 + nm_radius = 15.0 + point = 0,0 + repeat = 0 + lead = 8 +} + +//---------------------------------------------- +Behavior = BHV_StationKeep +{ + name = station-keep + pwt = 100 + condition = MODE==STATION-KEEPING + + center_activate = true + inner_radius = 5 + outer_radius = 10 + outer_speed = 1.0 + + transit_speed = 1.3 + swing_time = 7 + visual_hints = vertex_size=0, edge_color=gray50 +} + +//---------------------------------------------- +Behavior = BHV_AvoidCollision +{ + name = ac_ + pwt = 200 + condition = AVOID = true + updates = CONTACT_INFO + idleflag = AVOIDING = idle + activeflag = AVOIDING = active + inactiveflag = AVOIDING = inactive + runflag = AVOIDING = running + endflag = AVOIDING = end + endflag = CONTACT_RESOLVED = $[CONTACT] + templating = spawn + + contact = to-be-set + on_no_contact_ok = true + extrapolate = true + decay = 30,60 + + pwt_outer_dist = 20 + pwt_inner_dist = 11 + completed_dist = 40 + min_util_cpa_dist = 8 + max_util_cpa_dist = 15 + pwt_grade = linear + bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0 +} + + +//---------------------------------------------- +Behavior=BHV_AvoidObstacleV24 +{ + name = avd_ob_ + pwt = 500 + condition = DEPLOY = true + templating = spawn + updates = OBSTACLE_ALERT + + use_refinery = true + allowable_ttc = 5 + min_util_cpa_dist = 3 + max_util_cpa_dist = 7 + pwt_outer_dist = 15 + pwt_inner_dist = 5 + completed_dist = 15 +} + + diff --git a/src/test/missions/fixtures/s10_juliet/s10_juliet.alog.xz b/src/test/missions/fixtures/s10_juliet/s10_juliet.alog.xz index 868f4f0..183d576 100644 Binary files a/src/test/missions/fixtures/s10_juliet/s10_juliet.alog.xz and b/src/test/missions/fixtures/s10_juliet/s10_juliet.alog.xz differ diff --git a/src/test/missions/fixtures/s10_juliet/s10_juliet.moos b/src/test/missions/fixtures/s10_juliet/s10_juliet.moos index 2466a22..e4b91d6 100644 --- a/src/test/missions/fixtures/s10_juliet/s10_juliet.moos +++ b/src/test/missions/fixtures/s10_juliet/s10_juliet.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./JULIET_27_10_2026_____07_50_51/JULIET_27_10_2026_____07_50_51._moos +%% LOG FILE: ./JULIET_13_11_2026_____03_49_29/JULIET_13_11_2026_____03_49_29._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930874517.89039 +%% LOGSTART 17945417690.33025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT CSAIL @@ -54,17 +54,22 @@ ProcessConfig = uProcessWatch ProcessConfig = pLogger { + Log = AIS_REPORT @ 0 NOSYNC + Log = AIS_REPORT_LOCAL @ 0 NOSYNC Log = APPCAST @ 0 NOSYNC + Log = BHV_ABLE_FILTER @ 0 NOSYNC Log = BHV_IPF @ 0 NOSYNC Log = BHV_SETTINGS @ 0 NOSYNC Log = BHV_STATUS @ 0 NOSYNC Log = BHV_WARNING @ 0 NOSYNC + Log = DB_CLIENTS @ 0 NOSYNC Log = DEPLOY @ 0 NOSYNC Log = DEPTH_VALUE @ 0 NOSYNC Log = DESIRED_DEPTH @ 0 NOSYNC Log = DESIRED_HEADING @ 0 NOSYNC Log = DESIRED_SPEED @ 0 NOSYNC Log = GOTO_DEPTH @ 0 NOSYNC + Log = HELM_MAP_CLEAR @ 0 NOSYNC Log = IVPHELM_ALLSTOP @ 0 NOSYNC Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC @@ -85,6 +90,7 @@ ProcessConfig = pLogger Log = IVPHELM_LOOP_CPU @ 0 NOSYNC Log = IVPHELM_MODESET @ 0 NOSYNC Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_REJOURNAL @ 0 NOSYNC Log = IVPHELM_STATE @ 0 NOSYNC Log = IVPHELM_STATEVARS @ 0 NOSYNC Log = IVPHELM_SUMMARY @ 0 NOSYNC @@ -100,14 +106,19 @@ ProcessConfig = pLogger Log = LOITER_REPORT @ 0 NOSYNC Log = MODE @ 0 NOSYNC Log = MOOS_DEBUG @ 0 NOSYNC + Log = MOOS_MANUAL_OVERIDE @ 0 NOSYNC + Log = MOOS_MANUAL_OVERRIDE @ 0 NOSYNC Log = NAV_DEPTH @ 0 NOSYNC Log = NAV_HEADING @ 0 NOSYNC Log = NAV_SPEED @ 0 NOSYNC Log = NAV_X @ 0 NOSYNC Log = NAV_Y @ 0 NOSYNC + Log = NODE_REPORT @ 0 NOSYNC + Log = NODE_REPORT_LOCAL @ 0 NOSYNC Log = PHELMIVP_PID @ 0 NOSYNC Log = PHELMIVP_STATUS @ 0 NOSYNC Log = PLOGGER_CMD @ 0 NOSYNC + Log = RESTART_HELM @ 0 NOSYNC Log = RETURN @ 0 NOSYNC Log = TURN_RATE @ 0 NOSYNC Log = UPDATES_RETURN @ 0 NOSYNC diff --git a/src/test/missions/fixtures/s1_alpha/s1_alpha.alog.xz b/src/test/missions/fixtures/s1_alpha/s1_alpha.alog.xz index 1f5500c..897be9d 100644 Binary files a/src/test/missions/fixtures/s1_alpha/s1_alpha.alog.xz and b/src/test/missions/fixtures/s1_alpha/s1_alpha.alog.xz differ diff --git a/src/test/missions/fixtures/s1_alpha/s1_alpha.moos b/src/test/missions/fixtures/s1_alpha/s1_alpha.moos index 510d5f0..95572c1 100644 --- a/src/test/missions/fixtures/s1_alpha/s1_alpha.moos +++ b/src/test/missions/fixtures/s1_alpha/s1_alpha.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./MOOSLog_27_10_2026_____06_56_17/MOOSLog_27_10_2026_____06_56_17._moos +%% LOG FILE: ./MOOSLog_13_11_2026_____03_36_39/MOOSLog_13_11_2026_____03_36_39._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930841772.21312 +%% LOGSTART 17945409993.54647 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT CSAIL @@ -31,7 +31,7 @@ ProcessConfig = ANTLER MSBetweenLaunches = 200 Run = MOOSDB @ NewConsole = false - Run = pLogger @ NewConsole = false + Run = pLogger @ NewConsole = false Run = uSimMarineV22 @ NewConsole = false Run = pMarinePIDV22 @ NewConsole = false Run = pHelmIvP @ NewConsole = false @@ -92,6 +92,7 @@ ProcessConfig = pLogger Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = MISSION @ 0 NOSYNC Log = MOOS_DEBUG @ 0 NOSYNC Log = MOOS_MANUAL_OVERIDE @ 0 NOSYNC Log = MOOS_MANUAL_OVERRIDE @ 0 NOSYNC @@ -142,9 +143,6 @@ ProcessConfig = pLogger LogAuxSrc = true WildCardLogging = true - WildCardOmitPattern = *_STATUS - WildCardOmitPattern = DB_VARSUMMARY - WildCardOmitPattern = DB_RWSUMMARY WildCardExclusionLog = true } @@ -308,8 +306,9 @@ ProcessConfig = pNodeReporter ProcessConfig = uTimerScript_record { - event = var=DEPLOY, val=true, time=10 - event = var=MOOS_MANUAL_OVERRIDE, val=false, time=10 + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 } diff --git a/src/test/missions/fixtures/s1_alpha_obsavoid/alpha.bhv b/src/test/missions/fixtures/s1_alpha_obsavoid/alpha.bhv new file mode 100644 index 0000000..74c8756 --- /dev/null +++ b/src/test/missions/fixtures/s1_alpha_obsavoid/alpha.bhv @@ -0,0 +1,87 @@ +//-------- FILE: alpha.bhv ------------- + +initialize DEPLOY = false +initialize RETURN = false +initialize OBSTACLE_HIT = 0 + +set MODE = ACTIVE { + DEPLOY = true + OBSTACLE_HIT = 0 +} INACTIVE + +set MODE = SURVEYING { + MODE = ACTIVE + RETURN != true +} RETURNING + + + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_survey + pwt = 100 + condition = MODE == SURVEYING + endflag = RETURN = true + + idleflag = WPTING = idle + runflag = WPTING = running + endflag = WPTING = end + inactiveflag = WPTING = inactive + + UPDATES = WPT_UPDATE + perpetual = true + +// lead = 8 +// lead_damper = 1 + speed = 2 // meters per second + capture_line = true + capture_radius = 5.0 + slip_radius = 8.0 + points = 60,-50 : 60,-160 : 150,-160 : 180,-100 : 150,-40 + repeat = 5 + + visual_hints = nextpt_color=yellow + visual_hints = nextpt_vertex_size=8 + visual_hints = nextpt_lcolor=gray70 + visual_hints = vertex_color=dodger_blue, edge_color=white + visual_hints = vertex_size=5, edge_size=1 +} + +//---------------------------------------------- +Behavior = BHV_Waypoint +{ + name = waypt_return + pwt = 100 + condition = MODE == RETURNING + perpetual = true + endflag = RETURN = false + endflag = DEPLOY = false + endflag = MISSION = complete + + speed = 2.0 + capture_radius = 2.0 + slip_radius = 8.0 + points = 0,-20 +} + +//---------------------------------------------- +Behavior = BHV_AvoidObstacleV24 +{ + name = avd_obs + pwt = 110 + condition = MODE == ACTIVE + templating = spawn + updates = OBSTACLE_ALERT + + use_refinery = true + + allowable_ttc = 100 + pwt_outer_dist = 40 + pwt_inner_dist = 25 + max_util_cpa_dist = 20 + min_util_cpa_dist = 10 + completed_dist = 45 +} + + diff --git a/src/test/missions/fixtures/s1_alpha_obsavoid/s1_alpha_obsavoid.alog.xz b/src/test/missions/fixtures/s1_alpha_obsavoid/s1_alpha_obsavoid.alog.xz new file mode 100644 index 0000000..5c9692d Binary files /dev/null and b/src/test/missions/fixtures/s1_alpha_obsavoid/s1_alpha_obsavoid.alog.xz differ diff --git a/src/test/missions/fixtures/s1_alpha_obsavoid/s1_alpha_obsavoid.moos b/src/test/missions/fixtures/s1_alpha_obsavoid/s1_alpha_obsavoid.moos new file mode 100644 index 0000000..e312f23 --- /dev/null +++ b/src/test/missions/fixtures/s1_alpha_obsavoid/s1_alpha_obsavoid.moos @@ -0,0 +1,320 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOG FILE: ./MOOSLog_13_11_2026_____03_53_43/MOOSLog_13_11_2026_____03_53_43._moos +%% FILE OPENED ON Thu Jan 1 00:00:00 1970 +%% LOGSTART 17945420234.72471 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +//------------------------------------------------- +// NAME: M. Benjamin, MIT +// FILE: alpha.moos +//------------------------------------------------- + +ServerHost = localhost +ServerPort = 9000 +Community = alpha + +//---- Next Line was commented and replaced with a command line overload ---- // +//MOOSTimeWarp = 1 (default) +MOOSTimeWarp = 10 + +// Forest Lake +//LatOrigin = 43.825300 +//LongOrigin = -70.330400 + +// MIT Sailing Pavilion (use this one) +LatOrigin = 42.358456 +LongOrigin = -71.087589 + + +//------------------------------------------ +// Antler configuration block +ProcessConfig = ANTLER +{ + Run = uTimerScript @ NewConsole = false ~ uTimerScript_record + MSBetweenLaunches = 200 + + Run = MOOSDB @ NewConsole = false + Run = pLogger @ NewConsole = false + Run = pMarinePIDV22 @ NewConsole = false + Run = pHelmIvP @ NewConsole = false + Run = pMarineViewer @ NewConsole = false + Run = uProcessWatch @ NewConsole = false + Run = pNodeReporter @ NewConsole = false + Run = pObstacleMgr @ NewConsole = false + Run = uSimMarineV22 @ NewConsole = false +} + +//------------------------------------------ +// uProcessWatch config block + +ProcessConfig = uProcessWatch +{ + AppTick = 4 + CommsTick = 4 + + summary_wait = 5 + + nowatch = uXMS* + nowatch = uMAC* + nowatch = uPokeDB* + nowatch = uTermCommand* + watch_all = true +} + +//------------------------------------------ +// pLogger config block + +ProcessConfig = pLogger +{ + Log = AIS_REPORT @ 0 NOSYNC + Log = AIS_REPORT_LOCAL @ 0 NOSYNC + Log = APPCAST @ 0 NOSYNC + Log = APP_LOG @ 0 NOSYNC + Log = BHV_ABLE_FILTER @ 0 NOSYNC + Log = BHV_IPF @ 0 NOSYNC + Log = BHV_SETTINGS @ 0 NOSYNC + Log = BHV_STATUS @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + Log = CYCLE_INDEX @ 0 NOSYNC + Log = DB_CLIENTS @ 0 NOSYNC + Log = DEPLOY @ 0 NOSYNC + Log = DESIRED_HEADING @ 0 NOSYNC + Log = DESIRED_SPEED @ 0 NOSYNC + Log = HELM_MAP_CLEAR @ 0 NOSYNC + Log = IVPHELM_ALLSTOP @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC + Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_CNT_EVER @ 0 NOSYNC + Log = IVPHELM_BHV_DISABLED_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE @ 0 NOSYNC + Log = IVPHELM_BHV_IDLE_CNT @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING @ 0 NOSYNC + Log = IVPHELM_BHV_RUNNING_CNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_COUNT @ 0 NOSYNC + Log = IVPHELM_COMPLETED_PENDING @ 0 NOSYNC + Log = IVPHELM_CPU @ 0 NOSYNC + Log = IVPHELM_CREATE_CPU @ 0 NOSYNC + Log = IVPHELM_DOMAIN @ 0 NOSYNC + Log = IVPHELM_IPF_CNT @ 0 NOSYNC + Log = IVPHELM_ITER @ 0 NOSYNC + Log = IVPHELM_LEDGER_SUMMARY @ 0 NOSYNC + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = IVPHELM_LOOP_CPU @ 0 NOSYNC + Log = IVPHELM_MODESET @ 0 NOSYNC + Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_REJOURNAL @ 0 NOSYNC + Log = IVPHELM_STATE @ 0 NOSYNC + Log = IVPHELM_STATEVARS @ 0 NOSYNC + Log = IVPHELM_SUMMARY @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_CACHED @ 0 NOSYNC + Log = IVPHELM_TOTAL_PCS_FORMED @ 0 NOSYNC + Log = IVPHELM_UPDATEVARS @ 0 NOSYNC + Log = IVPHELM_UPDATE_RESULT @ 0 NOSYNC + Log = MODE @ 0 NOSYNC + Log = MOOS_DEBUG @ 0 NOSYNC + Log = MOOS_MANUAL_OVERIDE @ 0 NOSYNC + Log = MOOS_MANUAL_OVERRIDE @ 0 NOSYNC + Log = NAV_DEPTH @ 0 NOSYNC + Log = NAV_HEADING @ 0 NOSYNC + Log = NAV_SPEED @ 0 NOSYNC + Log = NAV_X @ 0 NOSYNC + Log = NAV_Y @ 0 NOSYNC + Log = NODE_REPORT @ 0 NOSYNC + Log = NODE_REPORT_LOCAL @ 0 NOSYNC + Log = OBM_ALERT_REQUEST @ 0 NOSYNC + Log = OBM_RESOLVED @ 0 NOSYNC + Log = OBSTACLE_ALERT @ 0 NOSYNC + Log = OBSTACLE_HIT @ 0 NOSYNC + Log = PHELMIVP_PID @ 0 NOSYNC + Log = PHELMIVP_STATUS @ 0 NOSYNC + Log = PLOGGER_CMD @ 0 NOSYNC + Log = RESTART_HELM @ 0 NOSYNC + Log = RETURN @ 0 NOSYNC + Log = TURN_RATE @ 0 NOSYNC + Log = VIEW_POINT @ 0 NOSYNC + Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC + Log = WPTING @ 0 NOSYNC + Log = WPT_INDEX @ 0 NOSYNC + Log = WPT_ODO @ 0 NOSYNC + Log = WPT_STAT @ 0 NOSYNC + Log = WPT_UPDATE @ 0 NOSYNC + AppTick = 8 + CommsTick = 8 + + AsyncLog = true + + // For variables that are published in a bundle on their first post, + // explicitly declare their logging request + + Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC + Log = BHV_WARNING @ 0 NOSYNC + + LogAuxSrc = true + WildCardLogging = true + WildCardExclusionLog = true +} + +//------------------------------------------ +// uSimMarineV22 config block + +ProcessConfig = uSimMarineV22 +{ + AppTick = 4 + CommsTick = 4 + + app_logging = true + + start_x = 60 + start_y = -30 + start_heading = 180 + start_speed = 0 + max_deceleration = 0.1 + prefix = NAV + + //max_rudder_degs_per_sec = 1 + + //turn_rate = 15 + turn_rate = 40 + thrust_map = 0:0, 20:1, 40:2, 60:3, 80:4, 100:5 + thrust_reflect = true +} + +//------------------------------------------ +// pHelmIvP config block + +ProcessConfig = pHelmIvP +{ + AppTick = 2 + CommsTick = 2 + + app_logging = true + + term_report_interval=0 + + bhv_dir_not_found_ok = true + //ivp_behavior_dir = /Users/mikerb + + behaviors = alpha.bhv + domain = course:0:359:360 + domain = speed:0:4:21 +} + +//------------------------------------------ +// pMarinePIDV22 config block + +ProcessConfig = pMarinePIDV22 +{ + AppTick = 20 + CommsTick = 20 + + verbose = true + depth_control = false + + // SIM_INSTABILITY = 20 + + // Yaw PID controller + yaw_pid_kp = 1.2 + yaw_pid_kd = 0.0 + yaw_pid_ki = 0.3 + yaw_pid_integral_limit = 0.07 + + // Speed PID controller + speed_pid_kp = 1.0 + speed_pid_kd = 0.0 + speed_pid_ki = 0.0 + speed_pid_integral_limit = 0.07 + + //MAXIMUMS + maxrudder = 100 + maxthrust = 100 + + // A non-zero SPEED_FACTOR overrides use of SPEED_PID + // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR + speed_factor = 20 +} + +//------------------------------------------ +// pMarineViewer config block + +ProcessConfig = pMarineViewer +{ + AppTick = 4 + CommsTick = 4 + + //tiff_file = forrest19.tif + tiff_file = AerialMIT.tif + + set_pan_x = -90 + set_pan_y = 80 + zoom = 2.4 + + vehicle_shape_scale = 1 + hash_delta = 50 + hash_shade = 0.4 + hash_viewable = true + + trails_point_size = 1 + + // Appcast configuration + appcast_height = 75 + appcast_width = 30 + appcast_viewable = true + appcast_color_scheme = indigo + nodes_font_size = medium + procs_font_size = medium + appcast_font_size = small + + //left_context[polyvert] = POLY_VERT=x=$(XPOS),y=$(YPOS) + left_context[pt] = VIEW_POINT = x=$(XPOS),y=$(YPOS),label=pt$(IX),vertex_color=white + + scope = DST_AVD_OBSTACLESC + scope = RNG_AVD_OBSTACLESC + scope = RNG_AVD_OBSTACLESA + scope = POSE_KEEP + scope = VIEW_POLYGON + scope = VIEW_POINT + scope = RETURN + scope = WPT_STAT + scope = VIEW_SEGLIST + + button_one = DEPLOY # DEPLOY=true + button_one = MOOS_MANUAL_OVERRIDE=false # RETURN=false + button_two = RETURN # RETURN=true +} + +//------------------------------------------ +// pNodeReporter config block + +ProcessConfig = pNodeReporter +{ + AppTick = 2 + CommsTick = 2 + + platform_type = kayak + platform_length = 4 +} + +//------------------------------------------------------- +// pObstacleMgr Configuration Block (created from plugin) + +ProcessConfig = pObstacleMgr +{ + AppTick = 4 + CommsTick = 4 + + given_obstacle = pts={50,-100:50,-120:80,-120:80,-100}, label=one + + obstacles_color = yellow + + post_view_polys = false + given_max_duration = 1000 +} +ProcessConfig = uTimerScript_record +{ + condition = (IVPHELM_STATE = PARK) or (IVPHELM_STATE = DRIVE) + event = var=DEPLOY, val=true, time=5 + event = var=MOOS_MANUAL_OVERRIDE, val=false, time=5 +} + + diff --git a/src/test/missions/fixtures/s2_bravo/s2_bravo.alog.xz b/src/test/missions/fixtures/s2_bravo/s2_bravo.alog.xz index 6f56f3c..544c7a3 100644 Binary files a/src/test/missions/fixtures/s2_bravo/s2_bravo.alog.xz and b/src/test/missions/fixtures/s2_bravo/s2_bravo.alog.xz differ diff --git a/src/test/missions/fixtures/s2_bravo/s2_bravo.moos b/src/test/missions/fixtures/s2_bravo/s2_bravo.moos index 637ef5d..232dbd5 100644 --- a/src/test/missions/fixtures/s2_bravo/s2_bravo.moos +++ b/src/test/missions/fixtures/s2_bravo/s2_bravo.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./MOOSLog_27_10_2026_____07_40_01/MOOSLog_27_10_2026_____07_40_01._moos +%% LOG FILE: ./MOOSLog_13_11_2026_____03_38_45/MOOSLog_13_11_2026_____03_38_45._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930868015.6366 +%% LOGSTART 17945411259.1919 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT CSAIL diff --git a/src/test/missions/fixtures/s3_charlie/s3_charlie.alog.xz b/src/test/missions/fixtures/s3_charlie/s3_charlie.alog.xz index a02bf5b..bede3ad 100644 Binary files a/src/test/missions/fixtures/s3_charlie/s3_charlie.alog.xz and b/src/test/missions/fixtures/s3_charlie/s3_charlie.alog.xz differ diff --git a/src/test/missions/fixtures/s3_charlie/s3_charlie.moos b/src/test/missions/fixtures/s3_charlie/s3_charlie.moos index f059384..3e77845 100644 --- a/src/test/missions/fixtures/s3_charlie/s3_charlie.moos +++ b/src/test/missions/fixtures/s3_charlie/s3_charlie.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./MOOSLog_27_10_2026_____07_42_08/MOOSLog_27_10_2026_____07_42_08._moos +%% LOG FILE: ./MOOSLog_13_11_2026_____03_40_54/MOOSLog_13_11_2026_____03_40_54._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930869283.83171 +%% LOGSTART 17945412545.3203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT CSAIL diff --git a/src/test/missions/fixtures/s4_delta/s4_delta.alog.xz b/src/test/missions/fixtures/s4_delta/s4_delta.alog.xz index 426eb5d..3e02939 100644 Binary files a/src/test/missions/fixtures/s4_delta/s4_delta.alog.xz and b/src/test/missions/fixtures/s4_delta/s4_delta.alog.xz differ diff --git a/src/test/missions/fixtures/s4_delta/s4_delta.moos b/src/test/missions/fixtures/s4_delta/s4_delta.moos index 656e2af..13e8c45 100644 --- a/src/test/missions/fixtures/s4_delta/s4_delta.moos +++ b/src/test/missions/fixtures/s4_delta/s4_delta.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./LOG_27_10_2026_____07_44_21/LOG_27_10_2026_____07_44_21._moos +%% LOG FILE: ./LOG_13_11_2026_____03_43_02/LOG_13_11_2026_____03_43_02._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930870614.74463 +%% LOGSTART 17945413826.16248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT CSAIL diff --git a/src/test/missions/fixtures/s5_echo/s5_echo.alog.xz b/src/test/missions/fixtures/s5_echo/s5_echo.alog.xz index b34aa3d..d2637c6 100644 Binary files a/src/test/missions/fixtures/s5_echo/s5_echo.alog.xz and b/src/test/missions/fixtures/s5_echo/s5_echo.alog.xz differ diff --git a/src/test/missions/fixtures/s5_echo/s5_echo.moos b/src/test/missions/fixtures/s5_echo/s5_echo.moos index f35e68b..ad24002 100644 --- a/src/test/missions/fixtures/s5_echo/s5_echo.moos +++ b/src/test/missions/fixtures/s5_echo/s5_echo.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./MOOSLog_27_10_2026_____07_46_32/MOOSLog_27_10_2026_____07_46_32._moos +%% LOG FILE: ./MOOSLog_13_11_2026_____03_45_11/MOOSLog_13_11_2026_____03_45_11._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930871923.37738 +%% LOGSTART 17945415118.63238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT CSAIL diff --git a/src/test/missions/fixtures/s7_golf/s7_golf.alog.xz b/src/test/missions/fixtures/s7_golf/s7_golf.alog.xz index f222d05..626eaa1 100644 Binary files a/src/test/missions/fixtures/s7_golf/s7_golf.alog.xz and b/src/test/missions/fixtures/s7_golf/s7_golf.alog.xz differ diff --git a/src/test/missions/fixtures/s7_golf/s7_golf.moos b/src/test/missions/fixtures/s7_golf/s7_golf.moos index 1b359bf..d50d50a 100644 --- a/src/test/missions/fixtures/s7_golf/s7_golf.moos +++ b/src/test/missions/fixtures/s7_golf/s7_golf.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./LOG_27_10_2026_____07_48_44/LOG_27_10_2026_____07_48_44._moos +%% LOG FILE: ./LOG_13_11_2026_____03_47_21/LOG_13_11_2026_____03_47_21._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930873244.76507 +%% LOGSTART 17945416410.06899 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT CSAIL @@ -61,18 +61,23 @@ ProcessConfig = pSafetyRetreat ProcessConfig = pLogger { + Log = AIS_REPORT @ 0 NOSYNC + Log = AIS_REPORT_LOCAL @ 0 NOSYNC Log = APPCAST @ 0 NOSYNC + Log = BHV_ABLE_FILTER @ 0 NOSYNC Log = BHV_ERROR @ 0 NOSYNC Log = BHV_IPF @ 0 NOSYNC Log = BHV_SETTINGS @ 0 NOSYNC Log = BHV_STATUS @ 0 NOSYNC Log = BHV_WARNING @ 0 NOSYNC Log = CYCLE_INDEX @ 0 NOSYNC + Log = DB_CLIENTS @ 0 NOSYNC Log = DEPLOY @ 0 NOSYNC Log = DESIRED_DEPTH @ 0 NOSYNC Log = DESIRED_HEADING @ 0 NOSYNC Log = DESIRED_SPEED @ 0 NOSYNC Log = GPS_UPDATE_RECEIVED @ 0 NOSYNC + Log = HELM_MAP_CLEAR @ 0 NOSYNC Log = IVPHELM_ALLSTOP @ 0 NOSYNC Log = IVPHELM_BHV_ACTIVE @ 0 NOSYNC Log = IVPHELM_BHV_ACTIVE_CNT @ 0 NOSYNC @@ -94,6 +99,7 @@ ProcessConfig = pLogger Log = IVPHELM_LOOP_CPU @ 0 NOSYNC Log = IVPHELM_MODESET @ 0 NOSYNC Log = IVPHELM_REGISTER @ 0 NOSYNC + Log = IVPHELM_REJOURNAL @ 0 NOSYNC Log = IVPHELM_STATE @ 0 NOSYNC Log = IVPHELM_STATEVARS @ 0 NOSYNC Log = IVPHELM_SUMMARY @ 0 NOSYNC @@ -108,16 +114,21 @@ ProcessConfig = pLogger Log = LOITER_REPORT_A @ 0 NOSYNC Log = MODE @ 0 NOSYNC Log = MOOS_DEBUG @ 0 NOSYNC + Log = MOOS_MANUAL_OVERIDE @ 0 NOSYNC + Log = MOOS_MANUAL_OVERRIDE @ 0 NOSYNC Log = NAV_DEPTH @ 0 NOSYNC Log = NAV_HEADING @ 0 NOSYNC Log = NAV_SPEED @ 0 NOSYNC Log = NAV_X @ 0 NOSYNC Log = NAV_Y @ 0 NOSYNC + Log = NODE_REPORT @ 0 NOSYNC + Log = NODE_REPORT_LOCAL @ 0 NOSYNC Log = PENDING_SURFACE @ 0 NOSYNC Log = PHELMIVP_PID @ 0 NOSYNC Log = PHELMIVP_STATUS @ 0 NOSYNC Log = PLOGGER_CMD @ 0 NOSYNC Log = PSURFACE @ 0 NOSYNC + Log = RESTART_HELM @ 0 NOSYNC Log = RETREAT_LOITER @ 0 NOSYNC Log = RETURN @ 0 NOSYNC Log = RETURNING @ 0 NOSYNC @@ -129,6 +140,7 @@ ProcessConfig = pLogger Log = UP_RETREAT @ 0 NOSYNC Log = VIEW_POINT @ 0 NOSYNC Log = VIEW_POLYGON @ 0 NOSYNC + Log = VIEW_SEGLIST @ 0 NOSYNC Log = WPT_ODO @ 0 NOSYNC Log = WPT_STAT @ 0 NOSYNC AppTick = 5 diff --git a/src/test/missions/fixtures/x1_legs/x1_legs.alog.xz b/src/test/missions/fixtures/x1_legs/x1_legs.alog.xz index 83111dc..be038f5 100644 Binary files a/src/test/missions/fixtures/x1_legs/x1_legs.alog.xz and b/src/test/missions/fixtures/x1_legs/x1_legs.alog.xz differ diff --git a/src/test/missions/fixtures/x1_legs/x1_legs.moos b/src/test/missions/fixtures/x1_legs/x1_legs.moos index a33e091..1310445 100644 --- a/src/test/missions/fixtures/x1_legs/x1_legs.moos +++ b/src/test/missions/fixtures/x1_legs/x1_legs.moos @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOG FILE: ./alpha_27_10_2026_____07_53_01/alpha_27_10_2026_____07_53_01._moos +%% LOG FILE: ./alpha_13_11_2026_____03_51_36/alpha_13_11_2026_____03_51_36._moos %% FILE OPENED ON Thu Jan 1 00:00:00 1970 -%% LOGSTART 17930875818.86947 +%% LOGSTART 17945418968.88906 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //------------------------------------------------- // NAME: M. Benjamin, MIT MechE diff --git a/src/test/missions/goby/m2_berta/ghost.pb.cfg b/src/test/missions/goby/m2_berta/ghost.pb.cfg new file mode 100644 index 0000000..c416028 --- /dev/null +++ b/src/test/missions/goby/m2_berta/ghost.pb.cfg @@ -0,0 +1,2 @@ +alog: "../../fixtures/m2_berta.abe/m2_berta.abe.alog.xz" +vehicle: "ben" diff --git a/src/test/missions/goby/m2_berta/helm.pb.cfg b/src/test/missions/goby/m2_berta/helm.pb.cfg new file mode 100644 index 0000000..16b5205 --- /dev/null +++ b/src/test/missions/goby/m2_berta/helm.pb.cfg @@ -0,0 +1,16 @@ +helm { + behavior_file: "../fixtures/m2_berta.abe/targ_abe.bhv" + domain { name: "course" low: 0 high: 359 points: 360 } + domain { name: "speed" low: 0 high: 2 points: 21 } + contact_manager { + alert: "id=avdcol_, var=CONTACT_INFO, val=\"name=$[VNAME] # contact=$[VNAME]\"" + alert: "id=avdcol_, alert_range=15, cpa_range=5" + contact_max_age: 35 + decay_start: 30 + decay_end: 60 + hold_alerts_for_helm: true + disable_var: "XYZ_DISABLE_TARGET" + enable_var: "XYZ_REENABLE_TARGET" + } +} +frontseat { enable: true } diff --git a/src/test/missions/goby/m2_berta/test.yml b/src/test/missions/goby/m2_berta/test.yml new file mode 100644 index 0000000..60b6861 --- /dev/null +++ b/src/test/missions/goby/m2_berta/test.yml @@ -0,0 +1,58 @@ +# m2_berta: abe loiters while ben, a ghost replayed from the recording, passes +# through; abe's avdcol_ behavior spawns from the helm's own contact alert. +# Times are real seconds: a tenth of mission time. The ghost fixture runs in +# this directory, the others in the one above. +include: [../closed_loop.yml] + +fixture: + - name: ghost + command: cat ../common.pb.cfg ghost.pb.cfg | ${GHOST} - + env: ['GOBY_INTERPROCESS=platform: "ivpico_${MISSION}"'] + +test: + name: m2_berta closed loop + run: + - name: mission + mode: PARALLEL + step: + - name: deploy + publish: + - group: ivpico::helm::variable + type: PROTOBUF/ivp.interface.Variable + value: 'key: "DEPLOY" sval: "true"' + delay: 0.5 + - group: ivpico::helm::variable + type: PROTOBUF/ivp.interface.Variable + value: 'key: "MOOS_MANUAL_OVERRIDE" sval: "false"' + delay: 0.5 + expect: + # recorded at 380 s of mission time + - group: ivpico::helm::life_event + type: ivp.interface.LifeEvent + match: 'type: SPAWN behavior: "avdcol_ben"' + timeout: 48 + - name: meets ben + expect: + - group: ivpico::test::ghost_range + type: ivp.interface.Variable + condition: [{ field: dval, op: LT, value: "100" }] + timeout: 48 + - name: keeps clear of ben + expect: + - group: ivpico::test::ghost_range + type: ivp.interface.Variable + condition: [{ field: dval, op: LT, value: "10" }] + count: 0 + timeout: 50 + - name: no errors + expect: + - group: ivpico::helm::status + type: ivp.interface.Status + condition: [{ field: state, op: EQ, value: MALCONFIG }] + count: 0 + timeout: 50 + - group: ivpico::helm::status + type: ivp.interface.Status + condition: [{ field: allstop, op: EQ, value: BEHAVIOR_ERROR }] + count: 0 + timeout: 50 diff --git a/src/test/missions/missions.txt b/src/test/missions/missions.txt index 8ec3f16..2f803ce 100644 --- a/src/test/missions/missions.txt +++ b/src/test/missions/missions.txt @@ -1,6 +1,6 @@ -# Single-vehicle MOOS-IvP missions recorded for the replay tests (record.sh). -# Each runs from ivp/missions/ with pAntler, and the pokes go in -# 5 s (mission time) after pHelmIvP starts. +# MOOS-IvP missions recorded for the replay tests (record.sh). Each runs from +# ivp/missions/ with pAntler, and the pokes go to every vehicle 5 s +# (mission time) after its pHelmIvP starts. # # mission moos_file warp seconds pokes s1_alpha alpha.moos 10 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false @@ -13,3 +13,17 @@ s7_golf golf.moos 10 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=fals s10_juliet juliet.moos 10 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false # x1_legs is MALCONFIG: its alpha.bhv uses BHV_LegRun parameters this MOOS-IvP rejects x1_legs alpha.moos 10 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false +# Obstacles from uFldObstacleSim, through pObstacleMgr +s1_alpha_obsavoid alpha.moos 10 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false +# +# Missions with contacts, run with launch.sh --just_make: one fixture per vehicle. +# At a lower warp, since mail reaches pHelmIvP later (in mission time) with +# several communities running. +# +# mission moos_file warp seconds pokes +m2_berta launch.sh 4 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false +berta_cmgr launch.sh 4 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false +m15_pursuit launch.sh 4 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false +m34_bo_alpha launch.sh 4 600 DEPLOY=true MOOS_MANUAL_OVERRIDE=false +# ufld_convoy is left out: its pHelmIvP looks for behaviors in a directory on +# its author's machine, and is MALCONFIG anywhere else diff --git a/src/test/missions/record.sh b/src/test/missions/record.sh index 1d28e18..21dbb6a 100755 --- a/src/test/missions/record.sh +++ b/src/test/missions/record.sh @@ -2,7 +2,8 @@ # Records MOOS-IvP missions under pHelmIvP for the replay tests: builds all of # MOOS-IvP from GobySoft's ivp-without-moos branch (libivp-helm-dev's source), # runs each mission in missions.txt headless, and keeps each vehicle's helm -# inputs and outputs in fixtures/. +# inputs and outputs in fixtures/ (one vehicle) or +# fixtures/. (missions started by launch.sh). # # Usage: record.sh [mission...] (default: every mission in missions.txt) # @@ -25,10 +26,13 @@ fi export PATH="${moos_ivp}/ivp/bin:${moos_ivp}/bin:${moos_ivp}/build/MOOS/MOOSCore/bin:${moos_ivp}/build/MOOS/MOOSEssentials/bin:${PATH}" # Keeps the log header, pHelmIvP's posts, and every post to a variable pHelmIvP -# registered, without the duplicate lines pLogger sometimes writes +# registered, without the duplicate lines pLogger sometimes writes, its +# app logging, the objective functions (which replay doesn't compare), or the +# lines a multi-line value spills onto trim() { awk 'NR == FNR { if ($2 == "IVPHELM_REGISTER") registered[$4] = 1; next } /^%%/ { print; next } + $1 !~ /^-?[0-9.]+$/ || $2 ~ /^(APP_LOG|APPCAST|PHELMIVP_STATUS|BHV_IPF)$/ { next } ($3 ~ /^pHelmIvP/ || ($2 in registered)) && !seen[$0]++' "$1" "$1" } @@ -60,6 +64,12 @@ prepare() { mv "${moos_file}.prepared" "${moos_file}" } +# Drops a shoreside's GUIs, which a headless run can't start +strip_gui() { + awk '!/^[ \t]*Run *= *(pMarineViewer|uMAC)[ \t@]/' "$1" > "$1.headless" + mv "$1.headless" "$1" +} + # The log directories of a run, wherever its pLogger writes them log_dirs() { find "$1" -name '*.alog' -exec dirname {} \; | sort -u @@ -87,7 +97,9 @@ add_logging() { mv "${moos_file}.logged" "${moos_file}" } -# run [log variables] +# run [log variables] +# With launch.sh, the mission's own launch.sh writes a .moos file per community +# (targ_*.moos), and each one runs. run() { local run=$1 moos_file=$2 warp=$3 seconds=$4 variables=${5:-} rm -rf "${run}" @@ -95,20 +107,40 @@ run() { cp -r "${moos_ivp}/ivp/missions/${mission}" "${run}" ( cd "${run}" - prepare "${moos_file}" "${pokes[@]}" - [ -n "${variables}" ] && add_logging "${moos_file}" "${variables}" - # job control puts pAntler in its own process group, to stop whatever it leaves behind + local moos_files=("${moos_file}") + if [ "${moos_file}" = launch.sh ]; then + ./launch.sh --just_make "${warp}" > launch.log 2>&1 + moos_files=(targ_*.moos) + fi + local f + for f in "${moos_files[@]}"; do + if grep -qiE '^[[:space:]]*processconfig[[:space:]]*=[[:space:]]*phelmivp' "${f}"; then + prepare "${f}" "${pokes[@]}" + [ -n "${variables}" ] && add_logging "${f}" "${variables}" + else + strip_gui "${f}" + fi + done + # job control puts each pAntler in its own process group, to stop whatever it leaves behind set -m - pAntler "${moos_file}" --MOOSTimeWarp="${warp}" > antler.log 2>&1 & - antler=$! + local antlers=() + for f in "${moos_files[@]}"; do + pAntler "${f}" --MOOSTimeWarp="${warp}" > "antler_${f%.moos}.log" 2>&1 & + antlers+=($!) + done sleep $((seconds / warp)) - kill -INT "${antler}" + local antler + for antler in "${antlers[@]}"; do kill -INT "${antler}" 2> /dev/null || true; done for _ in $(seq 20); do - kill -0 "${antler}" 2> /dev/null || break + local running=0 + for antler in "${antlers[@]}"; do kill -0 "${antler}" 2> /dev/null && running=1; done + [ "${running}" = 0 ] && break sleep 1 done - kill -KILL -- "-${antler}" 2> /dev/null || true - wait "${antler}" || true + for antler in "${antlers[@]}"; do + kill -KILL -- "-${antler}" 2> /dev/null || true + wait "${antler}" || true + done ) } @@ -126,17 +158,24 @@ record() { variables=$(helm_variables "${logs[@]}" | tr '\n' ' ') run "${work}/runs/${mission}" "${moos_file}" "${warp}" "${seconds}" "${variables}" - local fixture=${here}/fixtures/${mission} - rm -rf "${fixture}" - mkdir -p "${fixture}" + rm -rf "${here}/fixtures/${mission}" "${here}/fixtures/${mission}".* local log for log in $(log_dirs "${work}/runs/${mission}"); do - local name + local name community fixture name=$(basename "${log}") - trim "${log}/${name}.alog" | xz -9 > "${fixture}/${mission}.alog.xz" - cp "${log}/${name}._moos" "${fixture}/${mission}.moos" - if ! xz -dc "${fixture}/${mission}.alog.xz" | grep "IVPHELM_REGISTER" > /dev/null; then - echo "warning: ${mission}'s log misses pHelmIvP's startup" >&2 + awk '$2 == "IVPHELM_STATE" && $3 ~ /^pHelmIvP/ { found = 1; exit } END { exit !found }' \ + "${log}/${name}.alog" || continue + community=$(awk -F= 'tolower($1) ~ /^[ \t]*community[ \t]*$/ { gsub(/[ \t]/, "", $2); print $2; exit }' \ + "${log}/${name}._moos") + fixture=${here}/fixtures/${mission} + [ "${moos_file}" = launch.sh ] && fixture+=".${community}" + mkdir -p "${fixture}" + local base + base=$(basename "${fixture}") + trim "${log}/${name}.alog" | xz -9 > "${fixture}/${base}.alog.xz" + cp "${log}/${name}._moos" "${fixture}/${base}.moos" + if ! xz -dc "${fixture}/${base}.alog.xz" | grep "IVPHELM_REGISTER" > /dev/null; then + echo "warning: ${base}'s log misses pHelmIvP's startup" >&2 fi for bhv in "${log}"/*._bhv; do [ -e "${bhv}" ] || continue @@ -144,7 +183,11 @@ record() { done # pHelmIvP only asks pLogger to copy its behavior files once it has started if ! ls "${fixture}"/*.bhv > /dev/null 2>&1; then - cp "${work}/runs/${mission}"/*.bhv "${fixture}/" + if [ "${moos_file}" = launch.sh ]; then + cp "${work}/runs/${mission}/targ_${community}.bhv" "${fixture}/" + else + cp "${work}/runs/${mission}"/*.bhv "${fixture}/" + fi fi done } diff --git a/src/test/missions/replay.cpp b/src/test/missions/replay.cpp index a84dab0..c55ed71 100644 --- a/src/test/missions/replay.cpp +++ b/src/test/missions/replay.cpp @@ -1,8 +1,25 @@ +// Copyright 2026: +// GobySoft, LLC +// +// This file is part of IvPico. +// +// IvPico is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 2 of the License, or (at your option) any later +// version. +// +// IvPico is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with IvPico. If not, see . + // Replays a MOOS-IvP mission recorded under pHelmIvP (see record.sh) against // ivpico::helm::Helm, and checks that the helm makes the same decisions and // posts the same things. // -// Usage: replay [stream to print in full, e.g. "loiter LOITER_INDEX"] +// Usage: replay [--alerts] [stream to print in full, e.g. "loiter LOITER_INDEX"] // // The fixture holds the vehicle's .moos file (for pHelmIvP's configuration), // its .bhv files, and an alog trimmed to pHelmIvP's posts and the posts to @@ -20,9 +37,11 @@ // // What's compared, as sequences of changes, each change matched within // `tolerance` iterations, and all but `max_mismatch` of them matching (a -// stream with fewer than 20 changes has to match exactly). Continuous values -// (distances, ETAs, track points) differ now and then, when pHelmIvP got a -// navigation update a little later or earlier than its timestamp says. +// stream with fewer than 20 changes has to match exactly). A change with the +// same text on the same iteration but different numbers counts separately, +// against `max_numeric_mismatch`: continuous values (distances, ETAs, track +// points) differ now and then, when pHelmIvP got a navigation update a little +// later or earlier than its timestamp says. // - IVPHELM_STATE and IVPHELM_ALLSTOP against Status; // - mode variables against MODE postings; // - initialize posts against INITIALIZE postings; @@ -33,6 +52,18 @@ // domain on all but `desired_max_mismatch` of the iterations where either // helm decided, and never off for more than `desired_max_run` in a row. // +// Contacts are replayed two ways: +// - by default, the recorded contact manager's posts (pContactMgrV20's alerts, +// BHV_ABLE_FILTER) go in like any other input, and the helm's own contact +// alerts are off (contact_alerts: false). This checks the helm alone; +// - with --alerts, those posts are left out, and the helm raises alerts +// itself from the .moos file's pContactMgrV20 block. Its posts are compared +// with pContactMgrV20's, and every change may be `alerts_tolerance` +// iterations off, since pContactMgrV20 iterates on its own clock. A +// behavior spawned an iteration later posts every value an iteration +// later, so only the helm state, allstops, modes, life events, active +// behaviors and the contact manager's posts are compared. +// // Prints a summary per stream, the first mismatches in each, and exits non-zero // if any stream failed. @@ -60,10 +91,12 @@ using ivpico::helm::Output; namespace { -constexpr int tolerance = 1; +int tolerance = 1; +constexpr int alerts_tolerance = 2; constexpr double mail_latency = 0.005; constexpr double number_tolerance = 1e-3; constexpr double max_mismatch = 0.05; +constexpr double max_numeric_mismatch = 0.2; constexpr double desired_max_mismatch = 0.01; constexpr int desired_max_run = 3; constexpr int report_mismatches = 5; @@ -143,13 +176,94 @@ Alog read_alog(const fs::path& path) return alog; } -// pHelmIvP's block of the .moos file, as HelmConfig +bool is_contact_manager(const std::string& source) +{ + return source.rfind("pContactMgrV20", 0) == 0; +} + +// pContactMgrV20's block of the .moos file +void read_contact_manager(const std::vector& lines, HelmConfig::ContactManager& cm) +{ + // in reverse, as MOOS's mission reader hands them over + for (auto it = lines.rbegin(); it != lines.rend(); ++it) + { + const std::string& line = *it; + const auto eq = line.find('='); + const std::string key = lower(trim(line.substr(0, eq))); + const std::string value = eq == std::string::npos ? "" : trim(line.substr(eq + 1)); + const bool truth = lower(value) == "true"; + if (key == "alert") + cm.add_alert(value); + else if (key == "ignore_name") + cm.add_ignore_name(value); + else if (key == "match_name") + cm.add_match_name(value); + else if (key == "ignore_group") + cm.add_ignore_group(value); + else if (key == "match_group") + cm.add_match_group(value); + else if (key == "ignore_type") + cm.add_ignore_type(value); + else if (key == "match_type") + cm.add_match_type(value); + else if (key == "ignore_region") + cm.add_ignore_region(value); + else if (key == "match_region") + cm.add_match_region(value); + else if (key == "strict_ignore") + cm.set_strict_ignore(truth); + else if (key == "ownship_group") + cm.set_ownship_group(value); + else if (key == "ownship_type") + cm.set_ownship_type(value); + else if (key == "contact_max_age") + cm.set_contact_max_age(std::stod(value)); + else if (key == "reject_range") + cm.set_reject_range(lower(value) == "off" ? 0 : std::stod(value)); + else if (key == "max_contacts") + cm.set_max_contacts(std::stoul(value)); + else if (key == "decay") + { + const auto comma = value.find(','); + cm.set_decay_start(std::stod(value.substr(0, comma))); + cm.set_decay_end(std::stod(value.substr(comma + 1))); + } + else if (key == "hold_alerts_for_helm") + cm.set_hold_alerts_for_helm(truth); + else if (key == "alert_verbose") + cm.set_alert_verbose(truth); + else if (key == "disable_var") + cm.set_disable_var(value); + else if (key == "enable_var") + cm.set_enable_var(value); + else if (key == "expunge_var") + cm.set_expunge_var(value); + else if (key == "able_flag") + cm.add_able_flag(value); + else if (key == "disable_flag") + cm.add_disable_flag(value); + else if (key == "enable_flag") + cm.add_enable_flag(value); + else if (key == "early_warning_time") + cm.set_early_warning_time(std::stod(value)); + else if (key == "early_warning_flag") + cm.add_early_warning_flag(value); + else if (key == "cease_warning_flag") + cm.add_cease_warning_flag(value); + else if (key == "retire_flag") + cm.add_retire_flag(value); + else if (key != "apptick" && key != "commstick") + std::cout << " (pContactMgrV20 parameter not replayed: " << line << ")\n"; + } +} + +// pHelmIvP's (and pContactMgrV20's) blocks of the .moos file, as HelmConfig HelmConfig read_config(const fs::path& moos_file, const fs::path& dir) { HelmConfig cfg; std::ifstream in(moos_file); - bool in_block = false, in_helm = false; - std::vector helm_lines; + bool in_block = false, in_helm = false, in_cm = false; + std::vector helm_lines, cm_lines; for (std::string line; std::getline(in, line);) { line = trim(line.substr(0, line.find("//"))); @@ -164,6 +278,7 @@ HelmConfig read_config(const fs::path& moos_file, const fs::path& dir) if (key == "processconfig") { in_helm = value == "pHelmIvP"; + in_cm = value == "pContactMgrV20"; continue; } if (line == "{") @@ -173,12 +288,15 @@ HelmConfig read_config(const fs::path& moos_file, const fs::path& dir) } if (line == "}") { - in_block = in_helm = false; + in_block = in_helm = in_cm = false; continue; } if (in_block && in_helm) helm_lines.push_back(line); + if (in_block && in_cm) + cm_lines.push_back(line); } + read_contact_manager(cm_lines, *cfg.mutable_contact_manager()); // MOOS's mission reader hands pHelmIvP its configuration in reverse order, // which sets the order of the domain variables @@ -357,7 +475,13 @@ std::string life_event(const std::string& spec) bool compare(const std::string& stream, const std::vector& moos, const std::vector& ivpico) { + // a change within number_tolerance of the value before it is one helm + // seeing a difference the other didn't, from rounding + auto insignificant = [](const std::vector& changes, size_t k) + { return k > 0 && same_value(changes[k - 1].value, changes[k].value); }; + std::vector problems; + size_t numeric = 0; size_t i = 0, j = 0; while (i < moos.size() && j < ivpico.size()) { @@ -367,6 +491,23 @@ bool compare(const std::string& stream, const std::vector& moos, ++i, ++j; continue; } + const auto moos_parts = split_numbers(moos[i].value); + const auto ivpico_parts = split_numbers(ivpico[j].value); + const bool only_numbers = moos[i].tick == ivpico[j].tick && + moos_parts.first == ivpico_parts.first && + moos_parts.second.size() == ivpico_parts.second.size(); + if (!only_numbers && insignificant(moos, i)) + { + ++i; + continue; + } + if (!only_numbers && insignificant(ivpico, j)) + { + ++j; + continue; + } + if (only_numbers) + ++numeric; problems.push_back("pHelmIvP iteration " + std::to_string(moos[i].tick) + ": \"" + moos[i].value + "\", IvPico iteration " + std::to_string(ivpico[j].tick) + ": \"" + ivpico[j].value + "\""); @@ -380,15 +521,22 @@ bool compare(const std::string& stream, const std::vector& moos, ++j; } for (; i < moos.size(); ++i) - problems.push_back("pHelmIvP iteration " + std::to_string(moos[i].tick) + ": \"" + - moos[i].value + "\", missing from IvPico"); + if (!insignificant(moos, i)) + problems.push_back("pHelmIvP iteration " + std::to_string(moos[i].tick) + ": \"" + + moos[i].value + "\", missing from IvPico"); for (; j < ivpico.size(); ++j) - problems.push_back("IvPico iteration " + std::to_string(ivpico[j].tick) + ": \"" + - ivpico[j].value + "\", missing from pHelmIvP"); + if (!insignificant(ivpico, j)) + problems.push_back("IvPico iteration " + std::to_string(ivpico[j].tick) + ": \"" + + ivpico[j].value + "\", missing from pHelmIvP"); - const bool ok = problems.size() <= max_mismatch * std::max(moos.size(), ivpico.size()); + const size_t changes = std::max(moos.size(), ivpico.size()); + const bool ok = problems.size() - numeric <= max_mismatch * changes && + numeric <= max_numeric_mismatch * changes; std::cout << (ok ? " ok " : " FAIL ") << stream << " (" << moos.size() << " changes, " - << problems.size() << " off)\n"; + << problems.size() << " off"; + if (numeric) + std::cout << ", " << numeric << " only in numbers"; + std::cout << ")\n"; for (size_t k = 0; k < problems.size() && k < report_mismatches; ++k) std::cout << " " << problems[k] << "\n"; if (problems.size() > report_mismatches) @@ -440,12 +588,20 @@ bool compare_desired(const std::string& var, double step, bool wrap, int main(int argc, char* argv[]) { - if (argc != 2 && argc != 3) + std::vector args(argv + 1, argv + argc); + const auto alerts_arg = std::find(args.begin(), args.end(), "--alerts"); + const bool alerts = alerts_arg != args.end(); + if (alerts) + args.erase(alerts_arg); + if (args.size() != 1 && args.size() != 2) { - std::cerr << "usage: replay [stream to print in full]\n"; + std::cerr << "usage: replay [--alerts] [stream to print in full]\n"; return 2; } - const fs::path dir = fs::path(argv[1]).lexically_normal(); + const std::string print_stream = args.size() == 2 ? args[1] : ""; + if (alerts) + tolerance = alerts_tolerance; + const fs::path dir = fs::path(args[0]).lexically_normal(); fs::path moos_file, alog_file; for (const auto& f : fs::directory_iterator(dir)) { @@ -456,9 +612,10 @@ int main(int argc, char* argv[]) alog_file = f.path(); } std::cout << "Replaying " << (dir.has_filename() ? dir : dir.parent_path()).filename().string() - << "\n"; + << (alerts ? " with the helm's own contact alerts" : "") << "\n"; - const HelmConfig cfg = read_config(moos_file, dir); + HelmConfig cfg = read_config(moos_file, dir); + cfg.set_contact_alerts(alerts); const Alog alog = read_alog(alog_file); auto is_helm = [](const Entry& e) { return e.source.rfind("pHelmIvP", 0) == 0; }; @@ -476,11 +633,31 @@ int main(int argc, char* argv[]) 1); }; + // How many contact reports pHelmIvP's ledger had taken in by each + // iteration, from its IVPHELM_LEDGER_SUMMARY ("now:1, reps:748, ..."). + // Relayed reports reach pHelmIvP too unevenly to place by their log times. + std::vector> reports_by_tick(ticks.size()); + for (const auto& e : alog.entries) + { + const auto reps = e.value.find("reps:"); + if (is_helm(e) && e.var == "IVPHELM_LEDGER_SUMMARY" && reps != std::string::npos) + reports_by_tick[tick_of(e.time)] = std::stoul(e.value.substr(reps + 5)); + } + auto is_report = [](const Entry& e) + { return e.var == "NODE_REPORT" || e.var == "AIS_REPORT" || e.var == "AIS_REPORT_LOCAL"; }; + + std::map registered; + for (const auto& e : alog.entries) + if (is_helm(e) && e.var == "IVPHELM_REGISTER") + registered[e.value] = true; + // pHelmIvP's side Streams moos; std::map> moos_desired; for (const auto& e : alog.entries) { + if (alerts && is_contact_manager(e.source)) + add_change(moos, "contact_manager " + e.var, tick_of(e.time), e.value); if (!is_helm(e)) continue; const int k = tick_of(e.time); @@ -513,7 +690,24 @@ int main(int argc, char* argv[]) Streams ivpico; std::map> ivpico_desired; - size_t next_input = 0; + auto input = [&](const Entry& e) + { + ivp::interface::Variable v; + v.set_time(static_cast((alog.logstart + e.time) * 1e6)); + v.set_key(e.var); + double d; + if (is_number(e.value, &d)) + v.set_dval(d); + else + v.set_sval(e.value); + helm.handle(v); + }; + std::vector reports; + for (const auto& e : alog.entries) + if (!is_helm(e) && is_report(e)) + reports.push_back(&e); + + size_t next_input = 0, next_report = 0; for (size_t k = 0; k < ticks.size(); ++k) { for (; next_input < alog.entries.size() && @@ -521,18 +715,15 @@ int main(int argc, char* argv[]) ++next_input) { const Entry& e = alog.entries[next_input]; - if (is_helm(e)) + if (is_helm(e) || (alerts && is_contact_manager(e.source)) || is_report(e)) continue; - ivp::interface::Variable v; - v.set_time(static_cast((alog.logstart + e.time) * 1e6)); - v.set_key(e.var); - double d; - if (is_number(e.value, &d)) - v.set_dval(d); - else - v.set_sval(e.value); - helm.handle(v); + input(e); } + for (; next_report < reports.size() && + (reports_by_tick[k] ? next_report < *reports_by_tick[k] + : reports[next_report]->time <= ticks[k] - mail_latency); + ++next_report) + input(*reports[next_report]); const Output& out = helm.iterate(alog.logstart + ticks[k]); const int tick = static_cast(k); @@ -563,6 +754,11 @@ int main(int argc, char* argv[]) case ivp::interface::Posting::BEHAVIOR: add_change(ivpico, p.behavior() + " " + p.key(), tick, value); break; + // the recording has only the posts to variables pHelmIvP registered + case ivp::interface::Posting::CONTACT_MANAGER: + if (registered.count(p.key())) + add_change(ivpico, "contact_manager " + p.key(), tick, value); + break; default: break; } } @@ -600,20 +796,30 @@ int main(int argc, char* argv[]) std::map names; for (const auto& [name, changes] : moos) names[name] = true; for (const auto& [name, changes] : ivpico) names[name] = true; - for (const auto& [name, unused] : names) ok = compare(name, moos[name], ivpico[name]) && ok; + auto structural = [](const std::string& name) + { + return name == "IVPHELM_STATE" || name == "IVPHELM_ALLSTOP" || + name == "IVPHELM_LIFE_EVENT" || name == "IVPHELM_BHV_ACTIVE" || + name.rfind("mode ", 0) == 0 || name.rfind("contact_manager ", 0) == 0; + }; + for (const auto& [name, unused] : names) + if (!alerts || structural(name)) + ok = compare(name, moos[name], ivpico[name]) && ok; - if (argc == 3) + if (!print_stream.empty()) { - std::cout << "pHelmIvP " << argv[2] << ":\n"; - for (const auto& c : moos[argv[2]]) std::cout << " " << c.tick << " " << c.value << "\n"; - std::cout << "IvPico " << argv[2] << ":\n"; - for (const auto& c : ivpico[argv[2]]) std::cout << " " << c.tick << " " << c.value << "\n"; + std::cout << "pHelmIvP " << print_stream << ":\n"; + for (const auto& c : moos[print_stream]) + std::cout << " " << c.tick << " " << c.value << "\n"; + std::cout << "IvPico " << print_stream << ":\n"; + for (const auto& c : ivpico[print_stream]) + std::cout << " " << c.tick << " " << c.value << "\n"; } std::map desired_vars; for (const auto& [var, values] : moos_desired) desired_vars[var] = true; for (const auto& [var, values] : ivpico_desired) desired_vars[var] = true; - for (const auto& [var, unused] : desired_vars) + for (const auto& [var, unused] : alerts ? decltype(desired_vars)() : desired_vars) { double step = 0; bool wrap = false;