From 827179e09e9d72c0c8283c29be14e0be12d41a66 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 2 Aug 2017 09:56:12 +0200 Subject: [PATCH 01/14] [issue #892] Added yaml Dependencies --- Deps/python/Modules/yaml/CMakeLists.txt | 12 ++++++++++++ Deps/ros/CMakeLists.txt | 2 +- Deps/yaml-cpp/CMakeLists.txt | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Deps/python/Modules/yaml/CMakeLists.txt create mode 100644 Deps/yaml-cpp/CMakeLists.txt diff --git a/Deps/python/Modules/yaml/CMakeLists.txt b/Deps/python/Modules/yaml/CMakeLists.txt new file mode 100644 index 000000000..5db4c3a01 --- /dev/null +++ b/Deps/python/Modules/yaml/CMakeLists.txt @@ -0,0 +1,12 @@ +set(module "yaml") + +usePython(2) +find_python_module(${module} REQUIRED) + +string(TOUPPER ${module} module_upper) + +if(PY_${module_upper}) + SET (yaml_PY_MODULES PY_${module_upper}) + list(APPEND DEPS python-yaml) + list(APPEND DEPS_DEV python-yaml) +endif(PY_${module_upper}) \ No newline at end of file diff --git a/Deps/ros/CMakeLists.txt b/Deps/ros/CMakeLists.txt index 3ca921592..f5a23308b 100644 --- a/Deps/ros/CMakeLists.txt +++ b/Deps/ros/CMakeLists.txt @@ -22,7 +22,7 @@ if (ENABLE_ROS) kobuki_gazebo ) - list(APPEND DEPS ros-kinetic-roscpp ros-kinetic-std-msgs ros-kinetic-cv-bridge ros-kinetic-image-transport ros-kinetic-roscpp-core ros-kinetic-rospy ros-kinetic-nav-msgs ros-kinetic-geometry-msgs ros-kinetic-kobuki-gazebo ros-kinetic-turtlebot-gazebo) + list(APPEND DEPS ros-kinetic-roscpp ros-kinetic-std-msgs ros-kinetic-cv-bridge ros-kinetic-image-transport ros-kinetic-roscpp-core ros-kinetic-rospy ros-kinetic-nav-msgs ros-kinetic-geometry-msgs ros-kinetic-kobuki-gazebo) # list(APPEND DEPS_DEV ) else() diff --git a/Deps/yaml-cpp/CMakeLists.txt b/Deps/yaml-cpp/CMakeLists.txt new file mode 100644 index 000000000..00fa78b5b --- /dev/null +++ b/Deps/yaml-cpp/CMakeLists.txt @@ -0,0 +1,9 @@ +find_package(yaml-cpp) + +if (YAML_CPP_INCLUDE_DIR) + message("***YAML-CPP FOUND: ${YAML_CPP_INCLUDE_DIR}") + list(APPEND DEPS libyaml-cpp0.5v5) + list(APPEND DEPS_DEV libyaml-cpp-dev) +else() + message ("*** YAML-CPP NOT FOUND") +endIF() From 6031ec74615dff657c191c059cd837a96e94c8c8 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 2 Aug 2017 10:13:29 +0200 Subject: [PATCH 02/14] [issue #892] created config python library to read new yaml config files --- src/libs/config_py/.gitignore | 108 +++ src/libs/config_py/CMakeLists.txt | 8 + src/libs/config_py/LICENSE | 675 ++++++++++++++++++ src/libs/config_py/demo.py | 27 + src/libs/config_py/jderobotconfig/__init__.py | 9 + src/libs/config_py/jderobotconfig/config.py | 74 ++ .../jderobotconfig/hardcodedpaths.py.in | 49 ++ 7 files changed, 950 insertions(+) create mode 100644 src/libs/config_py/.gitignore create mode 100644 src/libs/config_py/CMakeLists.txt create mode 100644 src/libs/config_py/LICENSE create mode 100644 src/libs/config_py/demo.py create mode 100644 src/libs/config_py/jderobotconfig/__init__.py create mode 100644 src/libs/config_py/jderobotconfig/config.py create mode 100644 src/libs/config_py/jderobotconfig/hardcodedpaths.py.in diff --git a/src/libs/config_py/.gitignore b/src/libs/config_py/.gitignore new file mode 100644 index 000000000..2e96e31b7 --- /dev/null +++ b/src/libs/config_py/.gitignore @@ -0,0 +1,108 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + + +# https://raw.githubusercontent.com/github/gitignore/master/Global/JetBrains.gitignore +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm + +*.iml + +## Directory-based project format: +.idea/ +# if you remove the above rule, at least ignore the following: + +# User-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# .idea/dictionaries +# .idea/shelf + +# Sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml +# .idea/uiDesigner.xml + +# Gradle: +# .idea/gradle.xml +# .idea/libraries + +# Mongo Explorer plugin: +# .idea/mongoSettings.xml + +## File-based project format: +*.ipr +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties diff --git a/src/libs/config_py/CMakeLists.txt b/src/libs/config_py/CMakeLists.txt new file mode 100644 index 000000000..920405185 --- /dev/null +++ b/src/libs/config_py/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8) + +configure_module_python(jderobotconfig) + +add_custom_target(jderobotconfig_py ALL) +copy_to_binary_python(jderobotconfig_py jderobotconfig) + +install_python(jderobotconfig core) diff --git a/src/libs/config_py/LICENSE b/src/libs/config_py/LICENSE new file mode 100644 index 000000000..733c07236 --- /dev/null +++ b/src/libs/config_py/LICENSE @@ -0,0 +1,675 @@ + 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. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + 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: + + {project} Copyright (C) {year} {fullname} + 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/src/libs/config_py/demo.py b/src/libs/config_py/demo.py new file mode 100644 index 000000000..51c3f6caa --- /dev/null +++ b/src/libs/config_py/demo.py @@ -0,0 +1,27 @@ +# +# Copyright (C) 1997-2015 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Victor Arribas Raigadas +# +__author__ = 'varribas' + +import sys + +import jderobotconfig as config + +cfg = config.load(sys.argv[1]) +print config.dump(cfg) + diff --git a/src/libs/config_py/jderobotconfig/__init__.py b/src/libs/config_py/jderobotconfig/__init__.py new file mode 100644 index 000000000..f62ff62a3 --- /dev/null +++ b/src/libs/config_py/jderobotconfig/__init__.py @@ -0,0 +1,9 @@ +__author__ = 'aitormf' + +## import simplification +# empty __init__.py: +# from jderobotconfig import config as config +# new option: +# import jderobotconfig as config +from .config import * + diff --git a/src/libs/config_py/jderobotconfig/config.py b/src/libs/config_py/jderobotconfig/config.py new file mode 100644 index 000000000..f2f60feb0 --- /dev/null +++ b/src/libs/config_py/jderobotconfig/config.py @@ -0,0 +1,74 @@ +# +# Copyright (C) 1997-2017 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Aitor Martinez Fernandez +# +__author__ = 'aitormf' + +import sys, os +import yaml +from .hardcodedpaths import HARDCODED_PATHS + + +def findConfigFile(filename): + ''' + Returns filePath or None if it couldn't find the file + + @param filename: Name of the file + + @type filename: String + + @return String with path or None + + ''' + paths = "." + if HARDCODED_PATHS: + paths = paths+":"+HARDCODED_PATHS + + for path in paths.split(":"): + file_path = os.path.join(path, filename) + if os.path.exists(file_path): + return file_path + + return None + + +def load(filename): + ''' + Returns the configuration as dict + + @param filename: Name of the file + + @type filename: String + + @return a dict with propierties reader from file + + ''' + filepath = findConfigFile(filename) + properties= None + if (filepath): + print ('loading Config file %s' %(filepath)) + + with open(filepath, 'r') as stream: + properties=yaml.load(stream) + else: + msg = "Ice.Config file '%s' could not being found" % (filename) + raise ValueError(msg) + + return properties + +def dump(conf): + return yaml.dump(conf) diff --git a/src/libs/config_py/jderobotconfig/hardcodedpaths.py.in b/src/libs/config_py/jderobotconfig/hardcodedpaths.py.in new file mode 100644 index 000000000..2bf148bb6 --- /dev/null +++ b/src/libs/config_py/jderobotconfig/hardcodedpaths.py.in @@ -0,0 +1,49 @@ +# +# Copyright (C) 1997-2017 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Victor Arribas Raigadas +# +__author__ = 'varribas' + +import os +import platform + +if ('Windows')==platform.system(): + JDEROBOT_PATHS = "" + JDEROBOT_GAZEBO_PLUGINS_PATHS = "" +else: + # JdeRobot main Ice.Config path + JDEROBOT_PATHS = "@CMAKE_INSTALL_PREFIX@/share/jderobot/conf" + + + # JdeRobot Gazebo's plugins Ice.Config path + JDEROBOT_GAZEBO_PLUGINS_BASE_PATH = '@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins' + + if os.path.exists(JDEROBOT_GAZEBO_PLUGINS_BASE_PATH): + + gazebo_plugins = list() + for dir in os.listdir(JDEROBOT_GAZEBO_PLUGINS_BASE_PATH): + plugin_dir = os.path.join(JDEROBOT_GAZEBO_PLUGINS_BASE_PATH, dir) + gazebo_plugins.append(plugin_dir) + + JDEROBOT_GAZEBO_PLUGINS_PATHS = ':'.join(str(x) for x in gazebo_plugins) + + else: + JDEROBOT_GAZEBO_PLUGINS_PATHS = "" + + +# "Hardcoded" PATHS +HARDCODED_PATHS = "%s:%s" %(JDEROBOT_PATHS, JDEROBOT_GAZEBO_PLUGINS_PATHS) From d2f4d824a6301fb721a02f1291c9aeaff5633d24 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 2 Aug 2017 10:46:34 +0200 Subject: [PATCH 03/14] [issue #892] Updated jderobotComm_py to use new configuration instead of ice files --- .../jderobotcomm_py/jderobotComm/__init__.py | 46 +------- .../jderobotComm/cameraClient.py.only-ice.in | 40 +++---- .../jderobotComm/cameraClient.py.ros.in | 44 +++---- .../jderobotComm/communicator.py.only-ice.in | 103 ++++++++++++++++ .../jderobotComm/communicator.py.ros.in | 110 ++++++++++++++++++ .../jderobotComm/ice/cameraIceClient.py | 26 +++-- .../jderobotComm/laserClient.py.only-ice.in | 46 ++++---- .../jderobotComm/laserClient.py.ros.in | 50 ++++---- .../jderobotComm/motorsClient.py.only-ice.in | 44 +++---- .../jderobotComm/motorsClient.py.ros.in | 64 +++++----- .../jderobotComm/pose3dClient.py.only-ice.in | 44 +++---- .../jderobotComm/pose3dClient.py.ros.in | 48 ++++---- .../jderobotComm/ros/listenerCamera.py | 9 ++ src/libs/jderobotcomm_py/test.cfg | 36 ------ src/libs/jderobotcomm_py/test.yml | 36 ++++++ src/libs/jderobotcomm_py/testCamera.py | 14 +-- src/libs/jderobotcomm_py/testLaser.py | 14 +-- src/libs/jderobotcomm_py/testMotors.py | 11 +- src/libs/jderobotcomm_py/testPose.py | 10 +- 19 files changed, 492 insertions(+), 303 deletions(-) create mode 100644 src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in create mode 100644 src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in delete mode 100644 src/libs/jderobotcomm_py/test.cfg create mode 100644 src/libs/jderobotcomm_py/test.yml diff --git a/src/libs/jderobotcomm_py/jderobotComm/__init__.py b/src/libs/jderobotcomm_py/jderobotComm/__init__.py index fce5fb55b..5f38f420f 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/__init__.py +++ b/src/libs/jderobotcomm_py/jderobotComm/__init__.py @@ -1,51 +1,17 @@ -import Ice -import rospy +from .communicator import Communicator -from .laserClient import getLaserClient -from .cameraClient import getCameraClient -from .pose3dClient import getPose3dClient -from .motorsClient import getMotorsClient -def init (ic): - ''' - Starts ROS Node if it is necessary. - - @param ic: Ice Communicator - - @type ic: Ice Communicator - ''' - node = None - rosserver = False - - prop = ic.getProperties() - nodeName = prop.getPropertyWithDefault("NodeName", "JdeRobot") - - l = prop.getPropertiesForPrefix("") - keys = l.keys() - for i in keys: - if (i.endswith(".Server") and l[i] == "2"): - rosserver = True - - if (rosserver): - node = rospy.init_node(nodeName, anonymous=True) - - return ic,node -def destroy(ic=None, node=None): +def init (config): ''' - Destroys ROS Node and Ice Communicator if it is necessary. + Starts JdeRobotComm - @param ic: Ice Communicator - @param node: ROS Node + @param config: configuration of client - @type ic: Ice Communicator - @type node: ROS Node + @type config: dict ''' - if node: - rospy.signal_shutdown("Node Closed") - if ic: - ic.destroy() + return Communicator(config) diff --git a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in index 46b696f7e..6715b3e63 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in @@ -2,12 +2,12 @@ import sys import Ice from .ice.cameraIceClient import CameraIceClient -def __getCameraIceClient(ic, prefix): +def __getCameraIceClient(jdrc, prefix): ''' Returns a Camera Ice Client. This function should never be used. Use getCameraClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file @type ic: Ice Communicator @type prefix: String @@ -16,16 +16,16 @@ def __getCameraIceClient(ic, prefix): ''' print("Receiving " + prefix + " Image from ICE interfaces") - client = CameraIceClient(ic, prefix) + client = CameraIceClient(jdrc, prefix) client.start() return client -def __getListenerCamera(ic, prefix): +def __getListenerCamera(jdrc, prefix): ''' Returns a Camera ROS Subscriber. This function should never be used. Use getCameraClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file @type ic: Ice Communicator @type prefix: String @@ -37,12 +37,12 @@ def __getListenerCamera(ic, prefix): print(prefix + ": ROS msg are diabled") return None -def __Cameradisabled(ic, prefix): +def __Cameradisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getCameraClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file @type ic: Ice Communicator @type prefix: String @@ -53,24 +53,24 @@ def __Cameradisabled(ic, prefix): print( prefix + " Disabled") return None -def getCameraClient (ic, prefix, node=None): +def getCameraClient (jdrc, name): ''' Returns a Camera Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file - @param node: ROS node + @param jdrc: JdeRobotComm Communicator + @param name: name of client in config file - @type ic: Ice Communicator - @type prefix: String - @type node: ROS node + @type jdrc: JdeRobotComm Communicator + @type name: String @return None if Camera is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Cameradisabled, __getCameraIceClient, __getListenerCamera] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, name) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in index a98a8ca46..84bd3f9d8 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in @@ -6,12 +6,12 @@ from .ice.cameraIceClient import CameraIceClient if (sys.version_info[0] == 2): from .ros.listenerCamera import ListenerCamera -def __getCameraIceClient(ic, prefix): +def __getCameraIceClient(jdrc, prefix): ''' Returns a Camera Ice Client. This function should never be used. Use getCameraClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file @type ic: Ice Communicator @type prefix: String @@ -20,16 +20,16 @@ def __getCameraIceClient(ic, prefix): ''' print("Receiving " + prefix + " Image from ICE interfaces") - client = CameraIceClient(ic, prefix) + client = CameraIceClient(jdrc, prefix) client.start() return client -def __getListenerCamera(ic, prefix): +def __getListenerCamera(jdrc, prefix): ''' Returns a Camera ROS Subscriber. This function should never be used. Use getCameraClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file @type ic: Ice Communicator @type prefix: String @@ -39,20 +39,20 @@ def __getListenerCamera(ic, prefix): ''' if (sys.version_info[0] == 2): print("Receiving " + prefix + " Image from ROS messages") - prop = prop = ic.getProperties() - topic = prop.getPropertyWithDefault(prefix+".Topic",""); + cfg = jdrc.getConfig(prefix) + topic = cfg["Topic"] client = ListenerCamera(topic) return client else: print(prefix + ": ROS msg are diabled for python "+ sys.version_info[0]) return None -def __Cameradisabled(ic, prefix): +def __Cameradisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getCameraClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file @type ic: Ice Communicator @type prefix: String @@ -63,24 +63,24 @@ def __Cameradisabled(ic, prefix): print( prefix + " Disabled") return None -def getCameraClient (ic, prefix, node=None): +def getCameraClient (jdrc, name): ''' Returns a Camera Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file - @param node: ROS node + @param jdrc: JdeRobotComm Communicator + @param name: name of client in config file - @type ic: Ice Communicator - @type prefix: String - @type node: ROS node + @type jdrc: JdeRobotComm Communicator + @type name: String @return None if Camera is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Cameradisabled, __getCameraIceClient, __getListenerCamera] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, cfg) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in new file mode 100644 index 000000000..a2b568735 --- /dev/null +++ b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in @@ -0,0 +1,103 @@ +import Ice + +from .laserClient import getLaserClient +from .cameraClient import getCameraClient +from .pose3dClient import getPose3dClient +from .motorsClient import getMotorsClient + + +class Communicator: + ''' + JdeRobotComm Communicator class + + ''' + def __init__ (self, config): + ''' + Communicator constructor + + @param config: configuration of communicator + + @type config: dict + + ''' + rosserver = False + iceserver = False + + self.__node = None + self.__ic = None + self.config = config + + for i in self.config: + if type(self.config[i]) is dict and self.config[i]["Server"] == 1: + iceserver = True + + if iceserver: + id = Ice.InitializationData() + self.__ic = Ice.initialize(None, id) + + def destroy (self): + ''' + Destroys ROS Node and Ice Communicator if it is necessary. + + ''' + if self.__ic: + self.__ic.shutdown() + self.__ic.destroy() + + def getNode(self): + return self.__node + + def getIc(self): + return self.__ic + + def getConfig(self, name=None): + if name: + return self.config[name] + else: + return self.config + + + def getCameraClient(self, name): + ''' + Returns a Camera client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getCameraClient(self, name) + + def getMotorsClient(self, name): + ''' + Returns a Motors client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getMotorsClient(self, name) + + def getPose3dClient(self, name): + ''' + Returns a Pose3D client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getPose3dClient(self, name) + + def getLaserClient(self, name): + ''' + Returns a Laser client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getLaserClient(self, name) + diff --git a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in new file mode 100644 index 000000000..5e100846e --- /dev/null +++ b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in @@ -0,0 +1,110 @@ +import Ice +import rospy + +from .laserClient import getLaserClient +from .cameraClient import getCameraClient +from .pose3dClient import getPose3dClient +from .motorsClient import getMotorsClient + + +class Communicator: + ''' + JdeRobotComm Communicator class + + ''' + def __init__ (self, config): + ''' + Communicator constructor + + @param config: configuration of communicator + + @type config: dict + + ''' + rosserver = False + iceserver = False + + self.__node = None + self.__ic = None + self.config = config + + for i in self.config: + if type(self.config[i]) is dict and self.config[i]["Server"] == 1: + iceserver = True + if type(self.config[i]) is dict and self.config[i]["Server"] == 2: + rosserver = True + + if rosserver: + self.__node = rospy.init_node(config["NodeName"], anonymous=True) + if iceserver: + id = Ice.InitializationData() + self.__ic = Ice.initialize(None, id) + + def destroy (self): + ''' + Destroys ROS Node and Ice Communicator if it is necessary. + + ''' + if self.__node: + rospy.signal_shutdown("Node Closed") + if self.__ic: + self.__ic.shutdown() + self.__ic.destroy() + + def getNode(self): + return self.__node + + def getIc(self): + return self.__ic + + def getConfig(self, name=None): + if name: + return self.config[name] + else: + return self.config + + + def getCameraClient(self, name): + ''' + Returns a Camera client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getCameraClient(self, name) + + def getMotorsClient(self, name): + ''' + Returns a Motors client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getMotorsClient(self, name) + + def getPose3dClient(self, name): + ''' + Returns a Pose3D client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getPose3dClient(self, name) + + def getLaserClient(self, name): + ''' + Returns a Laser client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getLaserClient(self, name) + diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py b/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py index ef78c2658..d276dea00 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py +++ b/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py @@ -31,15 +31,15 @@ class Camera: Camera Connector. Recives image from Ice interface when you run update method. ''' - def __init__(self, ic, prefix): + def __init__(self, jdrc, prefix): ''' Camera Contructor. Exits When it receives a Exception diferent to Ice.ConnectionRefusedException - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String ''' @@ -47,10 +47,12 @@ def __init__(self, ic, prefix): self.image = Image() try: - basecamera = ic.propertyToProxy(prefix+".Proxy") + + cfg = jdrc.getConfig(prefix) + ic = jdrc.getIc() + basecamera = ic.stringToProxy(cfg["Proxy"]) self.proxy = jderobot.CameraPrx.checkedCast(basecamera) - prop = ic.getProperties() - self.imgFormat = prop.getProperty(prefix+".Format") + self.imgFormat = cfg["Format"] if not self.imgFormat: self.imgFormat = "RGB8" @@ -117,19 +119,19 @@ class CameraIceClient: ''' Camera Ice Client. Recives image from Ice interface running camera update method in a thread. ''' - def __init__(self,ic,prefix, start = False): + def __init__(self,jdrc,prefix, start = False): ''' CameraIceClient Contructor. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file @param start: indicates if start automatically the client - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @type start: Boolean ''' - self.camera = Camera(ic,prefix) + self.camera = Camera(jdrc,prefix) self.kill_event = threading.Event() self.thread = ThreadSensor(self.camera, self.kill_event) diff --git a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in index 7f25d9e74..6dfeff5a8 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in @@ -3,32 +3,32 @@ import Ice from .ice.laserIceClient import LaserIceClient -def __getLaserIceClient(ic, prefix): +def __getLaserIceClient(jdrc, prefix): ''' Returns a Laser Ice Client. This function should never be used. Use getLaserClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Laser Ice Client ''' print("Receiving " + prefix + " LaserData from ICE interfaces") - client = LaserIceClient(ic, prefix) + client = LaserIceClient(jdrc, prefix) client.start() return client -def __getListenerLaser(ic, prefix): +def __getListenerLaser(jdrc, prefix): ''' Returns a Laser ROS Subscriber. This function should never be used. Use getLaserClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Laser ROS Subscriber @@ -37,14 +37,14 @@ def __getListenerLaser(ic, prefix): print(prefix + ": ROS msg are diabled") return None -def __Laserdisabled(ic, prefix): +def __Laserdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getLaserClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return None @@ -53,24 +53,24 @@ def __Laserdisabled(ic, prefix): print( prefix + " Disabled") return None -def getLaserClient (ic, prefix, node=None): +def getLaserClient (jdrc, name): ''' Returns a Laser Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file - @param node: ROS node + @param jdrc: JdeRobotComm Communicator + @param name: name of client in config file - @type ic: Ice Communicator - @type prefix: String - @type node: ROS node + @type jdrc: JdeRobotComm Communicator + @type name: String @return None if Laser is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Laserdisabled, __getLaserIceClient, __getListenerLaser] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in index 934cd025e..16af57f99 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in @@ -6,32 +6,32 @@ from .ice.laserIceClient import LaserIceClient if (sys.version_info[0] == 2): from .ros.listenerLaser import ListenerLaser -def __getLaserIceClient(ic, prefix): +def __getLaserIceClient(jdrc, prefix): ''' Returns a Laser Ice Client. This function should never be used. Use getLaserClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Laser Ice Client ''' print("Receiving " + prefix + " LaserData from ICE interfaces") - client = LaserIceClient(ic, prefix) + client = LaserIceClient(jdrc, prefix) client.start() return client -def __getListenerLaser(ic, prefix): +def __getListenerLaser(jdrc, prefix): ''' Returns a Laser ROS Subscriber. This function should never be used. Use getLaserClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Laser ROS Subscriber @@ -39,22 +39,22 @@ def __getListenerLaser(ic, prefix): ''' if (sys.version_info[0] == 2): print("Receiving " + prefix + " LaserData from ROS messages") - prop = prop = ic.getProperties() - topic = prop.getPropertyWithDefault(prefix+".Topic",""); + cfg = jdrc.getConfig(prefix) + topic = cfg["Topic"] client = ListenerLaser(topic) return client else: print(prefix + ": ROS msg are diabled for python "+ sys.version_info[0]) return None -def __Laserdisabled(ic, prefix): +def __Laserdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getLaserClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return None @@ -63,24 +63,24 @@ def __Laserdisabled(ic, prefix): print( prefix + " Disabled") return None -def getLaserClient (ic, prefix, node=None): +def getLaserClient (jdrc, name): ''' Returns a Laser Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file - @param node: ROS node + @param jdrc: JdeRobotComm Communicator + @param name: name of client in config file - @type ic: Ice Communicator - @type prefix: String - @type node: ROS node + @type jdrc: JdeRobotComm Communicator + @type name: String @return None if Laser is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Laserdisabled, __getLaserIceClient, __getListenerLaser] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in index 63dff0f06..42908682b 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in @@ -4,32 +4,32 @@ from .ice.motorsIceClient import MotorsIceClient -def __getMotorsIceClient(ic, prefix): +def __getMotorsIceClient(jdrc, prefix): ''' Returns a Motors Ice Client. This function should never be used. Use getMotorsClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Motors Ice Client ''' - print("Publishing Motors with ICE interfaces") - client = MotorsIceClient(ic, prefix) + print("Publishing "+ prefix +" with ICE interfaces") + client = MotorsIceClient(jdrc, prefix) client.start() return client -def __getPublisherMotors(ic, prefix): +def __getPublisherMotors(jdrc, prefix): ''' Returns a Motors ROS Publisher. This function should never be used. Use getMotorsClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Motors ROS Publisher @@ -39,14 +39,14 @@ def __getPublisherMotors(ic, prefix): print(prefix + ": ROS msg are diabled") return None -def __Motorsdisabled(ic, prefix): +def __Motorsdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getMotorsClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return None @@ -55,24 +55,26 @@ def __Motorsdisabled(ic, prefix): print(prefix + " Disabled") return None -def getMotorsClient (ic, prefix, node=None): +def getMotorsClient (jdrc, name): ''' Returns a Motors Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file @param node: ROS node - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @type node: ROS node @return None if Motors is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Motorsdisabled, __getMotorsIceClient, __getPublisherMotors] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, name) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in index 787d5f9c9..2bf9e17a2 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in @@ -6,54 +6,50 @@ from .ice.motorsIceClient import MotorsIceClient if (sys.version_info[0] == 2): from .ros.publisherMotors import PublisherMotors -def __getMotorsIceClient(ic, prefix): +def __getMotorsIceClient(jdrc, prefix): ''' Returns a Motors Ice Client. This function should never be used. Use getMotorsClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Motors Ice Client ''' - print("Publishing Motors with ICE interfaces") - client = MotorsIceClient(ic, prefix) + print("Publishing "+ prefix +" with ICE interfaces") + client = MotorsIceClient(jdrc, prefix) client.start() return client -def __getPublisherMotors(ic, prefix): +def __getPublisherMotors(jdrc, prefix): ''' Returns a Motors ROS Publisher. This function should never be used. Use getMotorsClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Motors ROS Publisher ''' if (sys.version_info[0] == 2): - print("Publishing Motors with ROS messages") - prop = prop = ic.getProperties() - topic = prop.getPropertyWithDefault(prefix+".Topic","") - - maxWstr = prop.getProperty(prefix+".maxW") - if maxWstr: - maxW = float(maxWstr) - else: + print("Publishing "+ prefix + " with ROS messages") + cfg = jdrc.getConfig(prefix) + topic = cfg["Topic"] + + maxW = cfg["maxW"] + if not maxW: maxW = 0.5 print (prefix+".maxW not provided, the default value is used: "+ repr(maxW)) - maxVstr = prop.getProperty(prefix+".maxV") - if maxWstr: - maxV = float(maxVstr) - else: + maxV = cfg["maxV"] + if not maxV: maxV = 5 print (prefix+".maxV not provided, the default value is used: "+ repr(maxV)) @@ -64,14 +60,14 @@ def __getPublisherMotors(ic, prefix): print(prefix + ": ROS msg are diabled for python "+ sys.version_info[0]) return None -def __Motorsdisabled(ic, prefix): +def __Motorsdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getMotorsClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return None @@ -80,24 +76,26 @@ def __Motorsdisabled(ic, prefix): print(prefix + " Disabled") return None -def getMotorsClient (ic, prefix, node=None): +def getMotorsClient (jdrc, name): ''' Returns a Motors Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: Name of client in config file @param node: ROS node - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @type node: ROS node @return None if Motors is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Motorsdisabled, __getMotorsIceClient, __getPublisherMotors] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, name) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in index adb4b3163..d9a6aeff5 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in @@ -3,32 +3,32 @@ import Ice from .ice.pose3dIceClient import Pose3dIceClient -def __getPoseIceClient(ic, prefix): +def __getPoseIceClient(jdrc, prefix): ''' Returns a Pose3D Ice Client. This function should never be used. Use getPose3dClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @@param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Pose3D Ice Client ''' print("Receiving " + prefix + " from ICE interfaces") - client = Pose3dIceClient(ic, prefix) + client = Pose3dIceClient(jdrc, prefix) client.start() return client -def __getListenerPose(ic, prefix): +def __getListenerPose(jdrc, prefix): ''' Returns a Pose3D ROS Subscriber. This function should never be used. Use getPose3dClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Pose3D ROS Subscriber @@ -38,14 +38,14 @@ def __getListenerPose(ic, prefix): return None -def __Posedisabled(ic, prefix): +def __Posedisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getPose3dClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return None @@ -54,24 +54,24 @@ def __Posedisabled(ic, prefix): print(prefix + " Disabled") return None -def getPose3dClient (ic, prefix, node=None): +def getPose3dClient (jdrc, prefix): ''' Returns a Pose3D Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file - @param node: ROS node + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String - @type node: ROS node @return None if pose3d is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Posedisabled, __getPoseIceClient, __getListenerPose] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in index f052ce976..4236e4931 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in @@ -8,32 +8,32 @@ if (sys.version_info[0] == 2): -def __getPoseIceClient(ic, prefix): +def __getPoseIceClient(jdrc, prefix): ''' Returns a Pose3D Ice Client. This function should never be used. Use getPose3dClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @@param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Pose3D Ice Client ''' print("Receiving " + prefix + " from ICE interfaces") - client = Pose3dIceClient(ic, prefix) + client = Pose3dIceClient(jdrc, prefix) client.start() return client -def __getListenerPose(ic, prefix): +def __getListenerPose(jdrc, prefix): ''' Returns a Pose3D ROS Subscriber. This function should never be used. Use getPose3dClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return Pose3D ROS Subscriber @@ -41,8 +41,8 @@ def __getListenerPose(ic, prefix): ''' if (sys.version_info[0] == 2): print("Receiving " + prefix + " from ROS messages") - prop = prop = ic.getProperties() - topic = prop.getPropertyWithDefault(prefix+".Topic",""); + cfg = jdrc.getConfig(prefix) + topic = cfg["Topic"] client = ListenerPose3d(topic) return client else: @@ -50,14 +50,14 @@ def __getListenerPose(ic, prefix): return None -def __Posedisabled(ic, prefix): +def __Posedisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getPose3dClient instead of this - @param ic: Ice Communicator - @param prefix: prefix name of client in config file + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String @return None @@ -66,24 +66,24 @@ def __Posedisabled(ic, prefix): print(prefix + " Disabled") return None -def getPose3dClient (ic, prefix, node=None): +def getPose3dClient (jdrc, prefix): ''' Returns a Pose3D Client. - @param ic: Ice Communicator - @param prefix: prefix name of client in config file - @param node: ROS node + @param jdrc: JdeRobotComm Communicator + @param prefix: name of client in config file - @type ic: Ice Communicator + @type jdrc: JdeRobotComm Communicator @type prefix: String - @type node: ROS node @return None if pose3d is disabled ''' - prop = prop = ic.getProperties() - server = prop.getPropertyAsIntWithDefault(prefix+".Server",0) + cfg = jdrc.getConfig(name) + server = cfg["Server"] + if not server: + server=0 cons = [__Posedisabled, __getPoseIceClient, __getListenerPose] - return cons[server](ic, prefix) \ No newline at end of file + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/ros/listenerCamera.py b/src/libs/jderobotcomm_py/jderobotComm/ros/listenerCamera.py index a16ecf7e9..a9376dedb 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ros/listenerCamera.py +++ b/src/libs/jderobotcomm_py/jderobotComm/ros/listenerCamera.py @@ -95,4 +95,13 @@ def getImage(self): return image + def hasproxy (self): + ''' + Returns if Subscriber has ben created or not. + + @return if Subscriber has ben created or not (Boolean) + + ''' + return hasattr(self,"sub") and self.sub + diff --git a/src/libs/jderobotcomm_py/test.cfg b/src/libs/jderobotcomm_py/test.cfg deleted file mode 100644 index b14bdd63f..000000000 --- a/src/libs/jderobotcomm_py/test.cfg +++ /dev/null @@ -1,36 +0,0 @@ - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Motors.Server=2 -kobukiViewer.Motors.Proxy=Motors:tcp -h localhost -p 9001 -kobukiViewer.Motors.Topic=/cmd_vel_mux/input/teleop -kobukiViewer.Motors.Name=kobukiViewerMotors - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Pose3D.Server=2 -kobukiViewer.Pose3D.Proxy=Pose3D:tcp -h localhost -p 9001 -kobukiViewer.Pose3D.Topic=/odom -kobukiViewer.Pose3D.Name=kobukiViewerPose3d - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Camera1.Server=2 -kobukiViewer.Camera1.Proxy=CameraL:tcp -h localhost -p 9001 -kobukiViewer.Camera1.Format=RGB8 -kobukiViewer.Camera1.Topic=/camera/rgb/image_raw -kobukiViewer.Camera1.Name=kobukiViewerCamera1 - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Camera2.Server=1 -kobukiViewer.Camera2.Proxy=CameraR:tcp -h localhost -p 9001 -kobukiViewer.Camera2.Format=RGB8 -kobukiViewer.Camera2.Topic=/scan -kobukiViewer.Camera2.Name=kobukiViewerCamera2 - - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Laser.Server=2 -kobukiViewer.Laser.Proxy=Laser:tcp -h localhost -p 9001 -kobukiViewer.Laser.Topic=/scan -kobukiViewer.Laser.Name=kobukiViewerLaser - -kobukiViewer.Vmax=3 -kobukiViewer.Wmax=0.7 \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/test.yml b/src/libs/jderobotcomm_py/test.yml new file mode 100644 index 000000000..dbb538994 --- /dev/null +++ b/src/libs/jderobotcomm_py/test.yml @@ -0,0 +1,36 @@ +test: + Motors: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Motors:default -h localhost -p 9001" + Topic: "/cmd_vel_mux/input/teleop" + Name: testMotors + + Camera1: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera1 + + Camera2: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraR:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera2 + + Pose3D: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Pose3D:default -h localhost -p 9001" + Topic: "/odom" + Name: testPose3d + + Laser: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Laser:default -h localhost -p 9001" + Topic: "/scan" + Name: testLaser + + Vmax: 3 + Wmax: 0.7 + NodeName: JdeRobotCommTest \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/testCamera.py b/src/libs/jderobotcomm_py/testCamera.py index 75dc99e00..83c2dcaa3 100755 --- a/src/libs/jderobotcomm_py/testCamera.py +++ b/src/libs/jderobotcomm_py/testCamera.py @@ -1,21 +1,21 @@ -#!/usr/bin/env python3 -import easyiceconfig as EasyIce +#!/usr/bin/env python2 +import jderobotconfig as config import jderobotComm as comm import sys import time import signal -from jderobotTypes import LaserData +from jderobotTypes import Image if __name__ == '__main__': - ic = EasyIce.initialize(sys.argv) - ic, node = comm.init(ic) + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg["test"]) - client = comm.getCameraClient(ic, "kobukiViewer.Camera1") + client = jdrc.getCameraClient("Camera1") for i in range (10): #print("client1", end=":") @@ -26,7 +26,7 @@ client.stop() - comm.destroy(ic, node) + jdrc.destroy() diff --git a/src/libs/jderobotcomm_py/testLaser.py b/src/libs/jderobotcomm_py/testLaser.py index 39d3135e2..167155f6b 100755 --- a/src/libs/jderobotcomm_py/testLaser.py +++ b/src/libs/jderobotcomm_py/testLaser.py @@ -1,5 +1,5 @@ -#!/usr/bin/env python3 -import easyiceconfig as EasyIce +#!/usr/bin/env python2 +import jderobotconfig as config import jderobotComm as comm import sys import time @@ -12,11 +12,11 @@ if __name__ == '__main__': - ic = EasyIce.initialize(sys.argv) - ic, node = comm.init(ic) + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg["test"]) - client = comm.getLaserClient(ic, "kobukiViewer.Laser") - client2 = comm.getLaserClient(ic, "kobukiViewer.Laser") + client = jdrc.getLaserClient(ic, "Laser") + client2 = jdrc.getLaserClient(ic, "Laser") for i in range (10): #print("client1", end=":") @@ -30,7 +30,7 @@ print(laser) time.sleep(1) - comm.destroy(ic, node) + jdrc.destroy() diff --git a/src/libs/jderobotcomm_py/testMotors.py b/src/libs/jderobotcomm_py/testMotors.py index ae5107009..b323f72ca 100644 --- a/src/libs/jderobotcomm_py/testMotors.py +++ b/src/libs/jderobotcomm_py/testMotors.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import easyiceconfig as EasyIce +import jderobotconfig as config import jderobotComm as comm import sys import time @@ -12,17 +12,16 @@ if __name__ == '__main__': - ic = EasyIce.initialize(sys.argv) - ic, node = comm.init(ic) + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg["test"]) vel = CMDVel() vel.vx = 1 vel.az = 0.1 - client = comm.getMotorsClient(ic, "kobukiViewer.Motors") - #client2 = comm.getLaserClient(ic, "kobukiViewer.Laser") + client = jdrc.getMotorsClient(ic, "Motors") for i in range (10): client.sendVelocities(vel) time.sleep(1) - comm.destroy(ic, node) \ No newline at end of file + jdrc.destroy() \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/testPose.py b/src/libs/jderobotcomm_py/testPose.py index eaf4b026c..fa432d0e5 100644 --- a/src/libs/jderobotcomm_py/testPose.py +++ b/src/libs/jderobotcomm_py/testPose.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import easyiceconfig as EasyIce +import jderobotconfig as config import jderobotComm as comm import sys import time @@ -12,10 +12,10 @@ if __name__ == '__main__': - ic = EasyIce.initialize(sys.argv) - ic, node = comm.init(ic) + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg["test"]) - client = comm.getPose3dClient(ic, "kobukiViewer.Pose3D") + client = jdrc.getPose3dClient(ic, "kobukiViewer.Pose3D") for i in range (10): #print("client1", end=":") @@ -23,4 +23,4 @@ print(laser) time.sleep(1) - comm.destroy(ic, node) \ No newline at end of file + jdrc.destroy() \ No newline at end of file From 24cf3781828b6f22285c23e30728c6a235764f2d Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 2 Aug 2017 10:49:33 +0200 Subject: [PATCH 04/14] [issue #892] Updated basic_component_py to use yaml files instead of ice config files --- src/samples/basic_component_py/CMakeLists.txt | 2 +- .../basic_component_py/basic_component.py | 11 ++++++----- .../basic_component_py/basic_component_py.cfg | 16 ---------------- .../basic_component_py/basic_component_py.yml | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 22 deletions(-) delete mode 100644 src/samples/basic_component_py/basic_component_py.cfg create mode 100644 src/samples/basic_component_py/basic_component_py.yml diff --git a/src/samples/basic_component_py/CMakeLists.txt b/src/samples/basic_component_py/CMakeLists.txt index c43a55d60..8b9b5dd2c 100644 --- a/src/samples/basic_component_py/CMakeLists.txt +++ b/src/samples/basic_component_py/CMakeLists.txt @@ -25,4 +25,4 @@ INSTALL (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gui DESTINATION share/jderobot/py # Install resources #INSTALL (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION share/jderobot/python/basic_component_py COMPONENT tools PATTERN .svn EXCLUDE) -INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/basic_component_py.cfg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf) +INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/basic_component_py.yml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf) diff --git a/src/samples/basic_component_py/basic_component.py b/src/samples/basic_component_py/basic_component.py index 9057c4b1e..a5dcc535a 100755 --- a/src/samples/basic_component_py/basic_component.py +++ b/src/samples/basic_component_py/basic_component.py @@ -25,21 +25,22 @@ from gui.threadGUI import ThreadGUI from gui.GUI import MainWindow from PyQt5.QtWidgets import QApplication -import easyiceconfig as EasyIce +import jderobotconfig as config import signal signal.signal(signal.SIGINT, signal.SIG_DFL) if __name__ == '__main__': - ic = EasyIce.initialize(sys.argv) + cfg = config.load(sys.argv[1]) + #starting comm - ic, node = comm.init(ic) + jdrc= comm.init(cfg['basic_component']) - camera = comm.getCameraClient(ic,"basic_component.Camera") - motors = comm.getMotorsClient(ic,"basic_component.Motors") + camera = jdrc.getCameraClient("Camera") + motors = jdrc.getMotorsClient("Motors") app = QApplication(sys.argv) frame = MainWindow() diff --git a/src/samples/basic_component_py/basic_component_py.cfg b/src/samples/basic_component_py/basic_component_py.cfg deleted file mode 100644 index 262f8d9cb..000000000 --- a/src/samples/basic_component_py/basic_component_py.cfg +++ /dev/null @@ -1,16 +0,0 @@ -############ Motors ####################### -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -basic_component.Motors.Server=1 -basic_component.Motors.Proxy=Motors:default -h localhost -p 8999 -basic_component.Motors.Topic=/cmd_vel_mux/input/teleop -basic_component.Motors.Name=FolowLineMotors - - -############ Camera ####################### -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -basic_component.Camera.Server=1 -basic_component.Camera.Proxy=cam_turtlebot_right:default -h localhost -p 8994 -basic_component.Camera.Format=RGB8 -basic_component.Camera.Topic=/camera/rgb/image_raw -basic_component.Camera.Name=basic_component_pyCamera - diff --git a/src/samples/basic_component_py/basic_component_py.yml b/src/samples/basic_component_py/basic_component_py.yml new file mode 100644 index 000000000..f2b282125 --- /dev/null +++ b/src/samples/basic_component_py/basic_component_py.yml @@ -0,0 +1,17 @@ +basic_component: + Motors: + Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Motors:default -h localhost -p 9001" + Topic: "/turtlebotROS/mobile_base/commands/velocity" + Name: basic_component_pyCamera + maxW: 0.7 + maxV: 4 + + Camera: + Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/TurtlebotROS/cameraL/image_raw" + Name: basic_component_pyCamera + + NodeName: basic_component_py From 41fc13a63f6858e478ea6e2cf9cefa596dff76a9 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Mon, 18 Sep 2017 09:12:39 +0200 Subject: [PATCH 05/14] added config_cpp --- src/libs/config_cpp/CMakeLists.txt | 70 +++++++++++++++++++ src/libs/config_cpp/LICENSE | 18 +++++ src/libs/config_cpp/README.md | 9 +++ src/libs/config_cpp/ice.cfg | 4 ++ .../include/jderobot/config/config.h | 42 +++++++++++ .../include/jderobot/config/debug.hpp | 37 ++++++++++ .../jderobot/config/hardcodedlocations.h.in | 30 ++++++++ .../include/jderobot/config/loader.hpp | 57 +++++++++++++++ .../include/jderobot/config/stdutils.hpp | 66 +++++++++++++++++ src/libs/config_cpp/src/demo/demo.cpp | 14 ++++ src/libs/config_cpp/src/demo/ice.cfg | 4 ++ src/libs/config_cpp/src/loader.cpp | 60 ++++++++++++++++ src/libs/config_cpp/src/tests/test_loader.cpp | 34 +++++++++ .../config_cpp/src/tests/test_stdutils.cpp | 40 +++++++++++ 14 files changed, 485 insertions(+) create mode 100644 src/libs/config_cpp/CMakeLists.txt create mode 100644 src/libs/config_cpp/LICENSE create mode 100644 src/libs/config_cpp/README.md create mode 100644 src/libs/config_cpp/ice.cfg create mode 100644 src/libs/config_cpp/include/jderobot/config/config.h create mode 100644 src/libs/config_cpp/include/jderobot/config/debug.hpp create mode 100644 src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in create mode 100644 src/libs/config_cpp/include/jderobot/config/loader.hpp create mode 100644 src/libs/config_cpp/include/jderobot/config/stdutils.hpp create mode 100644 src/libs/config_cpp/src/demo/demo.cpp create mode 100644 src/libs/config_cpp/src/demo/ice.cfg create mode 100644 src/libs/config_cpp/src/loader.cpp create mode 100644 src/libs/config_cpp/src/tests/test_loader.cpp create mode 100644 src/libs/config_cpp/src/tests/test_stdutils.cpp diff --git a/src/libs/config_cpp/CMakeLists.txt b/src/libs/config_cpp/CMakeLists.txt new file mode 100644 index 000000000..95ecdec29 --- /dev/null +++ b/src/libs/config_cpp/CMakeLists.txt @@ -0,0 +1,70 @@ +cmake_minimum_required(VERSION 2.8) +project(jderobotconfig) + +### Project config +include_directories( + include + ${CMAKE_CURRENT_BINARY_DIR}/include +) + +configure_file( + include/jderobot/config/hardcodedlocations.h.in + include/jderobot/config/hardcodedlocations.h + @ONLY +) + +set(HEADERS + include/jderobot/config/config.h + ${CMAKE_CURRENT_BINARY_DIR}/include/jderobot/config/hardcodedlocations.h + include/jderobot/config/loader.hpp + include/jderobot/config/debug.hpp + + include/jderobot/config/stdutils.hpp +) + +set(SOURCES + src/loader.cpp +) +# set_property(SOURCE src/loader.cpp PROPERTY COMPILE_FLAGS "-std=c++0x") + +## Adding shared library for common usage +add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) +target_link_libraries(${PROJECT_NAME} ${YAML_CPP_LIBRARIES}) + +## Adding static library for single .so configurations +# since target is a shared library, -fPIC must be provided +add_library(${PROJECT_NAME}-embedded STATIC ${SOURCES} ${HEADERS}) +target_link_libraries(${PROJECT_NAME}-embedded ${YAML_CPP_LIBRARIES}) +set_property(TARGET ${PROJECT_NAME}-embedded PROPERTY POSITION_INDEPENDENT_CODE 1) + +## Export library variables (like find_package) +set(${PROJECT_NAME}_FOUND 1 CACHE BOOL "Find(${PROJECT_NAME})") +set(${PROJECT_NAME}_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE PATH "Find(${PROJECT_NAME})") +set(${PROJECT_NAME}_LIBRARY_DIRS "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "Find(${PROJECT_NAME})") +set(${PROJECT_NAME}_LIBRARIES "${PROJECT_NAME}" CACHE STRINGS "Find(${PROJECT_NAME})") + + +## demo +add_executable(config_demo src/demo/demo.cpp ${HEADERS}) +target_link_libraries(config_demo ${YAML_CPP_LIBRARIES}) +configure_file(src/demo/ice.cfg ice.cfg) +# set_target_properties(config_demo PROPERTIES COMPILE_FLAGS "-std=c++0x") + +## tests +#add_executable(config_test_stdutils src/tests/test_stdutils.cpp) +# set_target_properties(config_test_stdutils PROPERTIES COMPILE_FLAGS "-std=c++0x") + +#add_executable(config_test_loader src/tests/test_loader.cpp) +#target_link_libraries(config_test_loader ${PROJECT_NAME} ${YAML_CPP_LIBRARIES}) +# set_target_properties(config_test_loader PROPERTIES COMPILE_FLAGS "-std=c++0x") + + +### Install +install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-embedded + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + COMPONENT core +) +install(DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/include + COMPONENT core +) diff --git a/src/libs/config_cpp/LICENSE b/src/libs/config_cpp/LICENSE new file mode 100644 index 000000000..cc37edd33 --- /dev/null +++ b/src/libs/config_cpp/LICENSE @@ -0,0 +1,18 @@ +/* + * Copyright (C) 1997-2015 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + */ diff --git a/src/libs/config_cpp/README.md b/src/libs/config_cpp/README.md new file mode 100644 index 000000000..e417bf81e --- /dev/null +++ b/src/libs/config_cpp/README.md @@ -0,0 +1,9 @@ +# libEasyIceConfig +***A library to tame Ice.Config*** + + +## Expected usage +`#include ` +Then just replace: + * **Ice::initialize** ---> **EasyIce::initialize** + * **Ice::createProperties** ---> **EasyIce::createProperties** diff --git a/src/libs/config_cpp/ice.cfg b/src/libs/config_cpp/ice.cfg new file mode 100644 index 000000000..a1eece2c0 --- /dev/null +++ b/src/libs/config_cpp/ice.cfg @@ -0,0 +1,4 @@ +Demo.Name=hello world! +Demo.Endpoints=9000 +KK.Name=kk +Introrob.CMDVel.Proxy=override diff --git a/src/libs/config_cpp/include/jderobot/config/config.h b/src/libs/config_cpp/include/jderobot/config/config.h new file mode 100644 index 000000000..5723f1a50 --- /dev/null +++ b/src/libs/config_cpp/include/jderobot/config/config.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 1997-2015 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + */ + +#ifndef JDEROBOT_CONFIG_CONFIG_H +#define JDEROBOT_CONFIG_CONFIG_H + +/** + * @mainpage libEasyIceConfig + * A library to tame Ice.Config + * + * @author Victor Arribas Raigadas, .varribas.urjc@gmail.com + * @date November 2015 + * @version 0.9.0 (alpha) + */ + +#include +#include + +namespace JdeRobotConfig{ + +inline +YAML::Node load(std::string filename) + {return jderobotconfig::loader::load(filename);} + + +#endif // JDEROBOT_CONFIG_CONFIG_H diff --git a/src/libs/config_cpp/include/jderobot/config/debug.hpp b/src/libs/config_cpp/include/jderobot/config/debug.hpp new file mode 100644 index 000000000..1b73b61e8 --- /dev/null +++ b/src/libs/config_cpp/include/jderobot/config/debug.hpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 1997-2015 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + */ + + +#ifndef JDEROBOT_CONFIG_DEBUG_HPP +#define JDEROBOT_CONFIG_DEBUG_HPP + +#include +#include + +namespace jderobotconfig{ +namespace debug{ + +inline +void printProperties(YAML::Node prop){ + std::cout << prop << std::endl; +} + +}}//NS + +#endif // JDEROBOT_CONFIG_DEBUG_HPP diff --git a/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in b/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in new file mode 100644 index 000000000..936228226 --- /dev/null +++ b/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in @@ -0,0 +1,30 @@ +/* + * Copyright (C) 1997-2016 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas + */ + + +#ifndef JDEROBOT_CONFIG_HARDCOREDLOCATIONS_H +#define JDEROBOT_CONFIG_HARDCOREDLOCATIONS_H + +const char* HARDCORED_LOCATIONS = +"@CMAKE_INSTALL_PREFIX@/share/jderobot/conf\ +"; + + +#endif // JDEROBOT_CONFIG_HARDCOREDLOCATIONS_H + diff --git a/src/libs/config_cpp/include/jderobot/config/loader.hpp b/src/libs/config_cpp/include/jderobot/config/loader.hpp new file mode 100644 index 000000000..bf037bf43 --- /dev/null +++ b/src/libs/config_cpp/include/jderobot/config/loader.hpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 1997-2015 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + */ + +#ifndef JDEROBOT_CONFIG_LOADER_H +#define JDEROBOT_CONFIG_LOADER_H + +#include +#include +#include +#include +#include +#include + + +namespace jderobotconfig { +namespace loader { + + +/** + * @brief Find filename into all defined search paths. + * Order is: + * 1. current dir + * 2. jderobot paths (*) + * + * @return empty if file was not found. + */ +std::string findConfigFile(const std::string& filename); + +/** + * @brief Loads File configuration from passed file. + * + * @return new YAML:Node or passed one. + */ +YAML::Node load(std::string filename); + + + +}}//NS + + +#endif // JDEROBOT_CONFIG_LOADER_H diff --git a/src/libs/config_cpp/include/jderobot/config/stdutils.hpp b/src/libs/config_cpp/include/jderobot/config/stdutils.hpp new file mode 100644 index 000000000..860a31e78 --- /dev/null +++ b/src/libs/config_cpp/include/jderobot/config/stdutils.hpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 1997-2017 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + */ + +#ifndef STDUTILS_HPP +#define STDUTILS_HPP + +//// string wrapper for stdlib.h::getenv + +#include +#include + +inline +std::string getEnvironmentVariable(std::string var){ + char* _env = getenv(var.c_str()); + return std::string((_env)?_env:""); +} + + +//// Fallback std::split +/// source: http://stackoverflow.com/questions/5607589/right-way-to-split-an-stdstring-into-a-vectorstring + +#include +#include +#include + +namespace std { +inline +vector split(string str, string del){ + vector vstrings; + boost::split(vstrings, str, boost::is_any_of(del)); + return vstrings; +} +}//NS + + + +//// Check if file exists +/// For Linux works for files and directories +/// source: http://www.cplusplus.com/forum/general/1796/ +#include + +namespace std { +inline +bool fileexists(std::string filepath){ + ifstream ifile(filepath.c_str(), ios_base::in); + return ifile.is_open(); +} +}//NS + +#endif // STDUTILS_HPP diff --git a/src/libs/config_cpp/src/demo/demo.cpp b/src/libs/config_cpp/src/demo/demo.cpp new file mode 100644 index 000000000..a54f52b36 --- /dev/null +++ b/src/libs/config_cpp/src/demo/demo.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + + +int +main( int argc, const char* argv[] ){ + std::string filename (argv[1]); + YAML::Node props = JdeRobotConfig::load(filename); + std::cout << props << std::endl; + + return 0; +} diff --git a/src/libs/config_cpp/src/demo/ice.cfg b/src/libs/config_cpp/src/demo/ice.cfg new file mode 100644 index 000000000..a1eece2c0 --- /dev/null +++ b/src/libs/config_cpp/src/demo/ice.cfg @@ -0,0 +1,4 @@ +Demo.Name=hello world! +Demo.Endpoints=9000 +KK.Name=kk +Introrob.CMDVel.Proxy=override diff --git a/src/libs/config_cpp/src/loader.cpp b/src/libs/config_cpp/src/loader.cpp new file mode 100644 index 000000000..ceccf6bdc --- /dev/null +++ b/src/libs/config_cpp/src/loader.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 1997-2015 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + */ + + +#include "jderobot/config/loader.hpp" + +namespace jderobotconfig{ +namespace loader{ + +std::string +findConfigFile(const std::string& filename){ + if (std::fileexists(filename)) + return filename; + + std::string path_holders[] = {HARDCORED_LOCATIONS}; + for (int i=0; i<2; i++){ + if (path_holders[i].empty()) continue; + for (std::string path : std::split(path_holders[i], ":")){ + if (path.empty()) continue; + std::string filepath(path+"/"+filename); + if (std::fileexists(filepath)) + return filepath; + } + } + + return ""; +} + +YAML::Node +load(std::string filename){ + std::string filepath = findConfigFile(filename); + if (filepath.empty()){ + YAML::Exception e(YAML::Mark(),"jderobot/config/loader.cpp: file " + filepath + " Not Found"); + throw e; + } + YAML::Node config = YAML::LoadFile(filepath); + std::cout<<"[Info] loaded YAML Config file: "<setProperty("Ice.Config", filepath); + return config; +} + + + +}}//NS diff --git a/src/libs/config_cpp/src/tests/test_loader.cpp b/src/libs/config_cpp/src/tests/test_loader.cpp new file mode 100644 index 000000000..893db19b6 --- /dev/null +++ b/src/libs/config_cpp/src/tests/test_loader.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 1997-2015 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + * + * Thanks to: + * http://stackoverflow.com/questions/5607589/right-way-to-split-an-stdstring-into-a-vectorstring + * http://www.cplusplus.com/forum/general/1796/ + */ + +#include +#include +#include +#include + + + +int main(int argc, char* argv[]){ + YAML::Node props = Config::load(argv[1]); + jderobotconfig::debug::printProperties(props); +} diff --git a/src/libs/config_cpp/src/tests/test_stdutils.cpp b/src/libs/config_cpp/src/tests/test_stdutils.cpp new file mode 100644 index 000000000..ad2fb63e3 --- /dev/null +++ b/src/libs/config_cpp/src/tests/test_stdutils.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 1997-2015 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + * + * Thanks to: + * http://stackoverflow.com/questions/5607589/right-way-to-split-an-stdstring-into-a-vectorstring + * http://www.cplusplus.com/forum/general/1796/ + */ + + +#include +#include + + +int main(){ + std::string PATH = getEnvironmentVariable("PATH"); + std::vector paths = std::split(PATH, ":"); + std::copy(paths.begin(), paths.end(), std::ostream_iterator(std::cout, "\n")); + + std::cout << std::fileexists("/bin/bash"); + std::cout << std::fileexists("/dev/null"); + std::cout << std::fileexists("/tmp/foo"); + for (std::string path : paths){ + std::cout << std::fileexists(path); + } +} From 3a2ffec8bad58f6ede7f67fe45d039fb8e2578c2 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Fri, 22 Sep 2017 11:26:48 +0200 Subject: [PATCH 06/14] [issue #892] solved bug with config_cpp --- src/libs/config_cpp/CMakeLists.txt | 2 +- src/libs/config_cpp/include/jderobot/config/config.h | 2 +- src/libs/config_cpp/src/demo/demo.cpp | 4 ++++ src/libs/config_cpp/src/demo/ice.cfg | 8 ++++---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libs/config_cpp/CMakeLists.txt b/src/libs/config_cpp/CMakeLists.txt index 95ecdec29..84c9c1e0b 100644 --- a/src/libs/config_cpp/CMakeLists.txt +++ b/src/libs/config_cpp/CMakeLists.txt @@ -46,7 +46,7 @@ set(${PROJECT_NAME}_LIBRARIES "${PROJECT_NAME}" CACHE STRINGS "Find(${PROJECT_NA ## demo add_executable(config_demo src/demo/demo.cpp ${HEADERS}) -target_link_libraries(config_demo ${YAML_CPP_LIBRARIES}) +target_link_libraries(config_demo ${YAML_CPP_LIBRARIES} ${PROJECT_NAME}) configure_file(src/demo/ice.cfg ice.cfg) # set_target_properties(config_demo PROPERTIES COMPILE_FLAGS "-std=c++0x") diff --git a/src/libs/config_cpp/include/jderobot/config/config.h b/src/libs/config_cpp/include/jderobot/config/config.h index 5723f1a50..465c63ea8 100644 --- a/src/libs/config_cpp/include/jderobot/config/config.h +++ b/src/libs/config_cpp/include/jderobot/config/config.h @@ -38,5 +38,5 @@ inline YAML::Node load(std::string filename) {return jderobotconfig::loader::load(filename);} - +} #endif // JDEROBOT_CONFIG_CONFIG_H diff --git a/src/libs/config_cpp/src/demo/demo.cpp b/src/libs/config_cpp/src/demo/demo.cpp index a54f52b36..baf859aba 100644 --- a/src/libs/config_cpp/src/demo/demo.cpp +++ b/src/libs/config_cpp/src/demo/demo.cpp @@ -10,5 +10,9 @@ main( int argc, const char* argv[] ){ YAML::Node props = JdeRobotConfig::load(filename); std::cout << props << std::endl; + std::cout << props["Demo.Name"]<< std::endl; + //std::cout << props.IsScalar()<< std::endl; + //std::cout << props.as()<< std::endl; + return 0; } diff --git a/src/libs/config_cpp/src/demo/ice.cfg b/src/libs/config_cpp/src/demo/ice.cfg index a1eece2c0..ae7c15976 100644 --- a/src/libs/config_cpp/src/demo/ice.cfg +++ b/src/libs/config_cpp/src/demo/ice.cfg @@ -1,4 +1,4 @@ -Demo.Name=hello world! -Demo.Endpoints=9000 -KK.Name=kk -Introrob.CMDVel.Proxy=override +Demo.Name: hello world! +Demo.Endpoints: 9000 +KK.Name: kk +Introrob.CMDVel.Proxy: override From dbdca90fa9d1c5b5d8837607f06cb633bed017ce Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Mon, 25 Sep 2017 15:16:39 +0200 Subject: [PATCH 07/14] updated comm to use config --- CMakeLists.txt | 24 ++++ src/libs/CMakeLists.txt | 3 +- src/libs/config_cpp/CMakeLists.txt | 14 +-- src/libs/config_cpp/ice.cfg | 4 - .../include/jderobot/config/class.hpp | 112 ++++++++++++++++++ .../include/jderobot/config/config.h | 25 ++-- .../jderobot/config/hardcodedlocations.h.in | 4 +- .../include/jderobot/config/loader.hpp | 9 +- src/libs/config_cpp/src/class.cpp | 85 +++++++++++++ src/libs/config_cpp/src/demo/demo.cpp | 9 +- src/libs/config_cpp/src/demo/demo.yml | 18 +++ src/libs/config_cpp/src/demo/ice.cfg | 4 - src/libs/config_cpp/src/loader.cpp | 8 +- src/libs/config_cpp/src/tests/test_loader.cpp | 5 +- src/libs/config_py/demo.py | 4 +- src/libs/config_py/demo.yml | 18 +++ src/libs/jderobotcomm_cpp/CMakeLists.txt | 11 +- .../include/jderobot/comm/cameraClient.hpp | 3 +- .../include/jderobot/comm/communicator.hpp | 46 +++++++ .../jderobot/comm/ice/cameraIceClient.hpp | 4 +- .../jderobotcomm_cpp/src/cameraClient.cpp | 12 +- .../src/communicator.cpp} | 34 ++++-- .../src/ice/cameraIceClient.cpp | 14 +-- 23 files changed, 398 insertions(+), 72 deletions(-) delete mode 100644 src/libs/config_cpp/ice.cfg create mode 100644 src/libs/config_cpp/include/jderobot/config/class.hpp create mode 100644 src/libs/config_cpp/src/class.cpp create mode 100644 src/libs/config_cpp/src/demo/demo.yml delete mode 100644 src/libs/config_cpp/src/demo/ice.cfg create mode 100644 src/libs/config_py/demo.yml create mode 100644 src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp rename src/libs/{config_cpp/include/jderobot/config/debug.hpp => jderobotcomm_cpp/src/communicator.cpp} (59%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 684221ad6..81f068767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,30 @@ macro(list_subdirectories2 retval curdir return_relative) set(${retval} ${list_of_dirs}) endmacro() +# MACRO to add the list of subdirectories to another list +macro(list_subdirectories3 retval curdir return_relative) + file(GLOB sub-dir RELATIVE ${curdir} *) + set(list_of_dirs ${${retval}}) + foreach(dir ${sub-dir}) + if(IS_DIRECTORY ${curdir}/${dir}) + if (${return_relative}) + list (FIND list_of_dirs "${dir}" _index) + if (NOT ${_index} GREATER -1) + if (NOT ${dir} MATCHES "CMakeFiles" AND NOT ${dir} MATCHES ".svn") + set(list_of_dirs ${list_of_dirs} ${dir}) + endif() + endif() + else() + list (FIND list_of_dirs "${curdir}/${dir}" _index) + if (NOT ${_index} GREATER -1) + set(list_of_dirs ${list_of_dirs} ${curdir}/${dir}) + endif() + endif() + endif() + endforeach() + set(${retval} ${list_of_dirs}) +endmacro() + ################### diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt index 5eb780b23..a46ff2d73 100644 --- a/src/libs/CMakeLists.txt +++ b/src/libs/CMakeLists.txt @@ -1,4 +1,5 @@ -list_subdirectories( LIST_LIBS ${CMAKE_CURRENT_SOURCE_DIR} 1) +set (LIST_LIBS "config_cpp") #Adding library to be processed first +list_subdirectories3( LIST_LIBS ${CMAKE_CURRENT_SOURCE_DIR} 1) FOREACH (lib ${LIST_LIBS}) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${lib}/CMakeLists.txt) diff --git a/src/libs/config_cpp/CMakeLists.txt b/src/libs/config_cpp/CMakeLists.txt index 84c9c1e0b..d7bb528a0 100644 --- a/src/libs/config_cpp/CMakeLists.txt +++ b/src/libs/config_cpp/CMakeLists.txt @@ -17,15 +17,15 @@ set(HEADERS include/jderobot/config/config.h ${CMAKE_CURRENT_BINARY_DIR}/include/jderobot/config/hardcodedlocations.h include/jderobot/config/loader.hpp - include/jderobot/config/debug.hpp - + include/jderobot/config/class.hpp include/jderobot/config/stdutils.hpp ) set(SOURCES src/loader.cpp + src/class.cpp ) -# set_property(SOURCE src/loader.cpp PROPERTY COMPILE_FLAGS "-std=c++0x") + ## Adding shared library for common usage add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) @@ -39,7 +39,7 @@ set_property(TARGET ${PROJECT_NAME}-embedded PROPERTY POSITION_INDEPENDENT_CODE ## Export library variables (like find_package) set(${PROJECT_NAME}_FOUND 1 CACHE BOOL "Find(${PROJECT_NAME})") -set(${PROJECT_NAME}_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE PATH "Find(${PROJECT_NAME})") +set(${PROJECT_NAME}_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" CACHE PATH "Find(${PROJECT_NAME})") set(${PROJECT_NAME}_LIBRARY_DIRS "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "Find(${PROJECT_NAME})") set(${PROJECT_NAME}_LIBRARIES "${PROJECT_NAME}" CACHE STRINGS "Find(${PROJECT_NAME})") @@ -47,16 +47,14 @@ set(${PROJECT_NAME}_LIBRARIES "${PROJECT_NAME}" CACHE STRINGS "Find(${PROJECT_NA ## demo add_executable(config_demo src/demo/demo.cpp ${HEADERS}) target_link_libraries(config_demo ${YAML_CPP_LIBRARIES} ${PROJECT_NAME}) -configure_file(src/demo/ice.cfg ice.cfg) -# set_target_properties(config_demo PROPERTIES COMPILE_FLAGS "-std=c++0x") +configure_file(src/demo/demo.yml demo.yml) + ## tests #add_executable(config_test_stdutils src/tests/test_stdutils.cpp) -# set_target_properties(config_test_stdutils PROPERTIES COMPILE_FLAGS "-std=c++0x") #add_executable(config_test_loader src/tests/test_loader.cpp) #target_link_libraries(config_test_loader ${PROJECT_NAME} ${YAML_CPP_LIBRARIES}) -# set_target_properties(config_test_loader PROPERTIES COMPILE_FLAGS "-std=c++0x") ### Install diff --git a/src/libs/config_cpp/ice.cfg b/src/libs/config_cpp/ice.cfg deleted file mode 100644 index a1eece2c0..000000000 --- a/src/libs/config_cpp/ice.cfg +++ /dev/null @@ -1,4 +0,0 @@ -Demo.Name=hello world! -Demo.Endpoints=9000 -KK.Name=kk -Introrob.CMDVel.Proxy=override diff --git a/src/libs/config_cpp/include/jderobot/config/class.hpp b/src/libs/config_cpp/include/jderobot/config/class.hpp new file mode 100644 index 000000000..61bf8ae2d --- /dev/null +++ b/src/libs/config_cpp/include/jderobot/config/class.hpp @@ -0,0 +1,112 @@ +/* + * Copyright (C) 1997-2017 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Aitor Martinez Fernandez + */ + +#ifndef JDEROBOT_CONFIG_CLASS_H +#define JDEROBOT_CONFIG_CLASS_H + +/** + * @mainpage Config + * JdeRobot Config library + * + * @author Aitor Martinez Fernandez , .aitor.martinez.fernandez@gmail.com + * @date September 2017 + * @version 0.9.0 (alpha) + */ + +#include +#include +#include +#include +#include + +namespace JdeRobotConfig{ + +class Config { +public: + Config(); + Config(YAML::Node node); + //~Config(); + + /** + * @brief returns as string the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * + */ + std::string asString(std::string element); + + /** + * @brief returns as float the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * + */ + float asFloat(std::string element); + + /** + * @brief returns as integer the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * + */ + int asInt(std::string element); + + /** + * @brief returns as double the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * + */ + double asDouble(std::string element); + + + + YAML::Node getNode(); + + +private: + YAML::Node node; + + /** + * @brief makes recursively sear for element given in names + * + * + * @param yaml node in which search + * @param vector of elements names (route to element of last position of vector) + * + * + * @return yaml node of element + */ + YAML::Node searchNode(YAML::Node n, std::vector names); + +}; + + +/** + * @brief function to make printable config class + */ +inline +std::ostream& operator<< (std::ostream & out, JdeRobotConfig::Config & data) { + out << data.getNode(); + return out ; +} + +} + +#endif // JDEROBOT_CONFIG_CLASS_H \ No newline at end of file diff --git a/src/libs/config_cpp/include/jderobot/config/config.h b/src/libs/config_cpp/include/jderobot/config/config.h index 465c63ea8..fd42b0d0f 100644 --- a/src/libs/config_cpp/include/jderobot/config/config.h +++ b/src/libs/config_cpp/include/jderobot/config/config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2015 JDE Developers Team + * Copyright (C) 1997-2017 JDE Developers Team * * 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 @@ -14,28 +14,39 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * Authors : - * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + * Aitor Martinez Fernandez */ #ifndef JDEROBOT_CONFIG_CONFIG_H #define JDEROBOT_CONFIG_CONFIG_H /** - * @mainpage libEasyIceConfig - * A library to tame Ice.Config + * @mainpage Config + * JdeRobot COnfig library * - * @author Victor Arribas Raigadas, .varribas.urjc@gmail.com - * @date November 2015 + * @author Aitor Martinez Fernandez , .aitor.martinez.fernandez@gmail.com + * @date September 2017 * @version 0.9.0 (alpha) */ #include #include +#include namespace JdeRobotConfig{ + +/** + * @brief loads propierties from a file + * + * + * @param filename + * + * + * @return config class with all propierties + */ inline -YAML::Node load(std::string filename) +JdeRobotConfig::Config load(std::string filename) {return jderobotconfig::loader::load(filename);} } diff --git a/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in b/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in index 936228226..682a6ae0f 100644 --- a/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in +++ b/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in @@ -21,10 +21,12 @@ #ifndef JDEROBOT_CONFIG_HARDCOREDLOCATIONS_H #define JDEROBOT_CONFIG_HARDCOREDLOCATIONS_H + +namespace JdeRobotConfig{ const char* HARDCORED_LOCATIONS = "@CMAKE_INSTALL_PREFIX@/share/jderobot/conf\ "; - +} //NS #endif // JDEROBOT_CONFIG_HARDCOREDLOCATIONS_H diff --git a/src/libs/config_cpp/include/jderobot/config/loader.hpp b/src/libs/config_cpp/include/jderobot/config/loader.hpp index bf037bf43..d580e7b17 100644 --- a/src/libs/config_cpp/include/jderobot/config/loader.hpp +++ b/src/libs/config_cpp/include/jderobot/config/loader.hpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2015 JDE Developers Team + * Copyright (C) 1997-2017 JDE Developers Team * * 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 @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * Authors : - * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + * Aitor Martinez Fernandez */ #ifndef JDEROBOT_CONFIG_LOADER_H @@ -26,6 +26,7 @@ #include #include #include +#include namespace jderobotconfig { @@ -45,9 +46,9 @@ std::string findConfigFile(const std::string& filename); /** * @brief Loads File configuration from passed file. * - * @return new YAML:Node or passed one. + * @return new JdeRobotConfig::Config or passed one. */ -YAML::Node load(std::string filename); +JdeRobotConfig::Config load(std::string filename); diff --git a/src/libs/config_cpp/src/class.cpp b/src/libs/config_cpp/src/class.cpp new file mode 100644 index 000000000..a442876b7 --- /dev/null +++ b/src/libs/config_cpp/src/class.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 1997-2017 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Aitor Martinez Fernandez + */ + +#include "jderobot/config/class.hpp" + +namespace JdeRobotConfig{ + + +Config::Config(){ +} + +Config::Config(YAML::Node node){ + this->node = node; +} + +std::string +Config::asString(std::string element){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + return nod.as(); +} + +float +Config::asFloat(std::string element){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + return nod.as(); +} + +int +Config::asInt(std::string element){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + return nod.as(); +} + +double +Config::asDouble(std::string element){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + return nod.as(); +} + +YAML::Node +Config::getNode(){ + + return node; +} + + + +YAML::Node +Config::searchNode(YAML::Node n, std::vector names){ + YAML::Node nod = n[names[0]]; + names.erase(names.begin()); + + if (names.size()>0){ + return this->searchNode(nod, names); + }else{ + return nod; + } +} + + +}//NS \ No newline at end of file diff --git a/src/libs/config_cpp/src/demo/demo.cpp b/src/libs/config_cpp/src/demo/demo.cpp index baf859aba..0c713b522 100644 --- a/src/libs/config_cpp/src/demo/demo.cpp +++ b/src/libs/config_cpp/src/demo/demo.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -7,12 +8,12 @@ int main( int argc, const char* argv[] ){ std::string filename (argv[1]); - YAML::Node props = JdeRobotConfig::load(filename); + JdeRobotConfig::Config props = JdeRobotConfig::load(filename); std::cout << props << std::endl; + std::cout << props.asString("Demo.Motors.Proxy")<< std::endl; + std::cout << props.asFloat("Demo.Motors.maxW")<< std::endl; + std::cout << props.asInt("Demo.Motors.maxV")<< std::endl; - std::cout << props["Demo.Name"]<< std::endl; - //std::cout << props.IsScalar()<< std::endl; - //std::cout << props.as()<< std::endl; return 0; } diff --git a/src/libs/config_cpp/src/demo/demo.yml b/src/libs/config_cpp/src/demo/demo.yml new file mode 100644 index 000000000..04a17ada4 --- /dev/null +++ b/src/libs/config_cpp/src/demo/demo.yml @@ -0,0 +1,18 @@ +Demo: + Motors: + Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Motors:default -h localhost -p 9001" + Topic: "/turtlebotROS/mobile_base/commands/velocity" + Name: basic_component_pyCamera + maxW: 0.7 + maxV: 4 + + Camera: + Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/TurtlebotROS/cameraL/image_raw" + Name: basic_component_pyCamera + + NodeName: demo + diff --git a/src/libs/config_cpp/src/demo/ice.cfg b/src/libs/config_cpp/src/demo/ice.cfg deleted file mode 100644 index ae7c15976..000000000 --- a/src/libs/config_cpp/src/demo/ice.cfg +++ /dev/null @@ -1,4 +0,0 @@ -Demo.Name: hello world! -Demo.Endpoints: 9000 -KK.Name: kk -Introrob.CMDVel.Proxy: override diff --git a/src/libs/config_cpp/src/loader.cpp b/src/libs/config_cpp/src/loader.cpp index ceccf6bdc..898467bb0 100644 --- a/src/libs/config_cpp/src/loader.cpp +++ b/src/libs/config_cpp/src/loader.cpp @@ -28,7 +28,7 @@ findConfigFile(const std::string& filename){ if (std::fileexists(filename)) return filename; - std::string path_holders[] = {HARDCORED_LOCATIONS}; + std::string path_holders[] = {JdeRobotConfig::HARDCORED_LOCATIONS}; for (int i=0; i<2; i++){ if (path_holders[i].empty()) continue; for (std::string path : std::split(path_holders[i], ":")){ @@ -42,14 +42,16 @@ findConfigFile(const std::string& filename){ return ""; } -YAML::Node +JdeRobotConfig::Config load(std::string filename){ std::string filepath = findConfigFile(filename); if (filepath.empty()){ YAML::Exception e(YAML::Mark(),"jderobot/config/loader.cpp: file " + filepath + " Not Found"); throw e; } - YAML::Node config = YAML::LoadFile(filepath); + YAML::Node nodeConfig = YAML::LoadFile(filepath); + + JdeRobotConfig::Config config(nodeConfig); std::cout<<"[Info] loaded YAML Config file: "<setProperty("Ice.Config", filepath); return config; diff --git a/src/libs/config_cpp/src/tests/test_loader.cpp b/src/libs/config_cpp/src/tests/test_loader.cpp index 893db19b6..bb919b19b 100644 --- a/src/libs/config_cpp/src/tests/test_loader.cpp +++ b/src/libs/config_cpp/src/tests/test_loader.cpp @@ -24,11 +24,10 @@ #include #include #include -#include int main(int argc, char* argv[]){ - YAML::Node props = Config::load(argv[1]); - jderobotconfig::debug::printProperties(props); + JdeRobot::Config props = Config::load(argv[1]); + std::cout << props << std::endl; } diff --git a/src/libs/config_py/demo.py b/src/libs/config_py/demo.py index 51c3f6caa..8449cefaa 100644 --- a/src/libs/config_py/demo.py +++ b/src/libs/config_py/demo.py @@ -14,9 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. # Authors : -# Victor Arribas Raigadas +# Aitor Martinez Fernandez # -__author__ = 'varribas' +__author__ = 'aitormf' import sys diff --git a/src/libs/config_py/demo.yml b/src/libs/config_py/demo.yml new file mode 100644 index 000000000..abc5b1518 --- /dev/null +++ b/src/libs/config_py/demo.yml @@ -0,0 +1,18 @@ +Demo: + Motors: + Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: Motors:default -h localhost -p 9001 + Topic: '/turtlebotROS/mobile_base/commands/velocity' + Name: basic_component_pyCamera + maxW: 0.7 + maxV: 4 + + Camera: + Server: 2 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/TurtlebotROS/cameraL/image_raw" + Name: basic_component_pyCamera + + NodeName: demo + diff --git a/src/libs/jderobotcomm_cpp/CMakeLists.txt b/src/libs/jderobotcomm_cpp/CMakeLists.txt index 228dcafb2..af9e2a3b0 100644 --- a/src/libs/jderobotcomm_cpp/CMakeLists.txt +++ b/src/libs/jderobotcomm_cpp/CMakeLists.txt @@ -28,10 +28,12 @@ include_directories( ${catkin_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} ${INTERFACES_CPP_DIR} + ${jderobotconfig_INCLUDE_DIRS} ) set(HEADERS + include/jderobot/comm/communicator.hpp include/jderobot/comm/laserClient.hpp include/jderobot/comm/interfaces/laserClient.hpp include/jderobot/comm/ice/laserIceClient.hpp @@ -48,6 +50,7 @@ set(HEADERS ) set(SOURCES + src/communicator.cpp src/laserClient.cpp src/ice/laserIceClient.cpp src/cameraClient.cpp @@ -83,12 +86,15 @@ ENDIF() ## Adding shared library for common usage add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) +add_dependencies(${PROJECT_NAME} ${jderobotconfig_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} ${ZeroCIce_LIBRARIES} logger ${Boost_LIBRARIES} colorspacesmm - ${catkin_LIBRARIES}) + ${catkin_LIBRARIES} + ${jderobotconfig_LIBRARIES}) ## Adding static library for single .so configurations # since target is a shared library, -fPIC must be provided @@ -100,7 +106,8 @@ target_link_libraries(${PROJECT_NAME}-embedded ${Boost_LIBRARIES} colorspacesmm JderobotInterfaces - ${catkin_LIBRARIES}) + ${catkin_LIBRARIES} + ${jderobotconfig_LIBRARIES}) set_property(TARGET ${PROJECT_NAME}-embedded PROPERTY POSITION_INDEPENDENT_CODE 1) diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp index 63608c81b..dcb9a43bf 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -41,7 +42,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - CameraClient* getCameraClient(Ice::CommunicatorPtr ic, std::string prefix); + CameraClient* getCameraClient(JdeRobotComm::Communicator jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp new file mode 100644 index 000000000..fd3dbdba3 --- /dev/null +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 1997-2017 JDE Developers Team + * + * 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 http://www.gnu.org/licenses/. + * Authors : + * Aitor Martinez Fernandez + */ + +#ifndef JDEROBOTCOMM_COMMUNICATOR_H +#define JDEROBOTCOMM_COMMUNICATOR_H + +#include +#include + + +namespace JdeRobotComm { + + class Communicator { + public: + Communicator(JdeRobotConfig::Config config); + ~Communicator(); + + JdeRobotConfig::Config getConfig(); + Ice::CommunicatorPtr getIceComm(); + + + private: + JdeRobotConfig::Config config; + Ice::CommunicatorPtr ic; + }; + + +} //NS + +#endif // JDEROBOTCOMM_COMMUNICATOR_H \ No newline at end of file diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp index 355a353aa..a8e78f7b7 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp @@ -28,7 +28,9 @@ #include #include #include +#include #include +#include #include #include @@ -36,7 +38,7 @@ namespace JdeRobotComm { class CameraIceClient: public IceUtil::Thread, public JdeRobotComm::CameraClient { public: - CameraIceClient(Ice::CommunicatorPtr ic, std::string prefix); + CameraIceClient(JdeRobotComm::Communicator jdrc, std::string prefix); virtual ~CameraIceClient(); virtual void run(); diff --git a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp b/src/libs/jderobotcomm_cpp/src/cameraClient.cpp index 6a6af6cdb..8c6d83fd2 100644 --- a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/cameraClient.cpp @@ -25,12 +25,12 @@ namespace JdeRobotComm { CameraClient* -getCameraClient(Ice::CommunicatorPtr ic, std::string prefix){ +getCameraClient(JdeRobotComm::Communicator jdrc, std::string prefix){ CameraClient* client = 0; - Ice::PropertiesPtr prop = ic->getProperties(); - int server = prop->getPropertyAsIntWithDefault(prefix+".Server",0); + //int server = prop->getPropertyAsIntWithDefault(prefix+".Server",0); + int server = jdrc.getConfig().asInt(prefix+".Server"); switch (server){ case 0: { @@ -41,7 +41,7 @@ getCameraClient(Ice::CommunicatorPtr ic, std::string prefix){ { std::cout << "Receiving Image from ICE interfaces" << std::endl; CameraIceClient* cl; - cl = new CameraIceClient(ic, prefix); + cl = new CameraIceClient(jdrc, prefix); cl->start(); client = (JdeRobotComm::CameraClient*) cl; break; @@ -51,9 +51,9 @@ getCameraClient(Ice::CommunicatorPtr ic, std::string prefix){ #ifdef JDERROS std::cout << "Receiving Image from ROS messages" << std::endl; std::string nodeName; - nodeName = prop->getPropertyWithDefault(prefix+".Name","CameraNode"); + nodeName = jdrc.getConfig().asString(prefix+".Name"); std::string topic; - topic = prop->getPropertyWithDefault(prefix+".Topic",""); + topic = jdrc.getConfig().asString(prefix+".Topic"); ListenerCamera* lc; lc = new ListenerCamera(0, nullptr, nodeName, topic); lc->start(); diff --git a/src/libs/config_cpp/include/jderobot/config/debug.hpp b/src/libs/jderobotcomm_cpp/src/communicator.cpp similarity index 59% rename from src/libs/config_cpp/include/jderobot/config/debug.hpp rename to src/libs/jderobotcomm_cpp/src/communicator.cpp index 1b73b61e8..aa4257b56 100644 --- a/src/libs/config_cpp/include/jderobot/config/debug.hpp +++ b/src/libs/jderobotcomm_cpp/src/communicator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2015 JDE Developers Team + * Copyright (C) 1997-2017 JDE Developers Team * * 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 @@ -14,24 +14,32 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * Authors : - * Victor Arribas Raigadas <.varribas.urjc@gmail.com> + * Aitor Martinez Fernandez */ +#include +namespace JdeRobotComm { + +Communicator::Communicator(JdeRobotConfig::Config config){ + this->config = config; +} + + +Communicator::~Communicator(){ + this->ic->destroy(); +} -#ifndef JDEROBOT_CONFIG_DEBUG_HPP -#define JDEROBOT_CONFIG_DEBUG_HPP -#include -#include -namespace jderobotconfig{ -namespace debug{ +JdeRobotConfig::Config +Communicator::getConfig(){ + return this->config; +} -inline -void printProperties(YAML::Node prop){ - std::cout << prop << std::endl; +Ice::CommunicatorPtr +Communicator::getIceComm(){ + return this->ic; } -}}//NS -#endif // JDEROBOT_CONFIG_DEBUG_HPP +}//NS \ No newline at end of file diff --git a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp b/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp index 58fe06c97..5a7dc8b62 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp @@ -19,28 +19,26 @@ */ -#include #include "jderobot/comm/ice/cameraIceClient.hpp" namespace JdeRobotComm { -CameraIceClient::CameraIceClient(Ice::CommunicatorPtr ic, std::string prefix) { +CameraIceClient::CameraIceClient(JdeRobotComm::Communicator jdrc, std::string prefix) { this->prefix=prefix; - Ice::PropertiesPtr prop; - prop = ic->getProperties(); Ice::ObjectPrx baseCamera; this->refreshRate=0; this->mImageFormat.empty(); - int fps=prop->getPropertyAsIntWithDefault(prefix+".Fps",30); - this->cycle=(float)(1/(float)fps)*1000000; + float fps=jdrc.getConfig().asFloat(prefix+".Fps"); + this->cycle=(1/fps)*1000000; try{ - baseCamera = ic->propertyToProxy(prefix+".Proxy"); + std::string proxy = jdrc.getConfig().asString(prefix+".Proxy"); + baseCamera = jdrc.getIceComm()->stringToProxy(proxy); if (0==baseCamera){ this->on = false; throw prefix + "Could not create proxy with Camera"; @@ -62,7 +60,7 @@ CameraIceClient::CameraIceClient(Ice::CommunicatorPtr ic, std::string prefix) { } //check if default format is defined - std::string definedFormat=prop->getPropertyWithDefault(prefix+".Format", "RGB8"); + std::string definedFormat=jdrc.getConfig().asString(prefix+".Format"); this->mImageFormat = CameraUtils::negotiateDefaultFormat(this->prx,definedFormat); From 8937d3d41a74ba102e0c80c7ffd755c97766e5eb Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 27 Sep 2017 11:12:54 +0200 Subject: [PATCH 08/14] Terminated config library and updated cameraview to use it --- .../include/jderobot/config/class.hpp | 51 +++++++++++-- .../include/jderobot/config/config.h | 10 ++- .../jderobot/config/hardcodedlocations.h.in | 2 +- .../include/jderobot/config/loader.hpp | 4 +- src/libs/config_cpp/src/class.cpp | 74 ++++++++++++++++--- src/libs/config_cpp/src/demo/demo.cpp | 6 +- src/libs/config_cpp/src/loader.cpp | 6 +- src/libs/config_cpp/src/tests/test_loader.cpp | 2 +- src/libs/config_py/demo.py | 2 + .../include/jderobot/comm/cameraClient.hpp | 2 +- .../include/jderobot/comm/communicator.hpp | 9 ++- .../jderobot/comm/ice/cameraIceClient.hpp | 2 +- .../jderobotcomm_cpp/src/cameraClient.cpp | 8 +- .../jderobotcomm_cpp/src/communicator.cpp | 5 +- .../src/ice/cameraIceClient.cpp | 21 ++++-- src/tools/cameraview/CMakeLists.txt | 8 +- src/tools/cameraview/cameraview.cfg | 6 -- src/tools/cameraview/cameraview.cpp | 12 ++- src/tools/cameraview/cameraview.yml | 10 +++ 19 files changed, 177 insertions(+), 63 deletions(-) delete mode 100644 src/tools/cameraview/cameraview.cfg create mode 100644 src/tools/cameraview/cameraview.yml diff --git a/src/libs/config_cpp/include/jderobot/config/class.hpp b/src/libs/config_cpp/include/jderobot/config/class.hpp index 61bf8ae2d..187c142f5 100644 --- a/src/libs/config_cpp/include/jderobot/config/class.hpp +++ b/src/libs/config_cpp/include/jderobot/config/class.hpp @@ -35,13 +35,13 @@ #include #include -namespace JdeRobotConfig{ +namespace Config{ -class Config { +class Properties { public: - Config(); - Config(YAML::Node node); - //~Config(); + Properties(); + Properties(YAML::Node node); + //~Properties(); /** * @brief returns as string the propery given @@ -51,6 +51,16 @@ class Config { */ std::string asString(std::string element); + + /** + * @brief returns as string the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * @param default value + * + */ + std::string asStringWithDefault(std::string element, std::string dataDefault); + /** * @brief returns as float the propery given * @@ -59,6 +69,15 @@ class Config { */ float asFloat(std::string element); + /** + * @brief returns as float the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * @param default value + * + */ + float asFloatWithDefault(std::string element, float dataDefault); + /** * @brief returns as integer the propery given * @@ -67,6 +86,15 @@ class Config { */ int asInt(std::string element); + /** + * @brief returns as integer the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * @param default value + * + */ + int asIntWithDefault(std::string element, int dataDefault); + /** * @brief returns as double the propery given * @@ -75,6 +103,15 @@ class Config { */ double asDouble(std::string element); + /** + * @brief returns as double the propery given + * + * @param route to element separated by dots (example: "kobukiViewer.Camera.proxy") + * @param default value + * + */ + double asDoubleWithDefault(std::string element, double dataDefault); + YAML::Node getNode(); @@ -102,11 +139,11 @@ class Config { * @brief function to make printable config class */ inline -std::ostream& operator<< (std::ostream & out, JdeRobotConfig::Config & data) { +std::ostream& operator<< (std::ostream & out, Properties & data) { out << data.getNode(); return out ; } -} +}//NS #endif // JDEROBOT_CONFIG_CLASS_H \ No newline at end of file diff --git a/src/libs/config_cpp/include/jderobot/config/config.h b/src/libs/config_cpp/include/jderobot/config/config.h index fd42b0d0f..8ebbc5759 100644 --- a/src/libs/config_cpp/include/jderobot/config/config.h +++ b/src/libs/config_cpp/include/jderobot/config/config.h @@ -33,7 +33,7 @@ #include #include -namespace JdeRobotConfig{ +namespace Config{ /** @@ -46,8 +46,10 @@ namespace JdeRobotConfig{ * @return config class with all propierties */ inline -JdeRobotConfig::Config load(std::string filename) - {return jderobotconfig::loader::load(filename);} +Config::Properties load(int argc, char* argv[]) +{ + std::string filename (argv[1]); + return jderobotconfig::loader::load(filename);} -} +} //NS #endif // JDEROBOT_CONFIG_CONFIG_H diff --git a/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in b/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in index 682a6ae0f..1f32e8b41 100644 --- a/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in +++ b/src/libs/config_cpp/include/jderobot/config/hardcodedlocations.h.in @@ -22,7 +22,7 @@ #define JDEROBOT_CONFIG_HARDCOREDLOCATIONS_H -namespace JdeRobotConfig{ +namespace Config{ const char* HARDCORED_LOCATIONS = "@CMAKE_INSTALL_PREFIX@/share/jderobot/conf\ "; diff --git a/src/libs/config_cpp/include/jderobot/config/loader.hpp b/src/libs/config_cpp/include/jderobot/config/loader.hpp index d580e7b17..f44a519bc 100644 --- a/src/libs/config_cpp/include/jderobot/config/loader.hpp +++ b/src/libs/config_cpp/include/jderobot/config/loader.hpp @@ -46,9 +46,9 @@ std::string findConfigFile(const std::string& filename); /** * @brief Loads File configuration from passed file. * - * @return new JdeRobotConfig::Config or passed one. + * @return new Config::Config or passed one. */ -JdeRobotConfig::Config load(std::string filename); +Config::Properties load(std::string filename); diff --git a/src/libs/config_cpp/src/class.cpp b/src/libs/config_cpp/src/class.cpp index a442876b7..0234d562f 100644 --- a/src/libs/config_cpp/src/class.cpp +++ b/src/libs/config_cpp/src/class.cpp @@ -19,50 +19,106 @@ #include "jderobot/config/class.hpp" -namespace JdeRobotConfig{ +namespace Config{ -Config::Config(){ +Properties::Properties(){ } -Config::Config(YAML::Node node){ +Properties::Properties(YAML::Node node){ this->node = node; } std::string -Config::asString(std::string element){ +Properties::asString(std::string element){ std::vector v = std::split(element, "."); YAML::Node nod = this->searchNode(this->node, v); return nod.as(); } +std::string +Properties::asStringWithDefault(std::string element, std::string dataDefault){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + std::string data; + try{ + data = nod.as(); + }catch(YAML::BadConversion e){ + data = dataDefault; + } + return data; +} + float -Config::asFloat(std::string element){ +Properties::asFloat(std::string element){ std::vector v = std::split(element, "."); YAML::Node nod = this->searchNode(this->node, v); return nod.as(); } +float +Properties::asFloatWithDefault(std::string element, float dataDefault){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + float data; + try{ + data = nod.as(); + }catch(YAML::BadConversion e){ + data = dataDefault; + } + return data; +} + int -Config::asInt(std::string element){ +Properties::asInt(std::string element){ std::vector v = std::split(element, "."); YAML::Node nod = this->searchNode(this->node, v); return nod.as(); } +int +Properties::asIntWithDefault(std::string element, int dataDefault){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + int data; + try{ + data = nod.as(); + }catch(YAML::BadConversion e){ + data = dataDefault; + } + return data; +} + double -Config::asDouble(std::string element){ +Properties::asDouble(std::string element){ std::vector v = std::split(element, "."); YAML::Node nod = this->searchNode(this->node, v); return nod.as(); } +double +Properties::asDoubleWithDefault(std::string element, double dataDefault){ + std::vector v = std::split(element, "."); + + YAML::Node nod = this->searchNode(this->node, v); + double data; + try{ + data = nod.as(); + }catch(YAML::BadConversion e){ + data = dataDefault; + } + return data; +} + YAML::Node -Config::getNode(){ +Properties::getNode(){ return node; } @@ -70,7 +126,7 @@ Config::getNode(){ YAML::Node -Config::searchNode(YAML::Node n, std::vector names){ +Properties::searchNode(YAML::Node n, std::vector names){ YAML::Node nod = n[names[0]]; names.erase(names.begin()); diff --git a/src/libs/config_cpp/src/demo/demo.cpp b/src/libs/config_cpp/src/demo/demo.cpp index 0c713b522..e673d6169 100644 --- a/src/libs/config_cpp/src/demo/demo.cpp +++ b/src/libs/config_cpp/src/demo/demo.cpp @@ -6,11 +6,11 @@ int -main( int argc, const char* argv[] ){ - std::string filename (argv[1]); - JdeRobotConfig::Config props = JdeRobotConfig::load(filename); +main( int argc, char* argv[] ){ + Config::Properties props = Config::load(argc, argv); std::cout << props << std::endl; std::cout << props.asString("Demo.Motors.Proxy")<< std::endl; + std::cout << props.asStringWithDefault("Demo.Motors.Proxy2", "Proxy2")<< std::endl; std::cout << props.asFloat("Demo.Motors.maxW")<< std::endl; std::cout << props.asInt("Demo.Motors.maxV")<< std::endl; diff --git a/src/libs/config_cpp/src/loader.cpp b/src/libs/config_cpp/src/loader.cpp index 898467bb0..c3aeeda36 100644 --- a/src/libs/config_cpp/src/loader.cpp +++ b/src/libs/config_cpp/src/loader.cpp @@ -28,7 +28,7 @@ findConfigFile(const std::string& filename){ if (std::fileexists(filename)) return filename; - std::string path_holders[] = {JdeRobotConfig::HARDCORED_LOCATIONS}; + std::string path_holders[] = {Config::HARDCORED_LOCATIONS}; for (int i=0; i<2; i++){ if (path_holders[i].empty()) continue; for (std::string path : std::split(path_holders[i], ":")){ @@ -42,7 +42,7 @@ findConfigFile(const std::string& filename){ return ""; } -JdeRobotConfig::Config +Config::Properties load(std::string filename){ std::string filepath = findConfigFile(filename); if (filepath.empty()){ @@ -51,7 +51,7 @@ load(std::string filename){ } YAML::Node nodeConfig = YAML::LoadFile(filepath); - JdeRobotConfig::Config config(nodeConfig); + Config::Properties config(nodeConfig); std::cout<<"[Info] loaded YAML Config file: "<setProperty("Ice.Config", filepath); return config; diff --git a/src/libs/config_cpp/src/tests/test_loader.cpp b/src/libs/config_cpp/src/tests/test_loader.cpp index bb919b19b..2a7b9a9a8 100644 --- a/src/libs/config_cpp/src/tests/test_loader.cpp +++ b/src/libs/config_cpp/src/tests/test_loader.cpp @@ -28,6 +28,6 @@ int main(int argc, char* argv[]){ - JdeRobot::Config props = Config::load(argv[1]); + Config::Properties props = Config::load(argv[1]); std::cout << props << std::endl; } diff --git a/src/libs/config_py/demo.py b/src/libs/config_py/demo.py index 8449cefaa..ac3adbc86 100644 --- a/src/libs/config_py/demo.py +++ b/src/libs/config_py/demo.py @@ -23,5 +23,7 @@ import jderobotconfig as config cfg = config.load(sys.argv[1]) + +print (cfg["Demo"]["Motors"]["aaa"]) print config.dump(cfg) diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp index dcb9a43bf..51a8cea00 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp @@ -42,7 +42,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - CameraClient* getCameraClient(JdeRobotComm::Communicator jdrc, std::string prefix); + CameraClient* getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp index fd3dbdba3..e33659a83 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp @@ -21,22 +21,23 @@ #define JDEROBOTCOMM_COMMUNICATOR_H #include -#include +#include +#include namespace JdeRobotComm { class Communicator { public: - Communicator(JdeRobotConfig::Config config); + Communicator(Config::Properties config); ~Communicator(); - JdeRobotConfig::Config getConfig(); + Config::Properties getConfig(); Ice::CommunicatorPtr getIceComm(); private: - JdeRobotConfig::Config config; + Config::Properties config; Ice::CommunicatorPtr ic; }; diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp index a8e78f7b7..769e89cbe 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp @@ -38,7 +38,7 @@ namespace JdeRobotComm { class CameraIceClient: public IceUtil::Thread, public JdeRobotComm::CameraClient { public: - CameraIceClient(JdeRobotComm::Communicator jdrc, std::string prefix); + CameraIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); virtual ~CameraIceClient(); virtual void run(); diff --git a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp b/src/libs/jderobotcomm_cpp/src/cameraClient.cpp index 8c6d83fd2..9632662c5 100644 --- a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/cameraClient.cpp @@ -25,12 +25,12 @@ namespace JdeRobotComm { CameraClient* -getCameraClient(JdeRobotComm::Communicator jdrc, std::string prefix){ +getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ CameraClient* client = 0; //int server = prop->getPropertyAsIntWithDefault(prefix+".Server",0); - int server = jdrc.getConfig().asInt(prefix+".Server"); + int server = jdrc->getConfig().asInt(prefix+".Server"); switch (server){ case 0: { @@ -51,9 +51,9 @@ getCameraClient(JdeRobotComm::Communicator jdrc, std::string prefix){ #ifdef JDERROS std::cout << "Receiving Image from ROS messages" << std::endl; std::string nodeName; - nodeName = jdrc.getConfig().asString(prefix+".Name"); + nodeName = jdrc->getConfig().asString(prefix+".Name"); std::string topic; - topic = jdrc.getConfig().asString(prefix+".Topic"); + topic = jdrc->getConfig().asString(prefix+".Topic"); ListenerCamera* lc; lc = new ListenerCamera(0, nullptr, nodeName, topic); lc->start(); diff --git a/src/libs/jderobotcomm_cpp/src/communicator.cpp b/src/libs/jderobotcomm_cpp/src/communicator.cpp index aa4257b56..5ff40aa21 100644 --- a/src/libs/jderobotcomm_cpp/src/communicator.cpp +++ b/src/libs/jderobotcomm_cpp/src/communicator.cpp @@ -20,8 +20,9 @@ namespace JdeRobotComm { -Communicator::Communicator(JdeRobotConfig::Config config){ +Communicator::Communicator(Config::Properties config){ this->config = config; + this->ic = Ice::initialize(); } @@ -31,7 +32,7 @@ Communicator::~Communicator(){ -JdeRobotConfig::Config +Config::Properties Communicator::getConfig(){ return this->config; } diff --git a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp b/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp index 5a7dc8b62..ba6530cea 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp @@ -21,11 +21,13 @@ #include "jderobot/comm/ice/cameraIceClient.hpp" +#include + namespace JdeRobotComm { -CameraIceClient::CameraIceClient(JdeRobotComm::Communicator jdrc, std::string prefix) { +CameraIceClient::CameraIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; Ice::ObjectPrx baseCamera; @@ -34,11 +36,11 @@ CameraIceClient::CameraIceClient(JdeRobotComm::Communicator jdrc, std::string pr - float fps=jdrc.getConfig().asFloat(prefix+".Fps"); + float fps=jdrc->getConfig().asFloat(prefix+".Fps"); this->cycle=(1/fps)*1000000; try{ - std::string proxy = jdrc.getConfig().asString(prefix+".Proxy"); - baseCamera = jdrc.getIceComm()->stringToProxy(proxy); + std::string proxy = jdrc->getConfig().asString(prefix+".Proxy"); + baseCamera = jdrc->getIceComm()->stringToProxy(proxy); if (0==baseCamera){ this->on = false; throw prefix + "Could not create proxy with Camera"; @@ -60,7 +62,7 @@ CameraIceClient::CameraIceClient(JdeRobotComm::Communicator jdrc, std::string pr } //check if default format is defined - std::string definedFormat=jdrc.getConfig().asString(prefix+".Format"); + std::string definedFormat=jdrc->getConfig().asString(prefix+".Format"); this->mImageFormat = CameraUtils::negotiateDefaultFormat(this->prx,definedFormat); @@ -127,12 +129,16 @@ CameraIceClient::run(){ try{ + dataPtr = this->prx->getImageData(this->mImageFormat); + + // Putting image data img.data = CameraUtils::getImageFromCameraProxy(dataPtr); + img.format = dataPtr->description->format; img.width = dataPtr->description->width; img.height = dataPtr->description->height; @@ -140,9 +146,10 @@ CameraIceClient::run(){ + } - catch(...){ - LOG(WARNING) << prefix +"error during request (connection error)"; + catch(std::exception& e){ + LOG(WARNING) << prefix +"error during request (connection error): " << e.what() << std::endl; usleep(50000); } diff --git a/src/tools/cameraview/CMakeLists.txt b/src/tools/cameraview/CMakeLists.txt index 15c6a2266..e5733d563 100644 --- a/src/tools/cameraview/CMakeLists.txt +++ b/src/tools/cameraview/CMakeLists.txt @@ -11,15 +11,15 @@ include_directories( ${gtkglextmm_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${resourcelocator_INCLUDE_DIRS} - ${easyiceconfig_INCLUDE_DIRS} ${jderobottypes_INCLUDE_DIRS} ${jderobotcomm_INCLUDE_DIRS} + ${jderobotconfig_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} ) link_directories( ${resourcelocator_LIBRARY_DIRS} - ${easyiceconfig_LIBRARY_DIRS} ${jderobotcomm_LIBRARY_DIRS} + ${jderobotconfig_LIBRARY_DIRS} ) add_executable (cameraview ${SOURCE_FILES}) @@ -31,13 +31,13 @@ TARGET_LINK_LIBRARIES(cameraview ${gtkmm_LIBRARIES} ${libglademm_LIBRARIES} colorspacesmm - ${easyiceconfig_LIBRARIES} ${ZeroCIce_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${resourcelocator_LIBRARIES} ${catkin_LIBRARIES} ${jderobotcomm_LIBRARIES} + ${jderobotconfig_LIBRARIES} ${GLOG_LIBRARIES} JderobotInterfaces jderobotutil @@ -49,4 +49,4 @@ install(TARGETS cameraview ) INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cameraview.glade DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/glade) -INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cameraview.cfg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf) +INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cameraview.yml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf) diff --git a/src/tools/cameraview/cameraview.cfg b/src/tools/cameraview/cameraview.cfg deleted file mode 100644 index 3dbc09deb..000000000 --- a/src/tools/cameraview/cameraview.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -Cameraview.Camera.Server=1 -Cameraview.Camera.Proxy=cameraA:tcp -h localhost -p 9999 -Cameraview.Camera.Format=RGB8 -Cameraview.Camera.Topic=/camera/rgb/image_raw -Cameraview.Camera.Name=cameraA \ No newline at end of file diff --git a/src/tools/cameraview/cameraview.cpp b/src/tools/cameraview/cameraview.cpp index 61484afd7..dd9e542f9 100644 --- a/src/tools/cameraview/cameraview.cpp +++ b/src/tools/cameraview/cameraview.cpp @@ -24,20 +24,22 @@ #include #include #include "viewer.h" -#include "easyiceconfig/EasyIce.h" +#include +#include #include #include int main(int argc, char** argv){ cameraview::Viewer viewer; - Ice::CommunicatorPtr ic; + JdeRobotComm::CameraClient* camRGB; - ic = EasyIce::initialize(argc,argv); + Config::Properties cfg = Config::load(argc, argv); + JdeRobotComm::Communicator* jdrc = new JdeRobotComm::Communicator(cfg); - camRGB = JdeRobotComm::getCameraClient(ic, "Cameraview.Camera"); + camRGB = JdeRobotComm::getCameraClient(jdrc, "Cameraview.Camera"); JdeRobotTypes::Image rgb; @@ -49,5 +51,7 @@ int main(int argc, char** argv){ viewer.displayFrameRate(0); } + delete jdrc; + return 0; } diff --git a/src/tools/cameraview/cameraview.yml b/src/tools/cameraview/cameraview.yml new file mode 100644 index 000000000..794c83f25 --- /dev/null +++ b/src/tools/cameraview/cameraview.yml @@ -0,0 +1,10 @@ +Cameraview: + Camera: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "cameraA:tcp -h localhost -p 9999" + Format: RGB8 + Topic: "/TurtlebotROS/cameraL/image_raw" + Name: cameraA + Fps: 30 + + NodeName: cameraview \ No newline at end of file From be50d2d8f7aacad98b5353643619212918fbf316 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 27 Sep 2017 14:45:50 +0200 Subject: [PATCH 09/14] finished config_py and updated jderobotComm to use it --- src/libs/config_py/CMakeLists.txt | 8 +-- .../{jderobotconfig => config}/__init__.py | 2 + .../{jderobotconfig => config}/config.py | 11 ++- .../hardcodedpaths.py.in | 0 src/libs/config_py/config/properties.py | 52 ++++++++++++++ src/libs/config_py/demo.py | 6 +- .../jderobotComm/cameraClient.py.only-ice.in | 7 +- .../jderobotComm/cameraClient.py.ros.in | 12 ++-- .../jderobotComm/communicator.py.only-ice.in | 7 +- .../jderobotComm/communicator.py.ros.in | 16 ++--- .../jderobotComm/ice/cameraIceClient.py | 6 +- .../jderobotComm/ice/laserIceClient.py | 9 +-- .../jderobotComm/ice/motorsIceClient.py | 23 ++++-- .../jderobotComm/ice/pose3dIceClient.py | 8 ++- .../jderobotComm/laserClient.py.only-ice.in | 5 +- .../jderobotComm/laserClient.py.ros.in | 10 ++- .../jderobotComm/motorsClient.py.only-ice.in | 7 +- .../jderobotComm/motorsClient.py.ros.in | 16 ++--- .../jderobotComm/pose3dClient.py.only-ice.in | 3 +- .../jderobotComm/pose3dClient.py.ros.in | 6 +- src/libs/jderobotcomm_py/test.yml | 70 ++++++++++--------- src/libs/jderobotcomm_py/testCamera.py | 4 +- src/libs/jderobotcomm_py/testLaser.py | 8 +-- src/libs/jderobotcomm_py/testMotors.py | 6 +- src/libs/jderobotcomm_py/testPose.py | 6 +- 25 files changed, 181 insertions(+), 127 deletions(-) rename src/libs/config_py/{jderobotconfig => config}/__init__.py (84%) rename src/libs/config_py/{jderobotconfig => config}/config.py (93%) rename src/libs/config_py/{jderobotconfig => config}/hardcodedpaths.py.in (100%) create mode 100644 src/libs/config_py/config/properties.py diff --git a/src/libs/config_py/CMakeLists.txt b/src/libs/config_py/CMakeLists.txt index 920405185..61d72763f 100644 --- a/src/libs/config_py/CMakeLists.txt +++ b/src/libs/config_py/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 2.8) -configure_module_python(jderobotconfig) +configure_module_python(config) -add_custom_target(jderobotconfig_py ALL) -copy_to_binary_python(jderobotconfig_py jderobotconfig) +add_custom_target(config_py ALL) +copy_to_binary_python(config_py config) -install_python(jderobotconfig core) +install_python(config core) diff --git a/src/libs/config_py/jderobotconfig/__init__.py b/src/libs/config_py/config/__init__.py similarity index 84% rename from src/libs/config_py/jderobotconfig/__init__.py rename to src/libs/config_py/config/__init__.py index f62ff62a3..bf0e04445 100644 --- a/src/libs/config_py/jderobotconfig/__init__.py +++ b/src/libs/config_py/config/__init__.py @@ -7,3 +7,5 @@ # import jderobotconfig as config from .config import * +from .properties import Properties + diff --git a/src/libs/config_py/jderobotconfig/config.py b/src/libs/config_py/config/config.py similarity index 93% rename from src/libs/config_py/jderobotconfig/config.py rename to src/libs/config_py/config/config.py index f2f60feb0..7c04ca59a 100644 --- a/src/libs/config_py/jderobotconfig/config.py +++ b/src/libs/config_py/config/config.py @@ -21,6 +21,7 @@ import sys, os import yaml from .hardcodedpaths import HARDCODED_PATHS +from .properties import Properties def findConfigFile(filename): @@ -58,17 +59,15 @@ def load(filename): ''' filepath = findConfigFile(filename) - properties= None + prop= None if (filepath): print ('loading Config file %s' %(filepath)) with open(filepath, 'r') as stream: - properties=yaml.load(stream) + cfg=yaml.load(stream) + prop = Properties(cfg) else: msg = "Ice.Config file '%s' could not being found" % (filename) raise ValueError(msg) - return properties - -def dump(conf): - return yaml.dump(conf) + return prop \ No newline at end of file diff --git a/src/libs/config_py/jderobotconfig/hardcodedpaths.py.in b/src/libs/config_py/config/hardcodedpaths.py.in similarity index 100% rename from src/libs/config_py/jderobotconfig/hardcodedpaths.py.in rename to src/libs/config_py/config/hardcodedpaths.py.in diff --git a/src/libs/config_py/config/properties.py b/src/libs/config_py/config/properties.py new file mode 100644 index 000000000..4fd69549c --- /dev/null +++ b/src/libs/config_py/config/properties.py @@ -0,0 +1,52 @@ +# +# Copyright (C) 1997-2017 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Aitor Martinez Fernandez +# +__author__ = 'aitormf' + +import yaml + +class Properties: + def __init__(self, cfg): + self._config = cfg + + def getNode(self): + return self._config + + def getProperty(self, name): + + names = name.split(".") + + return self._searchNode(self._config, names) + + def getPropertyWithDefault(self, name, dataDefault): + return dataDefault + + + def _searchNode(self, node, lst): + name = lst.pop(0) + + nod = node[name] + + if (len(lst) > 0): + return (self._searchNode(nod, lst)) + else: + return nod + + def __str__(self): + return yaml.dump(self._config) + diff --git a/src/libs/config_py/demo.py b/src/libs/config_py/demo.py index ac3adbc86..f0e35309b 100644 --- a/src/libs/config_py/demo.py +++ b/src/libs/config_py/demo.py @@ -20,10 +20,10 @@ import sys -import jderobotconfig as config +import config cfg = config.load(sys.argv[1]) -print (cfg["Demo"]["Motors"]["aaa"]) -print config.dump(cfg) +print (cfg.getProperty("Demo.Motors.Server")) +print cfg diff --git a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in index 6715b3e63..a38e943a6 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in @@ -53,12 +53,12 @@ def __Cameradisabled(jdrc, prefix): print( prefix + " Disabled") return None -def getCameraClient (jdrc, name): +def getCameraClient (jdrc, prefix): ''' Returns a Camera Client. @param jdrc: JdeRobotComm Communicator - @param name: name of client in config file + @param prefix: name of client in config file @type jdrc: JdeRobotComm Communicator @type name: String @@ -66,8 +66,7 @@ def getCameraClient (jdrc, name): @return None if Camera is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 diff --git a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in index 84bd3f9d8..344af98dc 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in @@ -39,8 +39,7 @@ def __getListenerCamera(jdrc, prefix): ''' if (sys.version_info[0] == 2): print("Receiving " + prefix + " Image from ROS messages") - cfg = jdrc.getConfig(prefix) - topic = cfg["Topic"] + topic = jdrc.getConfig().getProperty(prefix+".topic") client = ListenerCamera(topic) return client else: @@ -63,12 +62,12 @@ def __Cameradisabled(jdrc, prefix): print( prefix + " Disabled") return None -def getCameraClient (jdrc, name): +def getCameraClient (jdrc, prefix): ''' Returns a Camera Client. @param jdrc: JdeRobotComm Communicator - @param name: name of client in config file + @param prefix: name of client in config file @type jdrc: JdeRobotComm Communicator @type name: String @@ -76,11 +75,10 @@ def getCameraClient (jdrc, name): @return None if Camera is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 cons = [__Cameradisabled, __getCameraIceClient, __getListenerCamera] - return cons[server](jdrc, cfg) \ No newline at end of file + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in index a2b568735..c24623ce9 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in @@ -50,11 +50,8 @@ class Communicator: def getIc(self): return self.__ic - def getConfig(self, name=None): - if name: - return self.config[name] - else: - return self.config + def getConfig(self): + return self.config def getCameraClient(self, name): diff --git a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in index 5e100846e..d07bae1f7 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in @@ -28,14 +28,15 @@ class Communicator: self.__ic = None self.config = config - for i in self.config: - if type(self.config[i]) is dict and self.config[i]["Server"] == 1: + ymlNode = self.config.getNode() + for i in ymlNode: + if type(ymlNode[i]) is dict and ymlNode[i]["Server"] == 1: iceserver = True - if type(self.config[i]) is dict and self.config[i]["Server"] == 2: + if type(ymlNode[i]) is dict and ymlNode[i]["Server"] == 2: rosserver = True if rosserver: - self.__node = rospy.init_node(config["NodeName"], anonymous=True) + self.__node = rospy.init_node(ymlNode["NodeName"], anonymous=True) if iceserver: id = Ice.InitializationData() self.__ic = Ice.initialize(None, id) @@ -57,11 +58,8 @@ class Communicator: def getIc(self): return self.__ic - def getConfig(self, name=None): - if name: - return self.config[name] - else: - return self.config + def getConfig(self): + return self.config def getCameraClient(self, name): diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py b/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py index d276dea00..a6dfe89f9 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py +++ b/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py @@ -48,11 +48,11 @@ def __init__(self, jdrc, prefix): try: - cfg = jdrc.getConfig(prefix) ic = jdrc.getIc() - basecamera = ic.stringToProxy(cfg["Proxy"]) + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + basecamera = ic.stringToProxy(proxyStr) self.proxy = jderobot.CameraPrx.checkedCast(basecamera) - self.imgFormat = cfg["Format"] + self.imgFormat = jdrc.getConfig().getProperty(prefix+".Format") if not self.imgFormat: self.imgFormat = "RGB8" diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/laserIceClient.py b/src/libs/jderobotcomm_py/jderobotComm/ice/laserIceClient.py index f89a45ba4..d6a8bcc44 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/laserIceClient.py +++ b/src/libs/jderobotcomm_py/jderobotComm/ice/laserIceClient.py @@ -30,12 +30,12 @@ class Laser: Laser Connector. Recives LaserData from Ice interface when you run update method. ''' - def __init__(self, ic, prefix): + def __init__(self, jdrc, prefix): ''' Laser Contructor. Exits When it receives a Exception diferent to Ice.ConnectionRefusedException - @param ic: Ice Communicator + @param jdrc: JdeRobotComm Communicator @param prefix: prefix name of client in config file @type ic: Ice Communicator @@ -45,9 +45,10 @@ def __init__(self, ic, prefix): self.laser = LaserData() try: - base = ic.propertyToProxy(prefix+".Proxy") + ic = jdrc.getIc() + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + base = ic.stringToProxy(proxyStr) self.proxy = jderobot.LaserPrx.checkedCast(base) - prop = ic.getProperties() self.update() diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/motorsIceClient.py b/src/libs/jderobotcomm_py/jderobotComm/ice/motorsIceClient.py index 53a269609..6a59c9494 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/motorsIceClient.py +++ b/src/libs/jderobotcomm_py/jderobotComm/ice/motorsIceClient.py @@ -27,11 +27,23 @@ class MotorsIceClient: - def __init__(self, ic, prefix): + + ''' + Motors Contructor. + Exits When it receives a Exception diferent to Ice.ConnectionRefusedException + + @param jdrc: JdeRobotComm Communicator + @param prefix: prefix name of client in config file + + @type ic: Ice Communicator + @type prefix: String + ''' + def __init__(self, jdrc, prefix): self.lock = threading.Lock() - prop = ic.getProperties() + ic = jdrc.getIc() + - maxWstr = prop.getProperty(prefix+".maxW") + maxWstr = jdrc.getConfig().getProperty(prefix+".maxW") if maxWstr: self.maxW = float(maxWstr) else: @@ -39,7 +51,7 @@ def __init__(self, ic, prefix): print (prefix+".maxW not provided, the default value is used: "+ repr(self.maxW)) - maxVstr = prop.getProperty(prefix+".maxV") + maxVstr = jdrc.getConfig().getProperty(prefix+".maxV") if maxWstr: self.maxV = float(maxVstr) else: @@ -47,7 +59,8 @@ def __init__(self, ic, prefix): print (prefix+".maxV not provided, the default value is used: "+ repr(self.maxV)) try: - base = ic.propertyToProxy(prefix+".Proxy") + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + base = ic.stringToProxy(proxyStr) self.proxy = jderobot.MotorsPrx.checkedCast(base) diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/pose3dIceClient.py b/src/libs/jderobotcomm_py/jderobotComm/ice/pose3dIceClient.py index 1da49c129..851bc3a73 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/pose3dIceClient.py +++ b/src/libs/jderobotcomm_py/jderobotComm/ice/pose3dIceClient.py @@ -31,12 +31,12 @@ class Pose3D: Pose3d Connector. Recives Pose3d from Ice interface when you run update method. ''' - def __init__(self, ic, prefix): + def __init__(self, jdrc, prefix): ''' Pose3d Contructor. Exits When it receives a Exception diferent to Ice.ConnectionRefusedException - @param ic: Ice Communicator + @param jdrc: JdeRobotComm Communicator @param prefix: prefix name of client in config file @type ic: Ice Communicator @@ -47,7 +47,9 @@ def __init__(self, ic, prefix): self.pose = Pose3d() try: - base = ic.propertyToProxy(prefix+".Proxy") + ic = jdrc.getIc() + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + base = ic.stringToProxy(proxyStr) self.proxy = jderobot.Pose3DPrx.checkedCast(base) prop = ic.getProperties() diff --git a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in index 6dfeff5a8..48d3ee01a 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in @@ -53,7 +53,7 @@ def __Laserdisabled(jdrc, prefix): print( prefix + " Disabled") return None -def getLaserClient (jdrc, name): +def getLaserClient (jdrc, prefix): ''' Returns a Laser Client. @@ -66,8 +66,7 @@ def getLaserClient (jdrc, name): @return None if Laser is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 diff --git a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in index 16af57f99..97bbce83a 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in @@ -39,8 +39,7 @@ def __getListenerLaser(jdrc, prefix): ''' if (sys.version_info[0] == 2): print("Receiving " + prefix + " LaserData from ROS messages") - cfg = jdrc.getConfig(prefix) - topic = cfg["Topic"] + topic = jdrc.getConfig().getProperty(prefix+".Topic") client = ListenerLaser(topic) return client else: @@ -63,12 +62,12 @@ def __Laserdisabled(jdrc, prefix): print( prefix + " Disabled") return None -def getLaserClient (jdrc, name): +def getLaserClient (jdrc, prefix): ''' Returns a Laser Client. @param jdrc: JdeRobotComm Communicator - @param name: name of client in config file + @param prefix: name of client in config file @type jdrc: JdeRobotComm Communicator @type name: String @@ -76,8 +75,7 @@ def getLaserClient (jdrc, name): @return None if Laser is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 diff --git a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in index 42908682b..0dc6bb816 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in @@ -55,7 +55,7 @@ def __Motorsdisabled(jdrc, prefix): print(prefix + " Disabled") return None -def getMotorsClient (jdrc, name): +def getMotorsClient (jdrc, prefix): ''' Returns a Motors Client. @@ -70,11 +70,10 @@ def getMotorsClient (jdrc, name): @return None if Motors is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 cons = [__Motorsdisabled, __getMotorsIceClient, __getPublisherMotors] - return cons[server](jdrc, name) \ No newline at end of file + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in index 2bf9e17a2..c48d2922d 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in @@ -19,7 +19,7 @@ def __getMotorsIceClient(jdrc, prefix): @return Motors Ice Client ''' - print("Publishing "+ prefix +" with ICE interfaces") + print("Publishing "+ prefix +" with ICE interfaces") client = MotorsIceClient(jdrc, prefix) client.start() return client @@ -39,16 +39,15 @@ def __getPublisherMotors(jdrc, prefix): ''' if (sys.version_info[0] == 2): print("Publishing "+ prefix + " with ROS messages") - cfg = jdrc.getConfig(prefix) - topic = cfg["Topic"] + topic = jdrc.getConfig().getProperty(prefix+".Topic") - maxW = cfg["maxW"] + maxW = jdrc.getConfig().getProperty(prefix+".maxW") if not maxW: maxW = 0.5 print (prefix+".maxW not provided, the default value is used: "+ repr(maxW)) - maxV = cfg["maxV"] + maxV = jdrc.getConfig().getProperty(prefix+".maxV") if not maxV: maxV = 5 print (prefix+".maxV not provided, the default value is used: "+ repr(maxV)) @@ -76,7 +75,7 @@ def __Motorsdisabled(jdrc, prefix): print(prefix + " Disabled") return None -def getMotorsClient (jdrc, name): +def getMotorsClient (jdrc, prefix): ''' Returns a Motors Client. @@ -91,11 +90,10 @@ def getMotorsClient (jdrc, name): @return None if Motors is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 cons = [__Motorsdisabled, __getMotorsIceClient, __getPublisherMotors] - return cons[server](jdrc, name) \ No newline at end of file + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in index d9a6aeff5..f66a3f690 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in @@ -67,8 +67,7 @@ def getPose3dClient (jdrc, prefix): @return None if pose3d is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 diff --git a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in index 4236e4931..ddd9665bb 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in +++ b/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in @@ -41,8 +41,7 @@ def __getListenerPose(jdrc, prefix): ''' if (sys.version_info[0] == 2): print("Receiving " + prefix + " from ROS messages") - cfg = jdrc.getConfig(prefix) - topic = cfg["Topic"] + topic = jdrc.getConfig().getProperty(prefix+".Topic") client = ListenerPose3d(topic) return client else: @@ -79,8 +78,7 @@ def getPose3dClient (jdrc, prefix): @return None if pose3d is disabled ''' - cfg = jdrc.getConfig(name) - server = cfg["Server"] + server = jdrc.getConfig().getProperty(prefix+".Server") if not server: server=0 diff --git a/src/libs/jderobotcomm_py/test.yml b/src/libs/jderobotcomm_py/test.yml index dbb538994..967c8eaa7 100644 --- a/src/libs/jderobotcomm_py/test.yml +++ b/src/libs/jderobotcomm_py/test.yml @@ -1,36 +1,38 @@ -test: - Motors: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "Motors:default -h localhost -p 9001" - Topic: "/cmd_vel_mux/input/teleop" - Name: testMotors - - Camera1: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "CameraL:default -h localhost -p 9001" - Format: RGB8 - Topic: "/camera/rgb/image_raw" - Name: testCamera1 - Camera2: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "CameraR:default -h localhost -p 9001" - Format: RGB8 - Topic: "/camera/rgb/image_raw" - Name: testCamera2 - - Pose3D: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "Pose3D:default -h localhost -p 9001" - Topic: "/odom" - Name: testPose3d - - Laser: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "Laser:default -h localhost -p 9001" - Topic: "/scan" - Name: testLaser +Motors: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Motors:default -h localhost -p 9001" + Topic: "/cmd_vel_mux/input/teleop" + Name: testMotors + maxV: 3 + maxW: 0.7 - Vmax: 3 - Wmax: 0.7 - NodeName: JdeRobotCommTest \ No newline at end of file +Camera1: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera1 + +Camera2: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraR:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera2 + +Pose3D: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Pose3D:default -h localhost -p 9001" + Topic: "/odom" + Name: testPose3d + +Laser: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Laser:default -h localhost -p 9001" + Topic: "/scan" + Name: testLaser + +Vmax: 3 +Wmax: 0.7 +NodeName: JdeRobotCommTest \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/testCamera.py b/src/libs/jderobotcomm_py/testCamera.py index 83c2dcaa3..de4a9a021 100755 --- a/src/libs/jderobotcomm_py/testCamera.py +++ b/src/libs/jderobotcomm_py/testCamera.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -import jderobotconfig as config +import config import jderobotComm as comm import sys import time @@ -13,7 +13,7 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg["test"]) + jdrc= comm.init(cfg) client = jdrc.getCameraClient("Camera1") diff --git a/src/libs/jderobotcomm_py/testLaser.py b/src/libs/jderobotcomm_py/testLaser.py index 167155f6b..bf6e17b22 100755 --- a/src/libs/jderobotcomm_py/testLaser.py +++ b/src/libs/jderobotcomm_py/testLaser.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -import jderobotconfig as config +import config import jderobotComm as comm import sys import time @@ -13,10 +13,10 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg["test"]) + jdrc= comm.init(cfg) - client = jdrc.getLaserClient(ic, "Laser") - client2 = jdrc.getLaserClient(ic, "Laser") + client = jdrc.getLaserClient("Laser") + client2 = jdrc.getLaserClient("Laser") for i in range (10): #print("client1", end=":") diff --git a/src/libs/jderobotcomm_py/testMotors.py b/src/libs/jderobotcomm_py/testMotors.py index b323f72ca..ed4033bb0 100644 --- a/src/libs/jderobotcomm_py/testMotors.py +++ b/src/libs/jderobotcomm_py/testMotors.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import jderobotconfig as config +import config import jderobotComm as comm import sys import time @@ -13,13 +13,13 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg["test"]) + jdrc= comm.init(cfg) vel = CMDVel() vel.vx = 1 vel.az = 0.1 - client = jdrc.getMotorsClient(ic, "Motors") + client = jdrc.getMotorsClient("Motors") for i in range (10): client.sendVelocities(vel) time.sleep(1) diff --git a/src/libs/jderobotcomm_py/testPose.py b/src/libs/jderobotcomm_py/testPose.py index fa432d0e5..697e41d6a 100644 --- a/src/libs/jderobotcomm_py/testPose.py +++ b/src/libs/jderobotcomm_py/testPose.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import jderobotconfig as config +import config import jderobotComm as comm import sys import time @@ -13,9 +13,9 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg["test"]) + jdrc= comm.init(cfg) - client = jdrc.getPose3dClient(ic, "kobukiViewer.Pose3D") + client = jdrc.getPose3dClient("Pose3D") for i in range (10): #print("client1", end=":") From 214dc08f9c3867dce353c8eeb7f656966a2722dc Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 27 Sep 2017 16:27:25 +0200 Subject: [PATCH 10/14] updated jderobotcomm to use config library --- .../include/jderobot/comm/cameraClient.hpp | 1 - .../include/jderobot/comm/ice/laserIceClient.hpp | 3 ++- .../include/jderobot/comm/ice/motorsIceClient.hpp | 3 ++- .../include/jderobot/comm/ice/pose3dIceClient.hpp | 3 ++- .../include/jderobot/comm/laserClient.hpp | 4 ++-- .../include/jderobot/comm/motorsClient.hpp | 4 ++-- .../include/jderobot/comm/pose3dClient.hpp | 4 ++-- src/libs/jderobotcomm_cpp/src/cameraClient.cpp | 7 +++---- .../jderobotcomm_cpp/src/ice/cameraIceClient.cpp | 4 ++-- .../jderobotcomm_cpp/src/ice/laserIceClient.cpp | 12 ++++++------ .../jderobotcomm_cpp/src/ice/motorsIceClient.cpp | 8 +++----- .../jderobotcomm_cpp/src/ice/pose3dIceClient.cpp | 13 ++++++------- src/libs/jderobotcomm_cpp/src/laserClient.cpp | 14 ++++++-------- src/libs/jderobotcomm_cpp/src/motorsClient.cpp | 11 +++++------ src/libs/jderobotcomm_cpp/src/pose3dClient.cpp | 11 +++++------ 15 files changed, 48 insertions(+), 54 deletions(-) diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp index 51a8cea00..32d9fc5da 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/laserIceClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/laserIceClient.hpp index eaf45ff91..537f5c0e6 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/laserIceClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/laserIceClient.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace JdeRobotComm { @@ -38,7 +39,7 @@ namespace JdeRobotComm { class LaserIceClient: public IceUtil::Thread, public JdeRobotComm::LaserClient { public: - LaserIceClient(Ice::CommunicatorPtr ic, std::string prefix); + LaserIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); virtual ~LaserIceClient(); virtual void run(); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp index 6c1e4375d..71b8647a6 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace JdeRobotComm { @@ -32,7 +33,7 @@ namespace JdeRobotComm { class MotorsIceClient: public JdeRobotComm::MotorsClient { public: - MotorsIceClient(Ice::CommunicatorPtr ic, std::string prefix); + MotorsIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); virtual ~MotorsIceClient(); virtual void sendVelocities(JdeRobotTypes::CMDVel vel); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp index 1e98c912c..510bd9a88 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include namespace JdeRobotComm { @@ -35,7 +36,7 @@ namespace JdeRobotComm { class Pose3dIceClient: public IceUtil::Thread, public JdeRobotComm::Pose3dClient { public: - Pose3dIceClient(Ice::CommunicatorPtr ic, std::string prefix); + Pose3dIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); virtual ~Pose3dIceClient(); virtual void run(); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/laserClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/laserClient.hpp index 7ccc72b72..0844c1875 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/laserClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/laserClient.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -40,7 +40,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - LaserClient* getLaserClient(Ice::CommunicatorPtr ic, std::string prefix); + LaserClient* getLaserClient(JdeRobotComm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/motorsClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/motorsClient.hpp index ae544b440..7e1a3b3db 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/motorsClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/motorsClient.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -41,7 +41,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - MotorsClient* getMotorsClient(Ice::CommunicatorPtr ic, std::string prefix); + MotorsClient* getMotorsClient(JdeRobotComm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/pose3dClient.hpp b/src/libs/jderobotcomm_cpp/include/jderobot/comm/pose3dClient.hpp index 99780ee12..90e7c7ded 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/pose3dClient.hpp +++ b/src/libs/jderobotcomm_cpp/include/jderobot/comm/pose3dClient.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -41,7 +41,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - Pose3dClient* getPose3dClient(Ice::CommunicatorPtr ic, std::string prefix); + Pose3dClient* getPose3dClient(JdeRobotComm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp b/src/libs/jderobotcomm_cpp/src/cameraClient.cpp index 9632662c5..27054d7dc 100644 --- a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/cameraClient.cpp @@ -29,8 +29,7 @@ getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ CameraClient* client = 0; - //int server = prop->getPropertyAsIntWithDefault(prefix+".Server",0); - int server = jdrc->getConfig().asInt(prefix+".Server"); + int server = jdrc->getConfig().asIntWithDefault(prefix+".Server", 0); switch (server){ case 0: { @@ -51,9 +50,9 @@ getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ #ifdef JDERROS std::cout << "Receiving Image from ROS messages" << std::endl; std::string nodeName; - nodeName = jdrc->getConfig().asString(prefix+".Name"); + nodeName = jdrc->getConfig().asStringWithDefault(prefix+".Name", "LaserNode"); std::string topic; - topic = jdrc->getConfig().asString(prefix+".Topic"); + topic = jdrc->getConfig().asStringWithDefault(prefix+".Topic", ""); ListenerCamera* lc; lc = new ListenerCamera(0, nullptr, nodeName, topic); lc->start(); diff --git a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp b/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp index ba6530cea..37c206890 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp @@ -36,7 +36,7 @@ CameraIceClient::CameraIceClient(JdeRobotComm::Communicator* jdrc, std::string p - float fps=jdrc->getConfig().asFloat(prefix+".Fps"); + float fps=jdrc->getConfig().asFloatWithDefault(prefix+".Fps", 30); this->cycle=(1/fps)*1000000; try{ std::string proxy = jdrc->getConfig().asString(prefix+".Proxy"); @@ -62,7 +62,7 @@ CameraIceClient::CameraIceClient(JdeRobotComm::Communicator* jdrc, std::string p } //check if default format is defined - std::string definedFormat=jdrc->getConfig().asString(prefix+".Format"); + std::string definedFormat=jdrc->getConfig().asStringWithDefault(prefix+".Format", "RGB8"); this->mImageFormat = CameraUtils::negotiateDefaultFormat(this->prx,definedFormat); diff --git a/src/libs/jderobotcomm_cpp/src/ice/laserIceClient.cpp b/src/libs/jderobotcomm_cpp/src/ice/laserIceClient.cpp index 61ee6656c..3334328ec 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/laserIceClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/ice/laserIceClient.cpp @@ -22,17 +22,17 @@ namespace JdeRobotComm { -LaserIceClient::LaserIceClient(Ice::CommunicatorPtr ic, std::string prefix) { +LaserIceClient::LaserIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; - Ice::PropertiesPtr prop; - prop = ic->getProperties(); + this->refreshRate=0; - int fps=prop->getPropertyAsIntWithDefault(prefix+".Fps",10); - this->cycle=(float)(1/(float)fps)*1000000; + float fps=jdrc->getConfig().asFloatWithDefault(prefix+".Fps",10); + this->cycle=(1/fps)*1000000; - Ice::ObjectPrx baseLaser = ic->propertyToProxy(prefix+".Proxy"); + std::string proxy = jdrc->getConfig().asString(prefix+".Proxy"); + Ice::ObjectPrx baseLaser = jdrc->getIceComm()->stringToProxy(proxy); if (0==baseLaser){ this->on = false; diff --git a/src/libs/jderobotcomm_cpp/src/ice/motorsIceClient.cpp b/src/libs/jderobotcomm_cpp/src/ice/motorsIceClient.cpp index a2666afd4..bb050670c 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/motorsIceClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/ice/motorsIceClient.cpp @@ -21,14 +21,12 @@ namespace JdeRobotComm { -MotorsIceClient::MotorsIceClient(Ice::CommunicatorPtr ic, std::string prefix) { +MotorsIceClient::MotorsIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; - Ice::PropertiesPtr prop; - prop = ic->getProperties(); - - Ice::ObjectPrx baseMotors = ic->propertyToProxy(prefix+".Proxy"); + std::string proxy = jdrc->getConfig().asString(prefix+".Proxy"); + Ice::ObjectPrx baseMotors = jdrc->getIceComm()->stringToProxy(proxy); if (0==baseMotors){ this->on = false; diff --git a/src/libs/jderobotcomm_cpp/src/ice/pose3dIceClient.cpp b/src/libs/jderobotcomm_cpp/src/ice/pose3dIceClient.cpp index 574725b62..ed4867caf 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/pose3dIceClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/ice/pose3dIceClient.cpp @@ -21,17 +21,16 @@ namespace JdeRobotComm { -Pose3dIceClient::Pose3dIceClient(Ice::CommunicatorPtr ic, std::string prefix) { +Pose3dIceClient::Pose3dIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; - Ice::PropertiesPtr prop; - prop = ic->getProperties(); + - int fps=prop->getPropertyAsIntWithDefault(prefix+".Fps",30); - this->cycle=(float)(1/(float)fps)*1000000; + float fps=jdrc->getConfig().asFloatWithDefault(prefix+".Fps",30); + this->cycle=(1/fps)*1000000; - - Ice::ObjectPrx basePose = ic->propertyToProxy(prefix+".Proxy"); + std::string proxy = jdrc->getConfig().asString(prefix+".Proxy"); + Ice::ObjectPrx basePose = jdrc->getIceComm()->stringToProxy(proxy); if (0==basePose){ this->on = false; diff --git a/src/libs/jderobotcomm_cpp/src/laserClient.cpp b/src/libs/jderobotcomm_cpp/src/laserClient.cpp index ad1898664..5d13b1c86 100644 --- a/src/libs/jderobotcomm_cpp/src/laserClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/laserClient.cpp @@ -7,12 +7,10 @@ namespace JdeRobotComm { LaserClient* -getLaserClient(Ice::CommunicatorPtr ic, std::string prefix){ +getLaserClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ LaserClient* client = 0; - Ice::PropertiesPtr prop = ic->getProperties(); - - int server = prop->getPropertyAsIntWithDefault(prefix+".Server",0); + int server = jdrc->getConfig().asIntWithDefault(prefix+".Server", 0); switch (server){ case 0: { @@ -23,7 +21,7 @@ getLaserClient(Ice::CommunicatorPtr ic, std::string prefix){ { std::cout << "Receiving LaserData from ICE interfaces" << std::endl; LaserIceClient* cl; - cl = new LaserIceClient(ic, prefix); + cl = new LaserIceClient(jdrc, prefix); cl->start(); client = (JdeRobotComm::LaserClient*) cl; break; @@ -33,9 +31,9 @@ getLaserClient(Ice::CommunicatorPtr ic, std::string prefix){ #ifdef JDERROS std::cout << "Receiving LaserData from ROS messages" << std::endl; std::string nodeName; - nodeName = prop->getPropertyWithDefault(prefix+".Name","LaserNode"); - std::string topic; - topic = prop->getPropertyWithDefault(prefix+".Topic",""); + nodeName = jdrc->getConfig().asStringWithDefault(prefix+".Name", "LaserNode"); + std::string topic; + topic = jdrc->getConfig().asStringWithDefault(prefix+".Topic", ""); ListenerLaser* lc; lc = new ListenerLaser(0, nullptr, nodeName, topic); lc->start(); diff --git a/src/libs/jderobotcomm_cpp/src/motorsClient.cpp b/src/libs/jderobotcomm_cpp/src/motorsClient.cpp index 074edf9d4..4f0aeb076 100644 --- a/src/libs/jderobotcomm_cpp/src/motorsClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/motorsClient.cpp @@ -7,12 +7,11 @@ namespace JdeRobotComm { MotorsClient* -getMotorsClient(Ice::CommunicatorPtr ic, std::string prefix){ +getMotorsClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ MotorsClient* client = 0; - Ice::PropertiesPtr prop = ic->getProperties(); - int server = prop->getPropertyAsIntWithDefault(prefix+".Server",0); + int server = jdrc->getConfig().asIntWithDefault(prefix+".Server", 0); switch (server){ case 0: { @@ -23,7 +22,7 @@ getMotorsClient(Ice::CommunicatorPtr ic, std::string prefix){ { std::cout << "Sending Velocities by ICE interfaces" << std::endl; MotorsIceClient* cl; - cl = new MotorsIceClient(ic, prefix); + cl = new MotorsIceClient(jdrc, prefix); client = (JdeRobotComm::MotorsClient*) cl; break; } @@ -32,9 +31,9 @@ getMotorsClient(Ice::CommunicatorPtr ic, std::string prefix){ #ifdef JDERROS std::cout << "Sending Velocities by ROS messages" << std::endl; std::string nodeName; - nodeName = prop->getPropertyWithDefault(prefix+".Name","MotorsNode"); + nodeName = jdrc->getConfig().asStringWithDefault(prefix+".Name", "MotorsNode"); std::string topic; - topic = prop->getPropertyWithDefault(prefix+".Topic",""); + topic = jdrc->getConfig().asStringWithDefault(prefix+".Topic", ""); PublisherMotors* pm; pm = new PublisherMotors(0, nullptr, nodeName, topic); pm->start(); diff --git a/src/libs/jderobotcomm_cpp/src/pose3dClient.cpp b/src/libs/jderobotcomm_cpp/src/pose3dClient.cpp index 3ea994e45..5aa2d172c 100644 --- a/src/libs/jderobotcomm_cpp/src/pose3dClient.cpp +++ b/src/libs/jderobotcomm_cpp/src/pose3dClient.cpp @@ -7,12 +7,11 @@ namespace JdeRobotComm { Pose3dClient* -getPose3dClient(Ice::CommunicatorPtr ic, std::string prefix){ +getPose3dClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ Pose3dClient* client = 0; - Ice::PropertiesPtr prop = ic->getProperties(); - int server = prop->getPropertyAsIntWithDefault(prefix+".Server",0); + int server = jdrc->getConfig().asIntWithDefault(prefix+".Server", 0); switch (server){ case 0: { @@ -23,7 +22,7 @@ getPose3dClient(Ice::CommunicatorPtr ic, std::string prefix){ { std::cout << "Receiving Pose3D from ICE interfaces" << std::endl; Pose3dIceClient* cl; - cl = new Pose3dIceClient(ic, prefix); + cl = new Pose3dIceClient(jdrc, prefix); cl->start(); client = (JdeRobotComm::Pose3dClient*) cl; break; @@ -33,9 +32,9 @@ getPose3dClient(Ice::CommunicatorPtr ic, std::string prefix){ #ifdef JDERROS std::cout << "Receiving Pose3D from ROS messages" << std::endl; std::string nodeName; - nodeName = prop->getPropertyWithDefault(prefix+".Name","PoseNode"); + nodeName = jdrc->getConfig().asStringWithDefault(prefix+".Name", "PoseNode"); std::string topic; - topic = prop->getPropertyWithDefault(prefix+".Topic",""); + topic = jdrc->getConfig().asStringWithDefault(prefix+".Topic", ""); ListenerPose* lc; lc = new ListenerPose(0, nullptr, nodeName, topic); lc->start(); From 63dcac482203f272829314efa3a27d8fa2405cb0 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Fri, 29 Sep 2017 13:56:03 +0200 Subject: [PATCH 11/14] updated all tools that use comm to support al new changes in it --- .../CMakeLists.txt | 8 +-- .../include/jderobot/comm/cameraClient.hpp | 4 +- .../include/jderobot/comm/communicator.hpp | 4 +- .../jderobot/comm/ice/cameraIceClient.hpp | 8 +-- .../jderobot/comm/ice/laserIceClient.hpp | 6 +- .../jderobot/comm/ice/motorsIceClient.hpp | 6 +- .../jderobot/comm/ice/pose3dIceClient.hpp | 6 +- .../jderobot/comm/interfaces/cameraClient.hpp | 2 +- .../jderobot/comm/interfaces/laserClient.hpp | 2 +- .../jderobot/comm/interfaces/motorsClient.hpp | 2 +- .../jderobot/comm/interfaces/pose3dClient.hpp | 2 +- .../include/jderobot/comm/laserClient.hpp | 4 +- .../include/jderobot/comm/motorsClient.hpp | 4 +- .../include/jderobot/comm/pose3dClient.hpp | 4 +- .../jderobot/comm/ros/listenerCamera.hpp | 4 +- .../jderobot/comm/ros/listenerLaser.hpp | 4 +- .../jderobot/comm/ros/listenerPose.hpp | 4 +- .../jderobot/comm/ros/publisherMotors.hpp | 4 +- .../include/jderobot/comm/ros/translators.hpp | 2 +- .../package.xml | 0 .../src/cameraClient.cpp | 8 +-- .../src/communicator.cpp | 2 +- .../src/ice/cameraIceClient.cpp | 4 +- .../src/ice/laserIceClient.cpp | 4 +- .../src/ice/motorsIceClient.cpp | 4 +- .../src/ice/pose3dIceClient.cpp | 4 +- .../src/laserClient.cpp | 8 +-- .../src/motorsClient.cpp | 8 +-- .../src/pose3dClient.cpp | 8 +-- .../src/ros/listenerCamera.cpp | 4 +- .../src/ros/listenerLaser.cpp | 4 +- .../src/ros/listenerPose.cpp | 4 +- .../src/ros/publisherMotors.cpp | 2 +- .../src/ros/translators.cpp | 2 +- src/libs/config_cpp/CMakeLists.txt | 6 +- .../include/jderobot/config/config.h | 4 +- .../include/jderobot/config/loader.hpp | 2 +- .../config/{class.hpp => properties.hpp} | 0 .../src/{class.cpp => properties.cpp} | 2 +- src/libs/config_py/config/properties.py | 7 +- src/libs/config_py/{ => demo}/demo.py | 1 + src/libs/config_py/{ => demo}/demo.yml | 0 src/libs/jderobotcomm_py/CMakeLists.txt | 8 +-- .../{jderobotComm => comm}/__init__.py | 4 +- .../cameraClient.py.only-ice.in | 10 +-- .../cameraClient.py.ros.in | 10 +-- .../communicator.py.only-ice.in | 9 +-- .../communicator.py.ros.in | 6 +- .../{jderobotComm => comm}/ice/__init__.py | 0 .../ice/cameraIceClient.py | 8 +-- .../ice/laserIceClient.py | 2 +- .../ice/motorsIceClient.py | 2 +- .../ice/pose3dIceClient.py | 2 +- .../ice/threadSensor.py | 0 .../laserClient.py.only-ice.in | 16 ++--- .../laserClient.py.ros.in | 16 ++--- .../motorsClient.py.only-ice.in | 16 ++--- .../motorsClient.py.ros.in | 16 ++--- .../pose3dClient.py.only-ice.in | 16 ++--- .../pose3dClient.py.ros.in | 16 ++--- .../{jderobotComm => comm}/ros/__init__.py | 0 .../ros/listenerCamera.py | 0 .../ros/listenerLaser.py | 0 .../ros/listenerPose3d.py | 0 .../ros/publisherMotors.py | 0 .../ros/threadPublisher.py | 0 src/libs/jderobotcomm_py/test.yml | 66 +++++++++---------- src/libs/jderobotcomm_py/testCamera.py | 6 +- src/libs/jderobotcomm_py/testLaser.py | 8 +-- src/libs/jderobotcomm_py/testMotors.py | 6 +- src/libs/jderobotcomm_py/testPose.py | 6 +- .../basic_component_py/basic_component.py | 11 ++-- src/tools/cameraview/CMakeLists.txt | 6 +- src/tools/cameraview/cameraview.cpp | 6 +- src/tools/kobukiViewer/CMakeLists.txt | 6 +- src/tools/kobukiViewer/gui/gui.cpp | 4 +- src/tools/kobukiViewer/gui/gui.h | 4 +- .../kobukiViewer/gui/threadupdategui.cpp | 4 +- src/tools/kobukiViewer/gui/threadupdategui.h | 4 +- .../kobukiViewer/gui/widget/controlvw.cpp | 9 ++- src/tools/kobukiViewer/gui/widget/controlvw.h | 6 +- src/tools/kobukiViewer/kobukiViewer.cfg | 36 ---------- src/tools/kobukiViewer/kobukiViewer.yml | 38 +++++++++++ src/tools/kobukiViewer/main.cpp | 17 +++-- src/tools/kobukiViewer/robot/actuators.cpp | 6 +- src/tools/kobukiViewer/robot/actuators.h | 7 +- src/tools/kobukiViewer/robot/robot.cpp | 6 +- src/tools/kobukiViewer/robot/robot.h | 4 +- src/tools/kobukiViewer/robot/sensors.cpp | 12 ++-- src/tools/kobukiViewer/robot/sensors.h | 13 ++-- 90 files changed, 318 insertions(+), 298 deletions(-) rename src/libs/{jderobotcomm_cpp => comm_cpp}/CMakeLists.txt (95%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/cameraClient.hpp (92%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/communicator.hpp (95%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ice/cameraIceClient.hpp (89%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ice/laserIceClient.hpp (90%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ice/motorsIceClient.hpp (90%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ice/pose3dIceClient.hpp (90%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/interfaces/cameraClient.hpp (98%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/interfaces/laserClient.hpp (98%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/interfaces/motorsClient.hpp (98%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/interfaces/pose3dClient.hpp (98%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/laserClient.hpp (92%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/motorsClient.hpp (92%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/pose3dClient.hpp (92%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ros/listenerCamera.hpp (95%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ros/listenerLaser.hpp (95%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ros/listenerPose.hpp (95%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ros/publisherMotors.hpp (95%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/include/jderobot/comm/ros/translators.hpp (99%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/package.xml (100%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/cameraClient.cpp (91%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/communicator.cpp (97%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ice/cameraIceClient.cpp (97%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ice/laserIceClient.cpp (97%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ice/motorsIceClient.cpp (95%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ice/pose3dIceClient.cpp (97%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/laserClient.cpp (86%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/motorsClient.cpp (85%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/pose3dClient.cpp (85%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ros/listenerCamera.cpp (94%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ros/listenerLaser.cpp (92%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ros/listenerPose.cpp (93%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ros/publisherMotors.cpp (98%) rename src/libs/{jderobotcomm_cpp => comm_cpp}/src/ros/translators.cpp (99%) rename src/libs/config_cpp/include/jderobot/config/{class.hpp => properties.hpp} (100%) rename src/libs/config_cpp/src/{class.cpp => properties.cpp} (98%) rename src/libs/config_py/{ => demo}/demo.py (93%) rename src/libs/config_py/{ => demo}/demo.yml (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/__init__.py (71%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/cameraClient.py.only-ice.in (88%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/cameraClient.py.ros.in (90%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/communicator.py.only-ice.in (90%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/communicator.py.ros.in (95%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ice/__init__.py (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ice/cameraIceClient.py (96%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ice/laserIceClient.py (98%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ice/motorsIceClient.py (98%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ice/pose3dIceClient.py (99%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ice/threadSensor.py (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/laserClient.py.only-ice.in (81%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/laserClient.py.ros.in (84%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/motorsClient.py.only-ice.in (82%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/motorsClient.py.ros.in (87%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/pose3dClient.py.only-ice.in (81%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/pose3dClient.py.ros.in (84%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ros/__init__.py (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ros/listenerCamera.py (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ros/listenerLaser.py (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ros/listenerPose3d.py (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ros/publisherMotors.py (100%) rename src/libs/jderobotcomm_py/{jderobotComm => comm}/ros/threadPublisher.py (100%) delete mode 100644 src/tools/kobukiViewer/kobukiViewer.cfg create mode 100644 src/tools/kobukiViewer/kobukiViewer.yml diff --git a/src/libs/jderobotcomm_cpp/CMakeLists.txt b/src/libs/comm_cpp/CMakeLists.txt similarity index 95% rename from src/libs/jderobotcomm_cpp/CMakeLists.txt rename to src/libs/comm_cpp/CMakeLists.txt index af9e2a3b0..19b66090c 100644 --- a/src/libs/jderobotcomm_cpp/CMakeLists.txt +++ b/src/libs/comm_cpp/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( ${catkin_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} ${INTERFACES_CPP_DIR} - ${jderobotconfig_INCLUDE_DIRS} + ${config_INCLUDE_DIRS} ) @@ -86,7 +86,7 @@ ENDIF() ## Adding shared library for common usage add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) -add_dependencies(${PROJECT_NAME} ${jderobotconfig_LIBRARIES}) +add_dependencies(${PROJECT_NAME} ${config_LIBRARIES}) target_link_libraries(${PROJECT_NAME} ${ZeroCIce_LIBRARIES} @@ -94,7 +94,7 @@ target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} colorspacesmm ${catkin_LIBRARIES} - ${jderobotconfig_LIBRARIES}) + ${config_LIBRARIES}) ## Adding static library for single .so configurations # since target is a shared library, -fPIC must be provided @@ -107,7 +107,7 @@ target_link_libraries(${PROJECT_NAME}-embedded colorspacesmm JderobotInterfaces ${catkin_LIBRARIES} - ${jderobotconfig_LIBRARIES}) + ${config_LIBRARIES}) set_property(TARGET ${PROJECT_NAME}-embedded PROPERTY POSITION_INDEPENDENT_CODE 1) diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/cameraClient.hpp similarity index 92% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/cameraClient.hpp index 32d9fc5da..e87eea284 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/cameraClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/cameraClient.hpp @@ -29,7 +29,7 @@ -namespace JdeRobotComm { +namespace Comm { /** * @brief make a CameraClient using propierties @@ -41,7 +41,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - CameraClient* getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + CameraClient* getCameraClient(Comm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp b/src/libs/comm_cpp/include/jderobot/comm/communicator.hpp similarity index 95% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp rename to src/libs/comm_cpp/include/jderobot/comm/communicator.hpp index e33659a83..cd1b1a696 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/communicator.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/communicator.hpp @@ -22,10 +22,10 @@ #include #include -#include +#include -namespace JdeRobotComm { +namespace Comm { class Communicator { public: diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp similarity index 89% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp index 769e89cbe..fcca0d2ce 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ice/cameraIceClient.hpp @@ -34,11 +34,11 @@ #include #include -namespace JdeRobotComm { +namespace Comm { -class CameraIceClient: public IceUtil::Thread, public JdeRobotComm::CameraClient { +class CameraIceClient: public IceUtil::Thread, public Comm::CameraClient { public: - CameraIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + CameraIceClient(Comm::Communicator* jdrc, std::string prefix); virtual ~CameraIceClient(); virtual void run(); @@ -71,5 +71,5 @@ class CameraIceClient: public IceUtil::Thread, public JdeRobotComm::CameraClient }; -} /* namespace JdeRobotComm */ +} /* namespace Comm */ #endif /* JDEROBOTCOMM_CAMERAICECLIENT_H_ */ \ No newline at end of file diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/laserIceClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/ice/laserIceClient.hpp similarity index 90% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/laserIceClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ice/laserIceClient.hpp index 537f5c0e6..0198f5e73 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/laserIceClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ice/laserIceClient.hpp @@ -34,12 +34,12 @@ #include #include -namespace JdeRobotComm { +namespace Comm { -class LaserIceClient: public IceUtil::Thread, public JdeRobotComm::LaserClient { +class LaserIceClient: public IceUtil::Thread, public Comm::LaserClient { public: - LaserIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + LaserIceClient(Comm::Communicator* jdrc, std::string prefix); virtual ~LaserIceClient(); virtual void run(); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp similarity index 90% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp index 71b8647a6..c8bbc96e7 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ice/motorsIceClient.hpp @@ -28,12 +28,12 @@ #include #include -namespace JdeRobotComm { +namespace Comm { -class MotorsIceClient: public JdeRobotComm::MotorsClient { +class MotorsIceClient: public Comm::MotorsClient { public: - MotorsIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + MotorsIceClient(Comm::Communicator* jdrc, std::string prefix); virtual ~MotorsIceClient(); virtual void sendVelocities(JdeRobotTypes::CMDVel vel); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp similarity index 90% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp index 510bd9a88..e3ac48073 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ice/pose3dIceClient.hpp @@ -31,12 +31,12 @@ #include #include -namespace JdeRobotComm { +namespace Comm { -class Pose3dIceClient: public IceUtil::Thread, public JdeRobotComm::Pose3dClient { +class Pose3dIceClient: public IceUtil::Thread, public Comm::Pose3dClient { public: - Pose3dIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + Pose3dIceClient(Comm::Communicator* jdrc, std::string prefix); virtual ~Pose3dIceClient(); virtual void run(); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/cameraClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/interfaces/cameraClient.hpp similarity index 98% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/cameraClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/interfaces/cameraClient.hpp index 3f952ad1e..b4d8f3277 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/cameraClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/interfaces/cameraClient.hpp @@ -23,7 +23,7 @@ #include -namespace JdeRobotComm { +namespace Comm { /** * @brief LaserClient class. diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/laserClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/interfaces/laserClient.hpp similarity index 98% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/laserClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/interfaces/laserClient.hpp index 49b95ef58..117abf626 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/laserClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/interfaces/laserClient.hpp @@ -23,7 +23,7 @@ #include -namespace JdeRobotComm { +namespace Comm { /** * @brief LaserClient class. diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/motorsClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/interfaces/motorsClient.hpp similarity index 98% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/motorsClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/interfaces/motorsClient.hpp index d65b32d6c..f6b79f6ac 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/motorsClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/interfaces/motorsClient.hpp @@ -23,7 +23,7 @@ #include -namespace JdeRobotComm { +namespace Comm { /** * @brief MotorsClient class. diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/pose3dClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/interfaces/pose3dClient.hpp similarity index 98% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/pose3dClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/interfaces/pose3dClient.hpp index de85cbe66..bd71c46a9 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/interfaces/pose3dClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/interfaces/pose3dClient.hpp @@ -23,7 +23,7 @@ #include -namespace JdeRobotComm { +namespace Comm { /** * @brief Pose3dClient class. diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/laserClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/laserClient.hpp similarity index 92% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/laserClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/laserClient.hpp index 0844c1875..c1d8c435d 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/laserClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/laserClient.hpp @@ -28,7 +28,7 @@ -namespace JdeRobotComm { +namespace Comm { /** * @brief make a LaserClient using propierties @@ -40,7 +40,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - LaserClient* getLaserClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + LaserClient* getLaserClient(Comm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/motorsClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/motorsClient.hpp similarity index 92% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/motorsClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/motorsClient.hpp index 7e1a3b3db..40ccb5f0c 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/motorsClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/motorsClient.hpp @@ -29,7 +29,7 @@ -namespace JdeRobotComm { +namespace Comm { /** * @brief make a MotorsClient using propierties @@ -41,7 +41,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - MotorsClient* getMotorsClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + MotorsClient* getMotorsClient(Comm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/pose3dClient.hpp b/src/libs/comm_cpp/include/jderobot/comm/pose3dClient.hpp similarity index 92% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/pose3dClient.hpp rename to src/libs/comm_cpp/include/jderobot/comm/pose3dClient.hpp index 90e7c7ded..2569d4cbb 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/pose3dClient.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/pose3dClient.hpp @@ -29,7 +29,7 @@ -namespace JdeRobotComm { +namespace Comm { /** * @brief make a Pose3dClient using propierties @@ -41,7 +41,7 @@ namespace JdeRobotComm { * * @return null if propierties are wrong */ - Pose3dClient* getPose3dClient(JdeRobotComm::Communicator* jdrc, std::string prefix); + Pose3dClient* getPose3dClient(Comm::Communicator* jdrc, std::string prefix); } //NS diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerCamera.hpp b/src/libs/comm_cpp/include/jderobot/comm/ros/listenerCamera.hpp similarity index 95% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerCamera.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ros/listenerCamera.hpp index 6e7169eb0..2134eb86c 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerCamera.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ros/listenerCamera.hpp @@ -30,8 +30,8 @@ #include #include -namespace JdeRobotComm { - class ListenerCamera: public JdeRobotComm::CameraClient { +namespace Comm { + class ListenerCamera: public Comm::CameraClient { public: ListenerCamera(int argc, char** argv, std::string nodeName, std::string topic); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerLaser.hpp b/src/libs/comm_cpp/include/jderobot/comm/ros/listenerLaser.hpp similarity index 95% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerLaser.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ros/listenerLaser.hpp index 16b95f862..336b753ad 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerLaser.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ros/listenerLaser.hpp @@ -28,8 +28,8 @@ #include #include -namespace JdeRobotComm { - class ListenerLaser: public JdeRobotComm::LaserClient { +namespace Comm { + class ListenerLaser: public Comm::LaserClient { public: ListenerLaser(int argc, char** argv, std::string nodeName, std::string topic); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerPose.hpp b/src/libs/comm_cpp/include/jderobot/comm/ros/listenerPose.hpp similarity index 95% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerPose.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ros/listenerPose.hpp index b6550d65a..5f5b5eb60 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/listenerPose.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ros/listenerPose.hpp @@ -28,8 +28,8 @@ #include #include -namespace JdeRobotComm { - class ListenerPose: public JdeRobotComm::Pose3dClient { +namespace Comm { + class ListenerPose: public Comm::Pose3dClient { public: ListenerPose(int argc, char** argv, std::string nodeName, std::string topic); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/publisherMotors.hpp b/src/libs/comm_cpp/include/jderobot/comm/ros/publisherMotors.hpp similarity index 95% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/publisherMotors.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ros/publisherMotors.hpp index 5a96655b5..674216e3d 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/publisherMotors.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ros/publisherMotors.hpp @@ -28,8 +28,8 @@ #include #include -namespace JdeRobotComm { - class PublisherMotors: public JdeRobotComm::MotorsClient { +namespace Comm { + class PublisherMotors: public Comm::MotorsClient { public: PublisherMotors(int argc, char** argv, std::string nodeName, std::string topic); diff --git a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/translators.hpp b/src/libs/comm_cpp/include/jderobot/comm/ros/translators.hpp similarity index 99% rename from src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/translators.hpp rename to src/libs/comm_cpp/include/jderobot/comm/ros/translators.hpp index 9241916a0..d8ee4e21a 100644 --- a/src/libs/jderobotcomm_cpp/include/jderobot/comm/ros/translators.hpp +++ b/src/libs/comm_cpp/include/jderobot/comm/ros/translators.hpp @@ -42,7 +42,7 @@ #include -namespace JdeRobotComm { +namespace Comm { /** * @brief translate ROS LaserScan messages to JdeRobot LaserData diff --git a/src/libs/jderobotcomm_cpp/package.xml b/src/libs/comm_cpp/package.xml similarity index 100% rename from src/libs/jderobotcomm_cpp/package.xml rename to src/libs/comm_cpp/package.xml diff --git a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp b/src/libs/comm_cpp/src/cameraClient.cpp similarity index 91% rename from src/libs/jderobotcomm_cpp/src/cameraClient.cpp rename to src/libs/comm_cpp/src/cameraClient.cpp index 27054d7dc..f52c57de8 100644 --- a/src/libs/jderobotcomm_cpp/src/cameraClient.cpp +++ b/src/libs/comm_cpp/src/cameraClient.cpp @@ -22,10 +22,10 @@ #include #endif -namespace JdeRobotComm { +namespace Comm { CameraClient* -getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ +getCameraClient(Comm::Communicator* jdrc, std::string prefix){ CameraClient* client = 0; @@ -42,7 +42,7 @@ getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ CameraIceClient* cl; cl = new CameraIceClient(jdrc, prefix); cl->start(); - client = (JdeRobotComm::CameraClient*) cl; + client = (Comm::CameraClient*) cl; break; } case 2: @@ -56,7 +56,7 @@ getCameraClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ ListenerCamera* lc; lc = new ListenerCamera(0, nullptr, nodeName, topic); lc->start(); - client = (JdeRobotComm::CameraClient*) lc; + client = (Comm::CameraClient*) lc; #else throw "ERROR: ROS is not available"; #endif diff --git a/src/libs/jderobotcomm_cpp/src/communicator.cpp b/src/libs/comm_cpp/src/communicator.cpp similarity index 97% rename from src/libs/jderobotcomm_cpp/src/communicator.cpp rename to src/libs/comm_cpp/src/communicator.cpp index 5ff40aa21..6e0a28898 100644 --- a/src/libs/jderobotcomm_cpp/src/communicator.cpp +++ b/src/libs/comm_cpp/src/communicator.cpp @@ -18,7 +18,7 @@ */ #include -namespace JdeRobotComm { +namespace Comm { Communicator::Communicator(Config::Properties config){ this->config = config; diff --git a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp b/src/libs/comm_cpp/src/ice/cameraIceClient.cpp similarity index 97% rename from src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp rename to src/libs/comm_cpp/src/ice/cameraIceClient.cpp index 37c206890..452aa58b7 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/cameraIceClient.cpp +++ b/src/libs/comm_cpp/src/ice/cameraIceClient.cpp @@ -24,10 +24,10 @@ #include -namespace JdeRobotComm { +namespace Comm { -CameraIceClient::CameraIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { +CameraIceClient::CameraIceClient(Comm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; Ice::ObjectPrx baseCamera; diff --git a/src/libs/jderobotcomm_cpp/src/ice/laserIceClient.cpp b/src/libs/comm_cpp/src/ice/laserIceClient.cpp similarity index 97% rename from src/libs/jderobotcomm_cpp/src/ice/laserIceClient.cpp rename to src/libs/comm_cpp/src/ice/laserIceClient.cpp index 3334328ec..918e8b694 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/laserIceClient.cpp +++ b/src/libs/comm_cpp/src/ice/laserIceClient.cpp @@ -20,9 +20,9 @@ */ #include "jderobot/comm/ice/laserIceClient.hpp" -namespace JdeRobotComm { +namespace Comm { -LaserIceClient::LaserIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { +LaserIceClient::LaserIceClient(Comm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; diff --git a/src/libs/jderobotcomm_cpp/src/ice/motorsIceClient.cpp b/src/libs/comm_cpp/src/ice/motorsIceClient.cpp similarity index 95% rename from src/libs/jderobotcomm_cpp/src/ice/motorsIceClient.cpp rename to src/libs/comm_cpp/src/ice/motorsIceClient.cpp index bb050670c..bad3806d3 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/motorsIceClient.cpp +++ b/src/libs/comm_cpp/src/ice/motorsIceClient.cpp @@ -19,9 +19,9 @@ #include "jderobot/comm/ice/motorsIceClient.hpp" -namespace JdeRobotComm { +namespace Comm { -MotorsIceClient::MotorsIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { +MotorsIceClient::MotorsIceClient(Comm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; diff --git a/src/libs/jderobotcomm_cpp/src/ice/pose3dIceClient.cpp b/src/libs/comm_cpp/src/ice/pose3dIceClient.cpp similarity index 97% rename from src/libs/jderobotcomm_cpp/src/ice/pose3dIceClient.cpp rename to src/libs/comm_cpp/src/ice/pose3dIceClient.cpp index ed4867caf..6e7e1ce4c 100644 --- a/src/libs/jderobotcomm_cpp/src/ice/pose3dIceClient.cpp +++ b/src/libs/comm_cpp/src/ice/pose3dIceClient.cpp @@ -19,9 +19,9 @@ #include "jderobot/comm/ice/pose3dIceClient.hpp" -namespace JdeRobotComm { +namespace Comm { -Pose3dIceClient::Pose3dIceClient(JdeRobotComm::Communicator* jdrc, std::string prefix) { +Pose3dIceClient::Pose3dIceClient(Comm::Communicator* jdrc, std::string prefix) { this->prefix=prefix; diff --git a/src/libs/jderobotcomm_cpp/src/laserClient.cpp b/src/libs/comm_cpp/src/laserClient.cpp similarity index 86% rename from src/libs/jderobotcomm_cpp/src/laserClient.cpp rename to src/libs/comm_cpp/src/laserClient.cpp index 5d13b1c86..71de12e20 100644 --- a/src/libs/jderobotcomm_cpp/src/laserClient.cpp +++ b/src/libs/comm_cpp/src/laserClient.cpp @@ -4,10 +4,10 @@ #include #endif -namespace JdeRobotComm { +namespace Comm { LaserClient* -getLaserClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ +getLaserClient(Comm::Communicator* jdrc, std::string prefix){ LaserClient* client = 0; int server = jdrc->getConfig().asIntWithDefault(prefix+".Server", 0); @@ -23,7 +23,7 @@ getLaserClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ LaserIceClient* cl; cl = new LaserIceClient(jdrc, prefix); cl->start(); - client = (JdeRobotComm::LaserClient*) cl; + client = (Comm::LaserClient*) cl; break; } case 2: @@ -37,7 +37,7 @@ getLaserClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ ListenerLaser* lc; lc = new ListenerLaser(0, nullptr, nodeName, topic); lc->start(); - client = (JdeRobotComm::LaserClient*) lc; + client = (Comm::LaserClient*) lc; #else throw "ERROR: ROS is not available"; #endif diff --git a/src/libs/jderobotcomm_cpp/src/motorsClient.cpp b/src/libs/comm_cpp/src/motorsClient.cpp similarity index 85% rename from src/libs/jderobotcomm_cpp/src/motorsClient.cpp rename to src/libs/comm_cpp/src/motorsClient.cpp index 4f0aeb076..8fc10f160 100644 --- a/src/libs/jderobotcomm_cpp/src/motorsClient.cpp +++ b/src/libs/comm_cpp/src/motorsClient.cpp @@ -4,10 +4,10 @@ #include #endif -namespace JdeRobotComm { +namespace Comm { MotorsClient* -getMotorsClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ +getMotorsClient(Comm::Communicator* jdrc, std::string prefix){ MotorsClient* client = 0; @@ -23,7 +23,7 @@ getMotorsClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ std::cout << "Sending Velocities by ICE interfaces" << std::endl; MotorsIceClient* cl; cl = new MotorsIceClient(jdrc, prefix); - client = (JdeRobotComm::MotorsClient*) cl; + client = (Comm::MotorsClient*) cl; break; } case 2: @@ -37,7 +37,7 @@ getMotorsClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ PublisherMotors* pm; pm = new PublisherMotors(0, nullptr, nodeName, topic); pm->start(); - client = (JdeRobotComm::MotorsClient*) pm; + client = (Comm::MotorsClient*) pm; #else throw "ERROR: ROS is not available"; #endif diff --git a/src/libs/jderobotcomm_cpp/src/pose3dClient.cpp b/src/libs/comm_cpp/src/pose3dClient.cpp similarity index 85% rename from src/libs/jderobotcomm_cpp/src/pose3dClient.cpp rename to src/libs/comm_cpp/src/pose3dClient.cpp index 5aa2d172c..80c8d2f9b 100644 --- a/src/libs/jderobotcomm_cpp/src/pose3dClient.cpp +++ b/src/libs/comm_cpp/src/pose3dClient.cpp @@ -4,10 +4,10 @@ #include #endif -namespace JdeRobotComm { +namespace Comm { Pose3dClient* -getPose3dClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ +getPose3dClient(Comm::Communicator* jdrc, std::string prefix){ Pose3dClient* client = 0; @@ -24,7 +24,7 @@ getPose3dClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ Pose3dIceClient* cl; cl = new Pose3dIceClient(jdrc, prefix); cl->start(); - client = (JdeRobotComm::Pose3dClient*) cl; + client = (Comm::Pose3dClient*) cl; break; } case 2: @@ -38,7 +38,7 @@ getPose3dClient(JdeRobotComm::Communicator* jdrc, std::string prefix){ ListenerPose* lc; lc = new ListenerPose(0, nullptr, nodeName, topic); lc->start(); - client = (JdeRobotComm::Pose3dClient*) lc; + client = (Comm::Pose3dClient*) lc; #else throw "ERROR: ROS is not available"; #endif diff --git a/src/libs/jderobotcomm_cpp/src/ros/listenerCamera.cpp b/src/libs/comm_cpp/src/ros/listenerCamera.cpp similarity index 94% rename from src/libs/jderobotcomm_cpp/src/ros/listenerCamera.cpp rename to src/libs/comm_cpp/src/ros/listenerCamera.cpp index 2003a4e95..e62fd8932 100644 --- a/src/libs/jderobotcomm_cpp/src/ros/listenerCamera.cpp +++ b/src/libs/comm_cpp/src/ros/listenerCamera.cpp @@ -1,6 +1,6 @@ #include -namespace JdeRobotComm { +namespace Comm { ListenerCamera::ListenerCamera(int argc, char** argv, std::string nodeName, std::string topic){ pthread_mutex_init(&mutex, NULL); @@ -48,7 +48,7 @@ namespace JdeRobotComm { time_t now; time(&now); pthread_mutex_lock(&mutex); - this->image = JdeRobotComm::translate_image_messages(image_msg); + this->image = Comm::translate_image_messages(image_msg); if (difftime(this->timer, now)>=1){ this->refreshRate = this->cont; this->cont = 0; diff --git a/src/libs/jderobotcomm_cpp/src/ros/listenerLaser.cpp b/src/libs/comm_cpp/src/ros/listenerLaser.cpp similarity index 92% rename from src/libs/jderobotcomm_cpp/src/ros/listenerLaser.cpp rename to src/libs/comm_cpp/src/ros/listenerLaser.cpp index ade23f6c8..89fb659ad 100644 --- a/src/libs/jderobotcomm_cpp/src/ros/listenerLaser.cpp +++ b/src/libs/comm_cpp/src/ros/listenerLaser.cpp @@ -1,6 +1,6 @@ #include -namespace JdeRobotComm { +namespace Comm { ListenerLaser::ListenerLaser(int argc, char** argv, std::string nodeName, std::string topic){ pthread_mutex_init(&mutex, NULL); @@ -46,7 +46,7 @@ namespace JdeRobotComm { void ListenerLaser::lasercallback(const sensor_msgs::LaserScanConstPtr& laser_msg){ pthread_mutex_lock(&mutex); - this->laserData = JdeRobotComm::translate_laser_messages(laser_msg); + this->laserData = Comm::translate_laser_messages(laser_msg); pthread_mutex_unlock(&mutex); } diff --git a/src/libs/jderobotcomm_cpp/src/ros/listenerPose.cpp b/src/libs/comm_cpp/src/ros/listenerPose.cpp similarity index 93% rename from src/libs/jderobotcomm_cpp/src/ros/listenerPose.cpp rename to src/libs/comm_cpp/src/ros/listenerPose.cpp index cce00926b..fb79341cb 100644 --- a/src/libs/jderobotcomm_cpp/src/ros/listenerPose.cpp +++ b/src/libs/comm_cpp/src/ros/listenerPose.cpp @@ -1,6 +1,6 @@ #include -namespace JdeRobotComm { +namespace Comm { ListenerPose::ListenerPose(int argc, char** argv, std::string nodeName, std::string topic){ pthread_mutex_init(&mutex, NULL); @@ -45,7 +45,7 @@ namespace JdeRobotComm { void ListenerPose::posecallback(const nav_msgs::OdometryConstPtr& odom_msg){ pthread_mutex_lock(&mutex); - this->pose = JdeRobotComm::translate_odometry_messages(odom_msg); + this->pose = Comm::translate_odometry_messages(odom_msg); pthread_mutex_unlock(&mutex); } diff --git a/src/libs/jderobotcomm_cpp/src/ros/publisherMotors.cpp b/src/libs/comm_cpp/src/ros/publisherMotors.cpp similarity index 98% rename from src/libs/jderobotcomm_cpp/src/ros/publisherMotors.cpp rename to src/libs/comm_cpp/src/ros/publisherMotors.cpp index 103e5cf75..a117ad558 100644 --- a/src/libs/jderobotcomm_cpp/src/ros/publisherMotors.cpp +++ b/src/libs/comm_cpp/src/ros/publisherMotors.cpp @@ -1,6 +1,6 @@ #include -namespace JdeRobotComm { +namespace Comm { PublisherMotors::PublisherMotors(int argc, char** argv, std::string nodeName, std::string topic){ pthread_mutex_init(&mutex, NULL); diff --git a/src/libs/jderobotcomm_cpp/src/ros/translators.cpp b/src/libs/comm_cpp/src/ros/translators.cpp similarity index 99% rename from src/libs/jderobotcomm_cpp/src/ros/translators.cpp rename to src/libs/comm_cpp/src/ros/translators.cpp index ef8402879..04043fa21 100644 --- a/src/libs/jderobotcomm_cpp/src/ros/translators.cpp +++ b/src/libs/comm_cpp/src/ros/translators.cpp @@ -1,5 +1,5 @@ #include "jderobot/comm/ros/translators.hpp" -namespace JdeRobotComm { +namespace Comm { float PI = 3.1415; diff --git a/src/libs/config_cpp/CMakeLists.txt b/src/libs/config_cpp/CMakeLists.txt index d7bb528a0..df0dd15e7 100644 --- a/src/libs/config_cpp/CMakeLists.txt +++ b/src/libs/config_cpp/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -project(jderobotconfig) +project(config) ### Project config include_directories( @@ -17,13 +17,13 @@ set(HEADERS include/jderobot/config/config.h ${CMAKE_CURRENT_BINARY_DIR}/include/jderobot/config/hardcodedlocations.h include/jderobot/config/loader.hpp - include/jderobot/config/class.hpp + include/jderobot/config/properties.hpp include/jderobot/config/stdutils.hpp ) set(SOURCES src/loader.cpp - src/class.cpp + src/properties.cpp ) diff --git a/src/libs/config_cpp/include/jderobot/config/config.h b/src/libs/config_cpp/include/jderobot/config/config.h index 8ebbc5759..ab9bec257 100644 --- a/src/libs/config_cpp/include/jderobot/config/config.h +++ b/src/libs/config_cpp/include/jderobot/config/config.h @@ -31,7 +31,7 @@ #include #include -#include +#include namespace Config{ @@ -43,7 +43,7 @@ namespace Config{ * @param filename * * - * @return config class with all propierties + * @return config class with all properties */ inline Config::Properties load(int argc, char* argv[]) diff --git a/src/libs/config_cpp/include/jderobot/config/loader.hpp b/src/libs/config_cpp/include/jderobot/config/loader.hpp index f44a519bc..825f98930 100644 --- a/src/libs/config_cpp/include/jderobot/config/loader.hpp +++ b/src/libs/config_cpp/include/jderobot/config/loader.hpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace jderobotconfig { diff --git a/src/libs/config_cpp/include/jderobot/config/class.hpp b/src/libs/config_cpp/include/jderobot/config/properties.hpp similarity index 100% rename from src/libs/config_cpp/include/jderobot/config/class.hpp rename to src/libs/config_cpp/include/jderobot/config/properties.hpp diff --git a/src/libs/config_cpp/src/class.cpp b/src/libs/config_cpp/src/properties.cpp similarity index 98% rename from src/libs/config_cpp/src/class.cpp rename to src/libs/config_cpp/src/properties.cpp index 0234d562f..336592517 100644 --- a/src/libs/config_cpp/src/class.cpp +++ b/src/libs/config_cpp/src/properties.cpp @@ -17,7 +17,7 @@ * Aitor Martinez Fernandez */ -#include "jderobot/config/class.hpp" +#include "jderobot/config/properties.hpp" namespace Config{ diff --git a/src/libs/config_py/config/properties.py b/src/libs/config_py/config/properties.py index 4fd69549c..dc7bfe28b 100644 --- a/src/libs/config_py/config/properties.py +++ b/src/libs/config_py/config/properties.py @@ -34,7 +34,12 @@ def getProperty(self, name): return self._searchNode(self._config, names) def getPropertyWithDefault(self, name, dataDefault): - return dataDefault + + try: + return self.getProperty(name) + + except KeyError: + return dataDefault def _searchNode(self, node, lst): diff --git a/src/libs/config_py/demo.py b/src/libs/config_py/demo/demo.py similarity index 93% rename from src/libs/config_py/demo.py rename to src/libs/config_py/demo/demo.py index f0e35309b..a0700ac91 100644 --- a/src/libs/config_py/demo.py +++ b/src/libs/config_py/demo/demo.py @@ -25,5 +25,6 @@ cfg = config.load(sys.argv[1]) print (cfg.getProperty("Demo.Motors.Server")) +print (cfg.getPropertyWithDefault("Demo.Motors.Server2", "Server2")) print cfg diff --git a/src/libs/config_py/demo.yml b/src/libs/config_py/demo/demo.yml similarity index 100% rename from src/libs/config_py/demo.yml rename to src/libs/config_py/demo/demo.yml diff --git a/src/libs/jderobotcomm_py/CMakeLists.txt b/src/libs/jderobotcomm_py/CMakeLists.txt index 239b10b49..37e183486 100644 --- a/src/libs/jderobotcomm_py/CMakeLists.txt +++ b/src/libs/jderobotcomm_py/CMakeLists.txt @@ -3,12 +3,12 @@ cmake_minimum_required(VERSION 2.8) #macro configure files macro(configure_jderobotcomm_py in) - file(GLOB_RECURSE files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/jderobotComm/ *.${in}) + file(GLOB_RECURSE files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/comm/ *.${in}) foreach(file ${files}) string(REGEX REPLACE "\\.${in}$" "" f "${file}") - configure_file_python(jderobotComm/${file} jderobotComm/${f}) + configure_file_python(comm/${file} comm/${f}) endforeach(file ${files}) @@ -21,6 +21,6 @@ ELSE() endif() add_custom_target(jderobotcomm_py ALL) -copy_to_binary_python(jderobotcomm_py jderobotComm) +copy_to_binary_python(jderobotcomm_py comm) -install_python(jderobotComm core) \ No newline at end of file +install_python(comm core) \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/jderobotComm/__init__.py b/src/libs/jderobotcomm_py/comm/__init__.py similarity index 71% rename from src/libs/jderobotcomm_py/jderobotComm/__init__.py rename to src/libs/jderobotcomm_py/comm/__init__.py index 5f38f420f..f14587b65 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/__init__.py +++ b/src/libs/jderobotcomm_py/comm/__init__.py @@ -3,7 +3,7 @@ -def init (config): +def init (config, prefix): ''' Starts JdeRobotComm @@ -11,7 +11,7 @@ def init (config): @type config: dict ''' - return Communicator(config) + return Communicator(config, prefix) diff --git a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in b/src/libs/jderobotcomm_py/comm/cameraClient.py.only-ice.in similarity index 88% rename from src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in rename to src/libs/jderobotcomm_py/comm/cameraClient.py.only-ice.in index a38e943a6..62e6c3950 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/comm/cameraClient.py.only-ice.in @@ -6,7 +6,7 @@ def __getCameraIceClient(jdrc, prefix): ''' Returns a Camera Ice Client. This function should never be used. Use getCameraClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file @type ic: Ice Communicator @@ -24,7 +24,7 @@ def __getListenerCamera(jdrc, prefix): ''' Returns a Camera ROS Subscriber. This function should never be used. Use getCameraClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file @type ic: Ice Communicator @@ -41,7 +41,7 @@ def __Cameradisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getCameraClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file @type ic: Ice Communicator @@ -57,10 +57,10 @@ def getCameraClient (jdrc, prefix): ''' Returns a Camera Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type name: String @return None if Camera is disabled diff --git a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in b/src/libs/jderobotcomm_py/comm/cameraClient.py.ros.in similarity index 90% rename from src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in rename to src/libs/jderobotcomm_py/comm/cameraClient.py.ros.in index 344af98dc..4d8f913d8 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/cameraClient.py.ros.in +++ b/src/libs/jderobotcomm_py/comm/cameraClient.py.ros.in @@ -10,7 +10,7 @@ def __getCameraIceClient(jdrc, prefix): ''' Returns a Camera Ice Client. This function should never be used. Use getCameraClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file @type ic: Ice Communicator @@ -28,7 +28,7 @@ def __getListenerCamera(jdrc, prefix): ''' Returns a Camera ROS Subscriber. This function should never be used. Use getCameraClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file @type ic: Ice Communicator @@ -50,7 +50,7 @@ def __Cameradisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getCameraClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file @type ic: Ice Communicator @@ -66,10 +66,10 @@ def getCameraClient (jdrc, prefix): ''' Returns a Camera Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type name: String @return None if Camera is disabled diff --git a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in b/src/libs/jderobotcomm_py/comm/communicator.py.only-ice.in similarity index 90% rename from src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in rename to src/libs/jderobotcomm_py/comm/communicator.py.only-ice.in index c24623ce9..6158edf2e 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.only-ice.in +++ b/src/libs/jderobotcomm_py/comm/communicator.py.only-ice.in @@ -8,10 +8,10 @@ from .motorsClient import getMotorsClient class Communicator: ''' - JdeRobotComm Communicator class + Comm Communicator class ''' - def __init__ (self, config): + def __init__ (self, config, prefix): ''' Communicator constructor @@ -27,8 +27,9 @@ class Communicator: self.__ic = None self.config = config - for i in self.config: - if type(self.config[i]) is dict and self.config[i]["Server"] == 1: + ymlNode = self.config.getProperty(prefix) + for i in ymlNode: + if type(ymlNode[i]) is dict and ymlNode[i]["Server"] == 1: iceserver = True if iceserver: diff --git a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in b/src/libs/jderobotcomm_py/comm/communicator.py.ros.in similarity index 95% rename from src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in rename to src/libs/jderobotcomm_py/comm/communicator.py.ros.in index d07bae1f7..53a65dd03 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/communicator.py.ros.in +++ b/src/libs/jderobotcomm_py/comm/communicator.py.ros.in @@ -9,10 +9,10 @@ from .motorsClient import getMotorsClient class Communicator: ''' - JdeRobotComm Communicator class + Comm Communicator class ''' - def __init__ (self, config): + def __init__ (self, config, prefix): ''' Communicator constructor @@ -28,7 +28,7 @@ class Communicator: self.__ic = None self.config = config - ymlNode = self.config.getNode() + ymlNode = self.config.getProperty(prefix) for i in ymlNode: if type(ymlNode[i]) is dict and ymlNode[i]["Server"] == 1: iceserver = True diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/__init__.py b/src/libs/jderobotcomm_py/comm/ice/__init__.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ice/__init__.py rename to src/libs/jderobotcomm_py/comm/ice/__init__.py diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py b/src/libs/jderobotcomm_py/comm/ice/cameraIceClient.py similarity index 96% rename from src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py rename to src/libs/jderobotcomm_py/comm/ice/cameraIceClient.py index a6dfe89f9..15a7f61e4 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/cameraIceClient.py +++ b/src/libs/jderobotcomm_py/comm/ice/cameraIceClient.py @@ -36,10 +36,10 @@ def __init__(self, jdrc, prefix): Camera Contructor. Exits When it receives a Exception diferent to Ice.ConnectionRefusedException - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String ''' @@ -123,11 +123,11 @@ def __init__(self,jdrc,prefix, start = False): ''' CameraIceClient Contructor. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file @param start: indicates if start automatically the client - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @type start: Boolean ''' diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/laserIceClient.py b/src/libs/jderobotcomm_py/comm/ice/laserIceClient.py similarity index 98% rename from src/libs/jderobotcomm_py/jderobotComm/ice/laserIceClient.py rename to src/libs/jderobotcomm_py/comm/ice/laserIceClient.py index d6a8bcc44..0b7013531 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/laserIceClient.py +++ b/src/libs/jderobotcomm_py/comm/ice/laserIceClient.py @@ -35,7 +35,7 @@ def __init__(self, jdrc, prefix): Laser Contructor. Exits When it receives a Exception diferent to Ice.ConnectionRefusedException - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: prefix name of client in config file @type ic: Ice Communicator diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/motorsIceClient.py b/src/libs/jderobotcomm_py/comm/ice/motorsIceClient.py similarity index 98% rename from src/libs/jderobotcomm_py/jderobotComm/ice/motorsIceClient.py rename to src/libs/jderobotcomm_py/comm/ice/motorsIceClient.py index 6a59c9494..f2ba33eb2 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/motorsIceClient.py +++ b/src/libs/jderobotcomm_py/comm/ice/motorsIceClient.py @@ -32,7 +32,7 @@ class MotorsIceClient: Motors Contructor. Exits When it receives a Exception diferent to Ice.ConnectionRefusedException - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: prefix name of client in config file @type ic: Ice Communicator diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/pose3dIceClient.py b/src/libs/jderobotcomm_py/comm/ice/pose3dIceClient.py similarity index 99% rename from src/libs/jderobotcomm_py/jderobotComm/ice/pose3dIceClient.py rename to src/libs/jderobotcomm_py/comm/ice/pose3dIceClient.py index 851bc3a73..256dc20c4 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/ice/pose3dIceClient.py +++ b/src/libs/jderobotcomm_py/comm/ice/pose3dIceClient.py @@ -36,7 +36,7 @@ def __init__(self, jdrc, prefix): Pose3d Contructor. Exits When it receives a Exception diferent to Ice.ConnectionRefusedException - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: prefix name of client in config file @type ic: Ice Communicator diff --git a/src/libs/jderobotcomm_py/jderobotComm/ice/threadSensor.py b/src/libs/jderobotcomm_py/comm/ice/threadSensor.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ice/threadSensor.py rename to src/libs/jderobotcomm_py/comm/ice/threadSensor.py diff --git a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in b/src/libs/jderobotcomm_py/comm/laserClient.py.only-ice.in similarity index 81% rename from src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in rename to src/libs/jderobotcomm_py/comm/laserClient.py.only-ice.in index 48d3ee01a..4769be465 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/comm/laserClient.py.only-ice.in @@ -7,10 +7,10 @@ def __getLaserIceClient(jdrc, prefix): ''' Returns a Laser Ice Client. This function should never be used. Use getLaserClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Laser Ice Client @@ -25,10 +25,10 @@ def __getListenerLaser(jdrc, prefix): ''' Returns a Laser ROS Subscriber. This function should never be used. Use getLaserClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Laser ROS Subscriber @@ -41,10 +41,10 @@ def __Laserdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getLaserClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None @@ -57,10 +57,10 @@ def getLaserClient (jdrc, prefix): ''' Returns a Laser Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param name: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type name: String @return None if Laser is disabled diff --git a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in b/src/libs/jderobotcomm_py/comm/laserClient.py.ros.in similarity index 84% rename from src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in rename to src/libs/jderobotcomm_py/comm/laserClient.py.ros.in index 97bbce83a..c6145f208 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/laserClient.py.ros.in +++ b/src/libs/jderobotcomm_py/comm/laserClient.py.ros.in @@ -10,10 +10,10 @@ def __getLaserIceClient(jdrc, prefix): ''' Returns a Laser Ice Client. This function should never be used. Use getLaserClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Laser Ice Client @@ -28,10 +28,10 @@ def __getListenerLaser(jdrc, prefix): ''' Returns a Laser ROS Subscriber. This function should never be used. Use getLaserClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Laser ROS Subscriber @@ -50,10 +50,10 @@ def __Laserdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getLaserClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None @@ -66,10 +66,10 @@ def getLaserClient (jdrc, prefix): ''' Returns a Laser Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type name: String @return None if Laser is disabled diff --git a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in b/src/libs/jderobotcomm_py/comm/motorsClient.py.only-ice.in similarity index 82% rename from src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in rename to src/libs/jderobotcomm_py/comm/motorsClient.py.only-ice.in index 0dc6bb816..e27632584 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/comm/motorsClient.py.only-ice.in @@ -8,10 +8,10 @@ def __getMotorsIceClient(jdrc, prefix): ''' Returns a Motors Ice Client. This function should never be used. Use getMotorsClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Motors Ice Client @@ -26,10 +26,10 @@ def __getPublisherMotors(jdrc, prefix): ''' Returns a Motors ROS Publisher. This function should never be used. Use getMotorsClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Motors ROS Publisher @@ -43,10 +43,10 @@ def __Motorsdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getMotorsClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None @@ -59,11 +59,11 @@ def getMotorsClient (jdrc, prefix): ''' Returns a Motors Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file @param node: ROS node - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @type node: ROS node diff --git a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in b/src/libs/jderobotcomm_py/comm/motorsClient.py.ros.in similarity index 87% rename from src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in rename to src/libs/jderobotcomm_py/comm/motorsClient.py.ros.in index c48d2922d..58859a2bd 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/motorsClient.py.ros.in +++ b/src/libs/jderobotcomm_py/comm/motorsClient.py.ros.in @@ -10,10 +10,10 @@ def __getMotorsIceClient(jdrc, prefix): ''' Returns a Motors Ice Client. This function should never be used. Use getMotorsClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Motors Ice Client @@ -28,10 +28,10 @@ def __getPublisherMotors(jdrc, prefix): ''' Returns a Motors ROS Publisher. This function should never be used. Use getMotorsClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Motors ROS Publisher @@ -63,10 +63,10 @@ def __Motorsdisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getMotorsClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None @@ -79,11 +79,11 @@ def getMotorsClient (jdrc, prefix): ''' Returns a Motors Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: Name of client in config file @param node: ROS node - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @type node: ROS node diff --git a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in b/src/libs/jderobotcomm_py/comm/pose3dClient.py.only-ice.in similarity index 81% rename from src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in rename to src/libs/jderobotcomm_py/comm/pose3dClient.py.only-ice.in index f66a3f690..dc66d9326 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.only-ice.in +++ b/src/libs/jderobotcomm_py/comm/pose3dClient.py.only-ice.in @@ -7,10 +7,10 @@ def __getPoseIceClient(jdrc, prefix): ''' Returns a Pose3D Ice Client. This function should never be used. Use getPose3dClient instead of this - @@param jdrc: JdeRobotComm Communicator + @@param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Pose3D Ice Client @@ -25,10 +25,10 @@ def __getListenerPose(jdrc, prefix): ''' Returns a Pose3D ROS Subscriber. This function should never be used. Use getPose3dClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Pose3D ROS Subscriber @@ -42,10 +42,10 @@ def __Posedisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getPose3dClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None @@ -58,10 +58,10 @@ def getPose3dClient (jdrc, prefix): ''' Returns a Pose3D Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None if pose3d is disabled diff --git a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in b/src/libs/jderobotcomm_py/comm/pose3dClient.py.ros.in similarity index 84% rename from src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in rename to src/libs/jderobotcomm_py/comm/pose3dClient.py.ros.in index ddd9665bb..3ed047f00 100644 --- a/src/libs/jderobotcomm_py/jderobotComm/pose3dClient.py.ros.in +++ b/src/libs/jderobotcomm_py/comm/pose3dClient.py.ros.in @@ -12,10 +12,10 @@ def __getPoseIceClient(jdrc, prefix): ''' Returns a Pose3D Ice Client. This function should never be used. Use getPose3dClient instead of this - @@param jdrc: JdeRobotComm Communicator + @@param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Pose3D Ice Client @@ -30,10 +30,10 @@ def __getListenerPose(jdrc, prefix): ''' Returns a Pose3D ROS Subscriber. This function should never be used. Use getPose3dClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return Pose3D ROS Subscriber @@ -53,10 +53,10 @@ def __Posedisabled(jdrc, prefix): ''' Prints a warning that the client is disabled. This function should never be used. Use getPose3dClient instead of this - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None @@ -69,10 +69,10 @@ def getPose3dClient (jdrc, prefix): ''' Returns a Pose3D Client. - @param jdrc: JdeRobotComm Communicator + @param jdrc: Comm Communicator @param prefix: name of client in config file - @type jdrc: JdeRobotComm Communicator + @type jdrc: Comm Communicator @type prefix: String @return None if pose3d is disabled diff --git a/src/libs/jderobotcomm_py/jderobotComm/ros/__init__.py b/src/libs/jderobotcomm_py/comm/ros/__init__.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ros/__init__.py rename to src/libs/jderobotcomm_py/comm/ros/__init__.py diff --git a/src/libs/jderobotcomm_py/jderobotComm/ros/listenerCamera.py b/src/libs/jderobotcomm_py/comm/ros/listenerCamera.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ros/listenerCamera.py rename to src/libs/jderobotcomm_py/comm/ros/listenerCamera.py diff --git a/src/libs/jderobotcomm_py/jderobotComm/ros/listenerLaser.py b/src/libs/jderobotcomm_py/comm/ros/listenerLaser.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ros/listenerLaser.py rename to src/libs/jderobotcomm_py/comm/ros/listenerLaser.py diff --git a/src/libs/jderobotcomm_py/jderobotComm/ros/listenerPose3d.py b/src/libs/jderobotcomm_py/comm/ros/listenerPose3d.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ros/listenerPose3d.py rename to src/libs/jderobotcomm_py/comm/ros/listenerPose3d.py diff --git a/src/libs/jderobotcomm_py/jderobotComm/ros/publisherMotors.py b/src/libs/jderobotcomm_py/comm/ros/publisherMotors.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ros/publisherMotors.py rename to src/libs/jderobotcomm_py/comm/ros/publisherMotors.py diff --git a/src/libs/jderobotcomm_py/jderobotComm/ros/threadPublisher.py b/src/libs/jderobotcomm_py/comm/ros/threadPublisher.py similarity index 100% rename from src/libs/jderobotcomm_py/jderobotComm/ros/threadPublisher.py rename to src/libs/jderobotcomm_py/comm/ros/threadPublisher.py diff --git a/src/libs/jderobotcomm_py/test.yml b/src/libs/jderobotcomm_py/test.yml index 967c8eaa7..e22b1cb39 100644 --- a/src/libs/jderobotcomm_py/test.yml +++ b/src/libs/jderobotcomm_py/test.yml @@ -1,38 +1,38 @@ +Test: + Motors: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Motors:default -h localhost -p 9001" + Topic: "/cmd_vel_mux/input/teleop" + Name: testMotors + maxV: 3 + maxW: 0.7 -Motors: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "Motors:default -h localhost -p 9001" - Topic: "/cmd_vel_mux/input/teleop" - Name: testMotors - maxV: 3 - maxW: 0.7 + Camera1: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera1 -Camera1: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "CameraL:default -h localhost -p 9001" - Format: RGB8 - Topic: "/camera/rgb/image_raw" - Name: testCamera1 + Camera2: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraR:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera2 -Camera2: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "CameraR:default -h localhost -p 9001" - Format: RGB8 - Topic: "/camera/rgb/image_raw" - Name: testCamera2 + Pose3D: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Pose3D:default -h localhost -p 9001" + Topic: "/odom" + Name: testPose3d -Pose3D: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "Pose3D:default -h localhost -p 9001" - Topic: "/odom" - Name: testPose3d + Laser: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Laser:default -h localhost -p 9001" + Topic: "/scan" + Name: testLaser -Laser: - Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS - Proxy: "Laser:default -h localhost -p 9001" - Topic: "/scan" - Name: testLaser - -Vmax: 3 -Wmax: 0.7 -NodeName: JdeRobotCommTest \ No newline at end of file + Vmax: 3 + Wmax: 0.7 + NodeName: JdeRobotCommTest \ No newline at end of file diff --git a/src/libs/jderobotcomm_py/testCamera.py b/src/libs/jderobotcomm_py/testCamera.py index de4a9a021..dece71e67 100755 --- a/src/libs/jderobotcomm_py/testCamera.py +++ b/src/libs/jderobotcomm_py/testCamera.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 import config -import jderobotComm as comm +import comm import sys import time import signal @@ -13,9 +13,9 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg) + jdrc= comm.init(cfg, "Test") - client = jdrc.getCameraClient("Camera1") + client = jdrc.getCameraClient("Test.Camera1") for i in range (10): #print("client1", end=":") diff --git a/src/libs/jderobotcomm_py/testLaser.py b/src/libs/jderobotcomm_py/testLaser.py index bf6e17b22..75de3f623 100755 --- a/src/libs/jderobotcomm_py/testLaser.py +++ b/src/libs/jderobotcomm_py/testLaser.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 import config -import jderobotComm as comm +import comm import sys import time import signal @@ -13,10 +13,10 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg) + jdrc= comm.init(cfg, "Test") - client = jdrc.getLaserClient("Laser") - client2 = jdrc.getLaserClient("Laser") + client = jdrc.getLaserClient("Test.Laser") + client2 = jdrc.getLaserClient("Test.Laser") for i in range (10): #print("client1", end=":") diff --git a/src/libs/jderobotcomm_py/testMotors.py b/src/libs/jderobotcomm_py/testMotors.py index ed4033bb0..1b9b554c7 100644 --- a/src/libs/jderobotcomm_py/testMotors.py +++ b/src/libs/jderobotcomm_py/testMotors.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 import config -import jderobotComm as comm +import comm import sys import time import signal @@ -13,13 +13,13 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg) + jdrc= comm.init(cfg, "Test") vel = CMDVel() vel.vx = 1 vel.az = 0.1 - client = jdrc.getMotorsClient("Motors") + client = jdrc.getMotorsClient("Test.Motors") for i in range (10): client.sendVelocities(vel) time.sleep(1) diff --git a/src/libs/jderobotcomm_py/testPose.py b/src/libs/jderobotcomm_py/testPose.py index 697e41d6a..d2171a9fe 100644 --- a/src/libs/jderobotcomm_py/testPose.py +++ b/src/libs/jderobotcomm_py/testPose.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 import config -import jderobotComm as comm +import comm import sys import time import signal @@ -13,9 +13,9 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - jdrc= comm.init(cfg) + jdrc= comm.init(cfg, "Test") - client = jdrc.getPose3dClient("Pose3D") + client = jdrc.getPose3dClient("Test.Pose3D") for i in range (10): #print("client1", end=":") diff --git a/src/samples/basic_component_py/basic_component.py b/src/samples/basic_component_py/basic_component.py index a5dcc535a..069d13065 100755 --- a/src/samples/basic_component_py/basic_component.py +++ b/src/samples/basic_component_py/basic_component.py @@ -21,11 +21,11 @@ import sys -import jderobotComm as comm +import comm from gui.threadGUI import ThreadGUI from gui.GUI import MainWindow from PyQt5.QtWidgets import QApplication -import jderobotconfig as config +import config import signal @@ -34,13 +34,12 @@ if __name__ == '__main__': cfg = config.load(sys.argv[1]) - #starting comm - jdrc= comm.init(cfg['basic_component']) + jdrc= comm.init(cfg, 'basic_component') - camera = jdrc.getCameraClient("Camera") - motors = jdrc.getMotorsClient("Motors") + camera = jdrc.getCameraClient("basic_component.Camera") + motors = jdrc.getMotorsClient("basic_component.Motors") app = QApplication(sys.argv) frame = MainWindow() diff --git a/src/tools/cameraview/CMakeLists.txt b/src/tools/cameraview/CMakeLists.txt index e5733d563..a1820aceb 100644 --- a/src/tools/cameraview/CMakeLists.txt +++ b/src/tools/cameraview/CMakeLists.txt @@ -13,13 +13,13 @@ include_directories( ${resourcelocator_INCLUDE_DIRS} ${jderobottypes_INCLUDE_DIRS} ${jderobotcomm_INCLUDE_DIRS} - ${jderobotconfig_INCLUDE_DIRS} + ${config_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} ) link_directories( ${resourcelocator_LIBRARY_DIRS} ${jderobotcomm_LIBRARY_DIRS} - ${jderobotconfig_LIBRARY_DIRS} + ${config_LIBRARY_DIRS} ) add_executable (cameraview ${SOURCE_FILES}) @@ -37,7 +37,7 @@ TARGET_LINK_LIBRARIES(cameraview ${resourcelocator_LIBRARIES} ${catkin_LIBRARIES} ${jderobotcomm_LIBRARIES} - ${jderobotconfig_LIBRARIES} + ${config_LIBRARIES} ${GLOG_LIBRARIES} JderobotInterfaces jderobotutil diff --git a/src/tools/cameraview/cameraview.cpp b/src/tools/cameraview/cameraview.cpp index dd9e542f9..7cd807bf3 100644 --- a/src/tools/cameraview/cameraview.cpp +++ b/src/tools/cameraview/cameraview.cpp @@ -34,12 +34,12 @@ int main(int argc, char** argv){ cameraview::Viewer viewer; - JdeRobotComm::CameraClient* camRGB; + Comm::CameraClient* camRGB; Config::Properties cfg = Config::load(argc, argv); - JdeRobotComm::Communicator* jdrc = new JdeRobotComm::Communicator(cfg); + Comm::Communicator* jdrc = new Comm::Communicator(cfg); - camRGB = JdeRobotComm::getCameraClient(jdrc, "Cameraview.Camera"); + camRGB = Comm::getCameraClient(jdrc, "Cameraview.Camera"); JdeRobotTypes::Image rgb; diff --git a/src/tools/kobukiViewer/CMakeLists.txt b/src/tools/kobukiViewer/CMakeLists.txt index c411d57f4..db808f823 100644 --- a/src/tools/kobukiViewer/CMakeLists.txt +++ b/src/tools/kobukiViewer/CMakeLists.txt @@ -34,7 +34,7 @@ if (${QT5_COMPILE} AND ${roscpp_FOUND}) ${INTERFACES_CPP_DIR} ${LIBS_DIR}/ ${CMAKE_CURRENT_SOURCE_DIR} - ${easyiceconfig_INCLUDE_DIRS} + ${config_INCLUDE_DIRS} ${jderobottypes_INCLUDE_DIRS} ${jderobotcomm_INCLUDE_DIRS} ${roscpp_INCLUDE_DIRS} @@ -55,7 +55,7 @@ if (${QT5_COMPILE} AND ${roscpp_FOUND}) ${Qt5OpenGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${OpenCV_LIBRARIES} - ${easyiceconfig_LIBRARIES} + ${config_LIBRARIES} ${jderobotcomm_LIBRARIES} ${ZeroCIce_LIBRARIES} JderobotInterfaces @@ -70,7 +70,7 @@ if (${QT5_COMPILE} AND ${roscpp_FOUND}) COMPONENT tools ) - INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/kobukiViewer.cfg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf) + INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/kobukiViewer.yml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf) ENDIF() diff --git a/src/tools/kobukiViewer/gui/gui.cpp b/src/tools/kobukiViewer/gui/gui.cpp index 36d522c30..537885160 100644 --- a/src/tools/kobukiViewer/gui/gui.cpp +++ b/src/tools/kobukiViewer/gui/gui.cpp @@ -1,6 +1,6 @@ #include "gui.h" -GUI::GUI(Robot* robot, Ice::CommunicatorPtr ic) +GUI::GUI(Robot* robot, Config::Properties props) { this->robot = robot; @@ -22,7 +22,7 @@ GUI::GUI(Robot* robot, Ice::CommunicatorPtr ic) currentW = new QLabel("0"); canvasVW = new controlVW(); - canvasVW->setIC(ic); + canvasVW->setProps(props); laserWidget =new LaserWidget(); diff --git a/src/tools/kobukiViewer/gui/gui.h b/src/tools/kobukiViewer/gui/gui.h index 6b1d9203f..0b37a0789 100644 --- a/src/tools/kobukiViewer/gui/gui.h +++ b/src/tools/kobukiViewer/gui/gui.h @@ -5,6 +5,8 @@ #include "../robot/robot.h" +#include + #include "widget/controlvw.h" #include "widget/cameraswidget.h" #include "widget/laserwidget.h" @@ -14,7 +16,7 @@ class GUI:public QWidget Q_OBJECT public: - GUI(Robot* robot, Ice::CommunicatorPtr ic); + GUI(Robot* robot, Config::Properties props); void updateThreadGUI(); private: diff --git a/src/tools/kobukiViewer/gui/threadupdategui.cpp b/src/tools/kobukiViewer/gui/threadupdategui.cpp index 566a167aa..0167829a7 100644 --- a/src/tools/kobukiViewer/gui/threadupdategui.cpp +++ b/src/tools/kobukiViewer/gui/threadupdategui.cpp @@ -1,10 +1,10 @@ #include "threadupdategui.h" -ThreadUpdateGUI::ThreadUpdateGUI(Robot* robot, Ice::CommunicatorPtr ic) +ThreadUpdateGUI::ThreadUpdateGUI(Robot* robot, Config::Properties props) { this->robot = robot; - gui = new GUI(robot, ic); + gui = new GUI(robot, props); gui->show(); } diff --git a/src/tools/kobukiViewer/gui/threadupdategui.h b/src/tools/kobukiViewer/gui/threadupdategui.h index cb93512a3..d0d781f62 100644 --- a/src/tools/kobukiViewer/gui/threadupdategui.h +++ b/src/tools/kobukiViewer/gui/threadupdategui.h @@ -9,12 +9,14 @@ #include #include +#include + #define cycle_update_gui 50 //miliseconds class ThreadUpdateGUI: public QThread { public: - ThreadUpdateGUI(Robot *robot, Ice::CommunicatorPtr ic); + ThreadUpdateGUI(Robot *robot, Config::Properties props); private: GUI* gui; diff --git a/src/tools/kobukiViewer/gui/widget/controlvw.cpp b/src/tools/kobukiViewer/gui/widget/controlvw.cpp index 02e6c6f47..2e6500c2b 100644 --- a/src/tools/kobukiViewer/gui/widget/controlvw.cpp +++ b/src/tools/kobukiViewer/gui/widget/controlvw.cpp @@ -27,13 +27,12 @@ controlVW::controlVW(QWidget *parent) : } -void controlVW::setIC(Ice::CommunicatorPtr ic) +void controlVW::setProps(Config::Properties props) { - this->ic = ic; - Ice::PropertiesPtr prop = ic->getProperties(); + this->props = props; - QString svmax = QString::fromUtf8(prop->getPropertyWithDefault("kobukiViewer.Vmax", "5").c_str()); - QString swmax = QString::fromUtf8(prop->getPropertyWithDefault("kobukiViewer.Wmax", "0.5").c_str()); + QString svmax = QString::fromUtf8(props.asStringWithDefault("kobukiViewer.Vmax", "5").c_str()); + QString swmax = QString::fromUtf8(props.asStringWithDefault("kobukiViewer.Wmax", "0.5").c_str()); this->v_max = svmax.toFloat(); this->w_max = swmax.toFloat(); diff --git a/src/tools/kobukiViewer/gui/widget/controlvw.h b/src/tools/kobukiViewer/gui/widget/controlvw.h index 1d773857d..504ab899f 100644 --- a/src/tools/kobukiViewer/gui/widget/controlvw.h +++ b/src/tools/kobukiViewer/gui/widget/controlvw.h @@ -6,7 +6,7 @@ #include #include -#include "easyiceconfig/EasyIce.h" +#include class controlVW : public QWidget { @@ -15,7 +15,7 @@ class controlVW : public QWidget explicit controlVW(QWidget *parent = 0); void Stop(); - void setIC(Ice::CommunicatorPtr ic); + void setProps(Config::Properties props); float getV(); float getW(); @@ -24,7 +24,7 @@ class controlVW : public QWidget QImage qimage; float v, w, v_max, w_max; - Ice::CommunicatorPtr ic; + Config::Properties props; protected: void paintEvent(QPaintEvent *); diff --git a/src/tools/kobukiViewer/kobukiViewer.cfg b/src/tools/kobukiViewer/kobukiViewer.cfg deleted file mode 100644 index db28984e3..000000000 --- a/src/tools/kobukiViewer/kobukiViewer.cfg +++ /dev/null @@ -1,36 +0,0 @@ - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Motors.Server=1 -kobukiViewer.Motors.Proxy=Motors:tcp -h localhost -p 9001 -kobukiViewer.Motors.Topic=/turtlebotROS/mobile_base/commands/velocity -kobukiViewer.Motors.Name=kobukiViewerMotors - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Pose3D.Server=1 -kobukiViewer.Pose3D.Proxy=Pose3D:tcp -h localhost -p 9001 -kobukiViewer.Pose3D.Topic=/turtlebotROS/odom -kobukiViewer.Pose3D.Name=kobukiViewerPose3d - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Camera1.Server=1 -kobukiViewer.Camera1.Proxy=CameraL:tcp -h localhost -p 9001 -kobukiViewer.Camera1.Format=RGB8 -kobukiViewer.Camera1.Topic=/TurtlebotROS/cameraL/image_raw -kobukiViewer.Camera1.Name=kobukiViewerCamera1 - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Camera2.Server=1 -kobukiViewer.Camera2.Proxy=CameraR:tcp -h localhost -p 9001 -kobukiViewer.Camera2.Format=RGB8 -kobukiViewer.Camera2.Topic=/TurtlebotROS/cameraR/image_raw -kobukiViewer.Camera2.Name=kobukiViewerCamera2 - - -# 0 -> Deactivate, 1 -> Ice , 2 -> ROS -kobukiViewer.Laser.Server=1 -kobukiViewer.Laser.Proxy=Laser:tcp -h localhost -p 9001 -kobukiViewer.Laser.Topic=/turtlebotROS/laser/scan -kobukiViewer.Laser.Name=kobukiViewerLaser - -kobukiViewer.Vmax=3 -kobukiViewer.Wmax=0.7 diff --git a/src/tools/kobukiViewer/kobukiViewer.yml b/src/tools/kobukiViewer/kobukiViewer.yml new file mode 100644 index 000000000..c571b1f7f --- /dev/null +++ b/src/tools/kobukiViewer/kobukiViewer.yml @@ -0,0 +1,38 @@ +kobukiViewer: + Motors: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Motors:default -h localhost -p 9001" + Topic: "/cmd_vel_mux/input/teleop" + Name: testMotors + maxV: 3 + maxW: 0.7 + + Camera1: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera1 + + Camera2: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraR:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera2 + + Pose3D: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Pose3D:default -h localhost -p 9001" + Topic: "/odom" + Name: testPose3d + + Laser: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Laser:default -h localhost -p 9001" + Topic: "/scan" + Name: testLaser + + Vmax: 3 + Wmax: 0.7 + NodeName: kobukiViewer \ No newline at end of file diff --git a/src/tools/kobukiViewer/main.cpp b/src/tools/kobukiViewer/main.cpp index dbccecc33..53966ca96 100644 --- a/src/tools/kobukiViewer/main.cpp +++ b/src/tools/kobukiViewer/main.cpp @@ -1,24 +1,29 @@ #include "robot/robot.h" #include "gui/threadupdategui.h" -#include "easyiceconfig/EasyIce.h" +#include "jderobot/config/config.h" +#include "jderobot/comm/communicator.hpp" int main(int argc, char *argv[]) { QApplication app(argc, argv); - Ice::CommunicatorPtr ic; try { - //-----------------ICE----------------// - ic = EasyIce::initialize(argc, argv); + + Config::Properties props = Config::load(argc, argv); + + + + //-----------------Comm----------------// + Comm::Communicator* jdrc = new Comm::Communicator(props); // Variables Compartidas // Robot -> Sensores, navegacion, actuadores - Robot *robot = new Robot(ic); + Robot *robot = new Robot(jdrc); - ThreadUpdateGUI* thread_update_gui = new ThreadUpdateGUI(robot, ic); + ThreadUpdateGUI* thread_update_gui = new ThreadUpdateGUI(robot, props); thread_update_gui->start(); } catch (const Ice::Exception& ex) { diff --git a/src/tools/kobukiViewer/robot/actuators.cpp b/src/tools/kobukiViewer/robot/actuators.cpp index 1db51cc87..8af861fef 100755 --- a/src/tools/kobukiViewer/robot/actuators.cpp +++ b/src/tools/kobukiViewer/robot/actuators.cpp @@ -1,10 +1,10 @@ #include "actuators.h" -Actuators::Actuators(Ice::CommunicatorPtr ic) +Actuators::Actuators(Comm::Communicator* jdrc) { - this->ic = ic; + this->jdrc = jdrc; - this->motorsClient = JdeRobotComm::getMotorsClient(ic, "kobukiViewer.Motors"); + this->motorsClient = Comm::getMotorsClient(jdrc, "kobukiViewer.Motors"); } diff --git a/src/tools/kobukiViewer/robot/actuators.h b/src/tools/kobukiViewer/robot/actuators.h index 83e804c94..33097df4e 100755 --- a/src/tools/kobukiViewer/robot/actuators.h +++ b/src/tools/kobukiViewer/robot/actuators.h @@ -7,12 +7,13 @@ #include #include +#include "jderobot/comm/communicator.hpp" #include class Actuators { public: - Actuators(Ice::CommunicatorPtr ic); + Actuators(Comm::Communicator* jdrc); float getMotorV(); float getMotorW(); @@ -28,10 +29,10 @@ class Actuators QMutex mutex; - Ice::CommunicatorPtr ic; + Comm::Communicator* jdrc; // ICE INTERFACES - JdeRobotComm::MotorsClient* motorsClient; + Comm::MotorsClient* motorsClient; }; #endif // ACTUATORS_H diff --git a/src/tools/kobukiViewer/robot/robot.cpp b/src/tools/kobukiViewer/robot/robot.cpp index bb699925e..4dd61356a 100644 --- a/src/tools/kobukiViewer/robot/robot.cpp +++ b/src/tools/kobukiViewer/robot/robot.cpp @@ -1,9 +1,9 @@ #include "robot.h" -Robot::Robot(Ice::CommunicatorPtr ic) +Robot::Robot(Comm::Communicator* jdrc) { - sensors = new Sensors(ic); - actuators = new Actuators(ic); + sensors = new Sensors(jdrc); + actuators = new Actuators(jdrc); pthread_mutex_init (&mutex, NULL); diff --git a/src/tools/kobukiViewer/robot/robot.h b/src/tools/kobukiViewer/robot/robot.h index f079e153e..76375882a 100644 --- a/src/tools/kobukiViewer/robot/robot.h +++ b/src/tools/kobukiViewer/robot/robot.h @@ -6,6 +6,8 @@ #include "sensors.h" #include "actuators.h" +#include "jderobot/comm/communicator.hpp" + #include class Robot: public QObject @@ -13,7 +15,7 @@ class Robot: public QObject Q_OBJECT public: - Robot(Ice::CommunicatorPtr ic); + Robot(Comm::Communicator* jdrc); void update(); diff --git a/src/tools/kobukiViewer/robot/sensors.cpp b/src/tools/kobukiViewer/robot/sensors.cpp index 030a54c04..99911950a 100755 --- a/src/tools/kobukiViewer/robot/sensors.cpp +++ b/src/tools/kobukiViewer/robot/sensors.cpp @@ -1,24 +1,24 @@ #include "sensors.h" -Sensors::Sensors(Ice::CommunicatorPtr ic) +Sensors::Sensors(Comm::Communicator* jdrc) { - this-> ic = ic; + this-> jdrc = jdrc; - this->poseClient = JdeRobotComm::getPose3dClient(ic, "kobukiViewer.Pose3D"); + this->poseClient = Comm::getPose3dClient(jdrc, "kobukiViewer.Pose3D"); ////////////////////////////// CAMERA1 ///////////////////////////// - this->camera1 = JdeRobotComm::getCameraClient(ic, "kobukiViewer.Camera1"); + this->camera1 = Comm::getCameraClient(jdrc, "kobukiViewer.Camera1"); ////////////////////////////// CAMERA2 ///////////////////////////// - this->camera2 = JdeRobotComm::getCameraClient(ic, "kobukiViewer.Camera2"); + this->camera2 = Comm::getCameraClient(jdrc, "kobukiViewer.Camera2"); ////////////////////////////// LASER ////////////////////////////// // Contact to LASER interface - this->laserClient = JdeRobotComm::getLaserClient(ic, "kobukiViewer.Laser"); + this->laserClient = Comm::getLaserClient(jdrc, "kobukiViewer.Laser"); } JdeRobotTypes::Image Sensors::getImage1() diff --git a/src/tools/kobukiViewer/robot/sensors.h b/src/tools/kobukiViewer/robot/sensors.h index 98f150e9c..c5b1782fc 100755 --- a/src/tools/kobukiViewer/robot/sensors.h +++ b/src/tools/kobukiViewer/robot/sensors.h @@ -13,6 +13,7 @@ #include #include +#include "jderobot/comm/communicator.hpp" #include #include #include @@ -20,7 +21,7 @@ class Sensors { public: - Sensors(Ice::CommunicatorPtr ic); + Sensors(Comm::Communicator* jdrc); JdeRobotTypes::Pose3d getPose(); JdeRobotTypes::LaserData getLaserData(); @@ -31,15 +32,15 @@ class Sensors private: - Ice::CommunicatorPtr ic; + Comm::Communicator* jdrc; //LASER DATA - JdeRobotComm::LaserClient* laserClient; + Comm::LaserClient* laserClient; - JdeRobotComm::CameraClient* camera1; - JdeRobotComm::CameraClient* camera2; + Comm::CameraClient* camera1; + Comm::CameraClient* camera2; - JdeRobotComm::Pose3dClient* poseClient; + Comm::Pose3dClient* poseClient; From c2b9e657d209b12d515b704d2d99cf178981809e Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Tue, 3 Oct 2017 08:40:43 +0200 Subject: [PATCH 12/14] changed jderobotcomm_py by comm_py 2 --- src/libs/comm_py/CMakeLists.txt | 26 ++ src/libs/comm_py/comm/__init__.py | 22 ++ .../comm_py/comm/cameraClient.py.only-ice.in | 75 ++++++ src/libs/comm_py/comm/cameraClient.py.ros.in | 84 +++++++ .../comm_py/comm/communicator.py.only-ice.in | 101 ++++++++ src/libs/comm_py/comm/communicator.py.ros.in | 108 ++++++++ src/libs/comm_py/comm/ice/__init__.py | 0 src/libs/comm_py/comm/ice/cameraIceClient.py | 178 ++++++++++++++ src/libs/comm_py/comm/ice/laserIceClient.py | 174 +++++++++++++ src/libs/comm_py/comm/ice/motorsIceClient.py | 125 ++++++++++ src/libs/comm_py/comm/ice/pose3dIceClient.py | 231 ++++++++++++++++++ src/libs/comm_py/comm/ice/threadSensor.py | 46 ++++ .../comm_py/comm/laserClient.py.only-ice.in | 75 ++++++ src/libs/comm_py/comm/laserClient.py.ros.in | 84 +++++++ .../comm_py/comm/motorsClient.py.only-ice.in | 79 ++++++ src/libs/comm_py/comm/motorsClient.py.ros.in | 99 ++++++++ .../comm_py/comm/pose3dClient.py.only-ice.in | 76 ++++++ src/libs/comm_py/comm/pose3dClient.py.ros.in | 87 +++++++ src/libs/comm_py/comm/ros/__init__.py | 0 src/libs/comm_py/comm/ros/listenerCamera.py | 107 ++++++++ src/libs/comm_py/comm/ros/listenerLaser.py | 99 ++++++++ src/libs/comm_py/comm/ros/listenerPose3d.py | 156 ++++++++++++ src/libs/comm_py/comm/ros/publisherMotors.py | 177 ++++++++++++++ src/libs/comm_py/comm/ros/threadPublisher.py | 46 ++++ src/libs/comm_py/test.yml | 38 +++ src/libs/comm_py/testCamera.py | 38 +++ src/libs/comm_py/testLaser.py | 42 ++++ src/libs/comm_py/testMotors.py | 27 ++ src/libs/comm_py/testPose.py | 26 ++ 29 files changed, 2426 insertions(+) create mode 100644 src/libs/comm_py/CMakeLists.txt create mode 100644 src/libs/comm_py/comm/__init__.py create mode 100644 src/libs/comm_py/comm/cameraClient.py.only-ice.in create mode 100644 src/libs/comm_py/comm/cameraClient.py.ros.in create mode 100644 src/libs/comm_py/comm/communicator.py.only-ice.in create mode 100644 src/libs/comm_py/comm/communicator.py.ros.in create mode 100644 src/libs/comm_py/comm/ice/__init__.py create mode 100644 src/libs/comm_py/comm/ice/cameraIceClient.py create mode 100644 src/libs/comm_py/comm/ice/laserIceClient.py create mode 100644 src/libs/comm_py/comm/ice/motorsIceClient.py create mode 100644 src/libs/comm_py/comm/ice/pose3dIceClient.py create mode 100644 src/libs/comm_py/comm/ice/threadSensor.py create mode 100644 src/libs/comm_py/comm/laserClient.py.only-ice.in create mode 100644 src/libs/comm_py/comm/laserClient.py.ros.in create mode 100644 src/libs/comm_py/comm/motorsClient.py.only-ice.in create mode 100644 src/libs/comm_py/comm/motorsClient.py.ros.in create mode 100644 src/libs/comm_py/comm/pose3dClient.py.only-ice.in create mode 100644 src/libs/comm_py/comm/pose3dClient.py.ros.in create mode 100644 src/libs/comm_py/comm/ros/__init__.py create mode 100644 src/libs/comm_py/comm/ros/listenerCamera.py create mode 100644 src/libs/comm_py/comm/ros/listenerLaser.py create mode 100644 src/libs/comm_py/comm/ros/listenerPose3d.py create mode 100644 src/libs/comm_py/comm/ros/publisherMotors.py create mode 100644 src/libs/comm_py/comm/ros/threadPublisher.py create mode 100644 src/libs/comm_py/test.yml create mode 100755 src/libs/comm_py/testCamera.py create mode 100755 src/libs/comm_py/testLaser.py create mode 100644 src/libs/comm_py/testMotors.py create mode 100644 src/libs/comm_py/testPose.py diff --git a/src/libs/comm_py/CMakeLists.txt b/src/libs/comm_py/CMakeLists.txt new file mode 100644 index 000000000..37e183486 --- /dev/null +++ b/src/libs/comm_py/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8) + +#macro configure files + +macro(configure_jderobotcomm_py in) + file(GLOB_RECURSE files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/comm/ *.${in}) + + foreach(file ${files}) + string(REGEX REPLACE "\\.${in}$" "" f "${file}") + + configure_file_python(comm/${file} comm/${f}) + + endforeach(file ${files}) + +endmacro() + +if(roscpp_FOUND) + configure_jderobotcomm_py(ros.in) +ELSE() + configure_jderobotcomm_py(only-ice.in) +endif() + +add_custom_target(jderobotcomm_py ALL) +copy_to_binary_python(jderobotcomm_py comm) + +install_python(comm core) \ No newline at end of file diff --git a/src/libs/comm_py/comm/__init__.py b/src/libs/comm_py/comm/__init__.py new file mode 100644 index 000000000..f14587b65 --- /dev/null +++ b/src/libs/comm_py/comm/__init__.py @@ -0,0 +1,22 @@ +from .communicator import Communicator + + + + +def init (config, prefix): + ''' + Starts JdeRobotComm + + @param config: configuration of client + + @type config: dict + ''' + return Communicator(config, prefix) + + + + + + + + diff --git a/src/libs/comm_py/comm/cameraClient.py.only-ice.in b/src/libs/comm_py/comm/cameraClient.py.only-ice.in new file mode 100644 index 000000000..62e6c3950 --- /dev/null +++ b/src/libs/comm_py/comm/cameraClient.py.only-ice.in @@ -0,0 +1,75 @@ +import sys +import Ice +from .ice.cameraIceClient import CameraIceClient + +def __getCameraIceClient(jdrc, prefix): + ''' + Returns a Camera Ice Client. This function should never be used. Use getCameraClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type ic: Ice Communicator + @type prefix: String + + @return Camera Ice Client + + ''' + print("Receiving " + prefix + " Image from ICE interfaces") + client = CameraIceClient(jdrc, prefix) + client.start() + return client + +def __getListenerCamera(jdrc, prefix): + ''' + Returns a Camera ROS Subscriber. This function should never be used. Use getCameraClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type ic: Ice Communicator + @type prefix: String + + @return Camera ROS Subscriber + + ''' + + print(prefix + ": ROS msg are diabled") + return None + +def __Cameradisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getCameraClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type ic: Ice Communicator + @type prefix: String + + @return None + + ''' + print( prefix + " Disabled") + return None + +def getCameraClient (jdrc, prefix): + ''' + Returns a Camera Client. + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type name: String + + @return None if Camera is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Cameradisabled, __getCameraIceClient, __getListenerCamera] + + return cons[server](jdrc, name) \ No newline at end of file diff --git a/src/libs/comm_py/comm/cameraClient.py.ros.in b/src/libs/comm_py/comm/cameraClient.py.ros.in new file mode 100644 index 000000000..4d8f913d8 --- /dev/null +++ b/src/libs/comm_py/comm/cameraClient.py.ros.in @@ -0,0 +1,84 @@ +import sys +import Ice +import rospy +from .ice.cameraIceClient import CameraIceClient + +if (sys.version_info[0] == 2): + from .ros.listenerCamera import ListenerCamera + +def __getCameraIceClient(jdrc, prefix): + ''' + Returns a Camera Ice Client. This function should never be used. Use getCameraClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type ic: Ice Communicator + @type prefix: String + + @return Camera Ice Client + + ''' + print("Receiving " + prefix + " Image from ICE interfaces") + client = CameraIceClient(jdrc, prefix) + client.start() + return client + +def __getListenerCamera(jdrc, prefix): + ''' + Returns a Camera ROS Subscriber. This function should never be used. Use getCameraClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type ic: Ice Communicator + @type prefix: String + + @return Camera ROS Subscriber + + ''' + if (sys.version_info[0] == 2): + print("Receiving " + prefix + " Image from ROS messages") + topic = jdrc.getConfig().getProperty(prefix+".topic") + client = ListenerCamera(topic) + return client + else: + print(prefix + ": ROS msg are diabled for python "+ sys.version_info[0]) + return None + +def __Cameradisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getCameraClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type ic: Ice Communicator + @type prefix: String + + @return None + + ''' + print( prefix + " Disabled") + return None + +def getCameraClient (jdrc, prefix): + ''' + Returns a Camera Client. + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type name: String + + @return None if Camera is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Cameradisabled, __getCameraIceClient, __getListenerCamera] + + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/comm_py/comm/communicator.py.only-ice.in b/src/libs/comm_py/comm/communicator.py.only-ice.in new file mode 100644 index 000000000..6158edf2e --- /dev/null +++ b/src/libs/comm_py/comm/communicator.py.only-ice.in @@ -0,0 +1,101 @@ +import Ice + +from .laserClient import getLaserClient +from .cameraClient import getCameraClient +from .pose3dClient import getPose3dClient +from .motorsClient import getMotorsClient + + +class Communicator: + ''' + Comm Communicator class + + ''' + def __init__ (self, config, prefix): + ''' + Communicator constructor + + @param config: configuration of communicator + + @type config: dict + + ''' + rosserver = False + iceserver = False + + self.__node = None + self.__ic = None + self.config = config + + ymlNode = self.config.getProperty(prefix) + for i in ymlNode: + if type(ymlNode[i]) is dict and ymlNode[i]["Server"] == 1: + iceserver = True + + if iceserver: + id = Ice.InitializationData() + self.__ic = Ice.initialize(None, id) + + def destroy (self): + ''' + Destroys ROS Node and Ice Communicator if it is necessary. + + ''' + if self.__ic: + self.__ic.shutdown() + self.__ic.destroy() + + def getNode(self): + return self.__node + + def getIc(self): + return self.__ic + + def getConfig(self): + return self.config + + + def getCameraClient(self, name): + ''' + Returns a Camera client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getCameraClient(self, name) + + def getMotorsClient(self, name): + ''' + Returns a Motors client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getMotorsClient(self, name) + + def getPose3dClient(self, name): + ''' + Returns a Pose3D client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getPose3dClient(self, name) + + def getLaserClient(self, name): + ''' + Returns a Laser client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getLaserClient(self, name) + diff --git a/src/libs/comm_py/comm/communicator.py.ros.in b/src/libs/comm_py/comm/communicator.py.ros.in new file mode 100644 index 000000000..53a65dd03 --- /dev/null +++ b/src/libs/comm_py/comm/communicator.py.ros.in @@ -0,0 +1,108 @@ +import Ice +import rospy + +from .laserClient import getLaserClient +from .cameraClient import getCameraClient +from .pose3dClient import getPose3dClient +from .motorsClient import getMotorsClient + + +class Communicator: + ''' + Comm Communicator class + + ''' + def __init__ (self, config, prefix): + ''' + Communicator constructor + + @param config: configuration of communicator + + @type config: dict + + ''' + rosserver = False + iceserver = False + + self.__node = None + self.__ic = None + self.config = config + + ymlNode = self.config.getProperty(prefix) + for i in ymlNode: + if type(ymlNode[i]) is dict and ymlNode[i]["Server"] == 1: + iceserver = True + if type(ymlNode[i]) is dict and ymlNode[i]["Server"] == 2: + rosserver = True + + if rosserver: + self.__node = rospy.init_node(ymlNode["NodeName"], anonymous=True) + if iceserver: + id = Ice.InitializationData() + self.__ic = Ice.initialize(None, id) + + def destroy (self): + ''' + Destroys ROS Node and Ice Communicator if it is necessary. + + ''' + if self.__node: + rospy.signal_shutdown("Node Closed") + if self.__ic: + self.__ic.shutdown() + self.__ic.destroy() + + def getNode(self): + return self.__node + + def getIc(self): + return self.__ic + + def getConfig(self): + return self.config + + + def getCameraClient(self, name): + ''' + Returns a Camera client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getCameraClient(self, name) + + def getMotorsClient(self, name): + ''' + Returns a Motors client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getMotorsClient(self, name) + + def getPose3dClient(self, name): + ''' + Returns a Pose3D client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getPose3dClient(self, name) + + def getLaserClient(self, name): + ''' + Returns a Laser client with the configration indicated by the name + + @param name: name of the client in the config + + @type name: String + + ''' + return getLaserClient(self, name) + diff --git a/src/libs/comm_py/comm/ice/__init__.py b/src/libs/comm_py/comm/ice/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/libs/comm_py/comm/ice/cameraIceClient.py b/src/libs/comm_py/comm/ice/cameraIceClient.py new file mode 100644 index 000000000..15a7f61e4 --- /dev/null +++ b/src/libs/comm_py/comm/ice/cameraIceClient.py @@ -0,0 +1,178 @@ +# +# Copyright (C) 1997-2017 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Aitor Martinez Fernandez +# + +import traceback +import jderobot +import numpy as np +import threading +import Ice +from .threadSensor import ThreadSensor +from jderobotTypes import Image + + +class Camera: + ''' + Camera Connector. Recives image from Ice interface when you run update method. + ''' + + def __init__(self, jdrc, prefix): + ''' + Camera Contructor. + Exits When it receives a Exception diferent to Ice.ConnectionRefusedException + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + ''' + + self.lock = threading.Lock() + self.image = Image() + + try: + + ic = jdrc.getIc() + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + basecamera = ic.stringToProxy(proxyStr) + self.proxy = jderobot.CameraPrx.checkedCast(basecamera) + self.imgFormat = jdrc.getConfig().getProperty(prefix+".Format") + if not self.imgFormat: + self.imgFormat = "RGB8" + + self.update() + + if not self.proxy: + print ('Interface ' + prefix + ' not configured') + + except Ice.ConnectionRefusedException: + print(prefix + ': connection refused') + + except: + traceback.print_exc() + exit(-1) + + def update(self): + ''' + Updates Image. + ''' + if self.hasproxy(): + img = Image() + imageData = self.proxy.getImageData(self.imgFormat) + img.height = imageData.description.height + img.width = imageData.description.width + img.format = imageData.description.format + + img.data = np.frombuffer(imageData.pixelData, dtype=np.uint8) + img.data.shape = img.height, img.width, 3 + + img.timeStamp = imageData.timeStamp.seconds + imageData.timeStamp.useconds * 1e-9 + + + self.lock.acquire() + self.image = img + self.lock.release() + + def getImage(self): + ''' + Returns last Image. + + @return last JdeRobotTypes Image saved + + ''' + img = Image() + if self.hasproxy(): + self.lock.acquire() + img = self.image + self.lock.release() + return img + + def hasproxy (self): + ''' + Returns if proxy has ben created or not. + + @return if proxy has ben created or not (Boolean) + + ''' + return hasattr(self,"proxy") and self.proxy + + + + +class CameraIceClient: + ''' + Camera Ice Client. Recives image from Ice interface running camera update method in a thread. + ''' + def __init__(self,jdrc,prefix, start = False): + ''' + CameraIceClient Contructor. + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + @param start: indicates if start automatically the client + + @type jdrc: Comm Communicator + @type prefix: String + @type start: Boolean + ''' + self.camera = Camera(jdrc,prefix) + + self.kill_event = threading.Event() + self.thread = ThreadSensor(self.camera, self.kill_event) + #self.thread = ThreadSensor(self.camera) + self.thread.daemon = True + + if start: + self.start() + + + def start(self): + ''' + Starts the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.clear() + self.thread.start() + + + def stop(self): + ''' + Stops the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.set() + + def getImage(self): + ''' + Returns last Image. + + @return last JdeRobotTypes Image saved + + ''' + return self.camera.getImage() + + + def hasproxy (self): + ''' + Returns if proxy has ben created or not. + + @return if proxy has ben created or not (Boolean) + + ''' + return self.camera.hasproxy() diff --git a/src/libs/comm_py/comm/ice/laserIceClient.py b/src/libs/comm_py/comm/ice/laserIceClient.py new file mode 100644 index 000000000..0b7013531 --- /dev/null +++ b/src/libs/comm_py/comm/ice/laserIceClient.py @@ -0,0 +1,174 @@ +# +# Copyright (C) 1997-2016 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Aitor Martinez Fernandez +# + +import traceback +import jderobot +import threading +import Ice +from .threadSensor import ThreadSensor +from jderobotTypes import LaserData + + +class Laser: + ''' + Laser Connector. Recives LaserData from Ice interface when you run update method. + ''' + + def __init__(self, jdrc, prefix): + ''' + Laser Contructor. + Exits When it receives a Exception diferent to Ice.ConnectionRefusedException + + @param jdrc: Comm Communicator + @param prefix: prefix name of client in config file + + @type ic: Ice Communicator + @type prefix: String + ''' + self.lock = threading.Lock() + self.laser = LaserData() + + try: + ic = jdrc.getIc() + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + base = ic.stringToProxy(proxyStr) + self.proxy = jderobot.LaserPrx.checkedCast(base) + + self.update() + + if not self.proxy: + print ('Interface ' + prefix + ' not configured') + + except Ice.ConnectionRefusedException: + print(prefix + ': connection refused') + + except: + traceback.print_exc() + exit(-1) + + def update(self): + ''' + Updates LaserData. + ''' + if self.hasproxy(): + laserD = LaserData() + values = [] + data = self.proxy.getLaserData() + + #laserD.values = laser.distanceData + for i in range (data.numLaser): + values.append(data.distanceData[i] / 1000.0) + + laserD.maxAngle = data.maxAngle + laserD.minAngle = data.minAngle + laserD.maxRange = data.maxRange + laserD.minRange = data.minRange + laserD.values = values + + + self.lock.acquire() + self.laser = laserD + self.lock.release() + + def hasproxy (self): + ''' + Returns if proxy has ben created or not. + + @return if proxy has ben created or not (Boolean) + + ''' + + return hasattr(self,"proxy") and self.proxy + + def getLaserData(self): + ''' + Returns last LaserData. + + @return last JdeRobotTypes LaserData saved + + ''' + if self.hasproxy(): + self.lock.acquire() + laser = self.laser + self.lock.release() + return laser + + return None + + + + +class LaserIceClient: + ''' + Laser Ice Client. Recives LaserData from Ice interface running Laser update method in a thread. + ''' + def __init__(self,ic,prefix, start = False): + ''' + LaserIceClient Contructor. + + @param ic: Ice Communicator + @param prefix: prefix name of client in config file + @param start: indicates if start automatically the client + + @type ic: Ice Communicator + @type prefix: String + @type start: Boolean + ''' + self.laser = Laser(ic,prefix) + + self.kill_event = threading.Event() + self.thread = ThreadSensor(self.laser, self.kill_event) + self.thread.daemon = True + + if start: + self.start() + + + def start(self): + ''' + Starts the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.clear() + self.thread.start() + + def stop(self): + ''' + Stops the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.set() + + def getLaserData(self): + ''' + Returns last LaserData. + + @return last JdeRobotTypes LaserData saved + + ''' + return self.laser.getLaserData() + + def hasproxy (self): + ''' + Returns if proxy has ben created or not. + + @return if proxy has ben created or not (Boolean) + + ''' + return self.laser.hasproxy() diff --git a/src/libs/comm_py/comm/ice/motorsIceClient.py b/src/libs/comm_py/comm/ice/motorsIceClient.py new file mode 100644 index 000000000..f2ba33eb2 --- /dev/null +++ b/src/libs/comm_py/comm/ice/motorsIceClient.py @@ -0,0 +1,125 @@ +# +# Copyright (C) 1997-2017 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Aitor Martinez Fernandez +# + +import traceback +import jderobot +import threading +import Ice +from .threadSensor import ThreadSensor +from jderobotTypes import CMDVel + + +class MotorsIceClient: + + + ''' + Motors Contructor. + Exits When it receives a Exception diferent to Ice.ConnectionRefusedException + + @param jdrc: Comm Communicator + @param prefix: prefix name of client in config file + + @type ic: Ice Communicator + @type prefix: String + ''' + def __init__(self, jdrc, prefix): + self.lock = threading.Lock() + ic = jdrc.getIc() + + + maxWstr = jdrc.getConfig().getProperty(prefix+".maxW") + if maxWstr: + self.maxW = float(maxWstr) + else: + self.maxW = 0.5 + print (prefix+".maxW not provided, the default value is used: "+ repr(self.maxW)) + + + maxVstr = jdrc.getConfig().getProperty(prefix+".maxV") + if maxWstr: + self.maxV = float(maxVstr) + else: + self.maxV = 5 + print (prefix+".maxV not provided, the default value is used: "+ repr(self.maxV)) + + try: + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + base = ic.stringToProxy(proxyStr) + self.proxy = jderobot.MotorsPrx.checkedCast(base) + + + if not self.proxy: + print ('Interface ' + prefix + ' not configured') + + except Ice.ConnectionRefusedException: + print(prefix + ': connection refused') + + except: + traceback.print_exc() + exit(-1) + + + def start(self): + pass + def stop(self): + pass + + def sendVelocities(self, vel): + if self.hasproxy(): + self.lock.acquire() + self.proxy.setV(vel.vx) + self.proxy.setW(vel.az) + self.proxy.setL(vel.vy) + self.lock.release() + + def getMaxW(self): + return self.maxW + + def getMaxV(self): + return self.maxV + + def sendV(self, v): + self.sendVX(v) + + def sendL(self, l): + self.sendVY(l) + + def sendW(self, w): + self.sendAZ(w) + + def sendVX(self, vx): + if self.hasproxy(): + self.lock.acquire() + self.proxy.setV(vx) + self.lock.release() + + def sendVY(self, vy): + if self.hasproxy(): + self.lock.acquire() + self.proxy.setL(vy) + self.lock.release() + + def sendAZ(self, az): + if self.hasproxy(): + self.lock.acquire() + self.proxy.setW(az) + self.lock.release() + + def hasproxy (self): + return hasattr(self,"proxy") and self.proxy \ No newline at end of file diff --git a/src/libs/comm_py/comm/ice/pose3dIceClient.py b/src/libs/comm_py/comm/ice/pose3dIceClient.py new file mode 100644 index 000000000..256dc20c4 --- /dev/null +++ b/src/libs/comm_py/comm/ice/pose3dIceClient.py @@ -0,0 +1,231 @@ +# +# Copyright (C) 1997-2017 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Aitor Martinez Fernandez +# + +import traceback +import jderobot +import threading +import Ice +from .threadSensor import ThreadSensor +from math import asin, atan2, pi +from jderobotTypes import Pose3d + + +class Pose3D: + ''' + Pose3d Connector. Recives Pose3d from Ice interface when you run update method. + ''' + + def __init__(self, jdrc, prefix): + ''' + Pose3d Contructor. + Exits When it receives a Exception diferent to Ice.ConnectionRefusedException + + @param jdrc: Comm Communicator + @param prefix: prefix name of client in config file + + @type ic: Ice Communicator + @type prefix: String + ''' + self.lock = threading.Lock() + + self.pose = Pose3d() + + try: + ic = jdrc.getIc() + proxyStr = jdrc.getConfig().getProperty(prefix+".Proxy") + base = ic.stringToProxy(proxyStr) + self.proxy = jderobot.Pose3DPrx.checkedCast(base) + prop = ic.getProperties() + + self.update() + + if not self.proxy: + print ('Interface ' + prefix + ' not configured') + + except Ice.ConnectionRefusedException: + print(prefix + ': connection refused') + + except: + traceback.print_exc() + exit(-1) + + def update(self): + ''' + Updates Pose3d. + ''' + pos = Pose3d() + if self.hasproxy(): + pose = self.proxy.getPose3DData() + pos.yaw = self.quat2Yaw(pose.q0, pose.q1, pose.q2, pose.q3) + pos.pitch = self.quat2Pitch(pose.q0, pose.q1, pose.q2, pose.q3) + pos.roll = self.quat2Roll(pose.q0, pose.q1, pose.q2, pose.q3) + pos.x = pose.x + pos.y = pose.y + pos.z = pose.z + pos.h = pose.h + pos.q = [pose.q0, pose.q1, pose.q2, pose.q3] + + self.lock.acquire() + self.pose = pos + self.lock.release() + + def hasproxy (self): + ''' + Returns if proxy has ben created or not. + + @return if proxy has ben created or not (Boolean) + + ''' + return hasattr(self,"proxy") and self.proxy + + def getPose3d(self): + ''' + Returns last Pose3d. + + @return last JdeRobotTypes Pose3d saved + + ''' + self.lock.acquire() + pose = self.pose + self.lock.release() + return pose + + + def quat2Yaw(self, qw, qx, qy, qz): + ''' + Translates from Quaternion to Yaw. + + @param qw,qx,qy,qz: Quaternion values + + @type qw,qx,qy,qz: float + + @return Yaw value translated from Quaternion + + ''' + rotateZa0=2.0*(qx*qy + qw*qz) + rotateZa1=qw*qw + qx*qx - qy*qy - qz*qz + rotateZ=0.0 + if(rotateZa0 != 0.0 and rotateZa1 != 0.0): + rotateZ=atan2(rotateZa0,rotateZa1) + return rotateZ + + def quat2Pitch(self, qw, qx, qy, qz): + ''' + Translates from Quaternion to Pitch. + + @param qw,qx,qy,qz: Quaternion values + + @type qw,qx,qy,qz: float + + @return Pitch value translated from Quaternion + + ''' + rotateYa0=-2.0*(qx*qz - qw*qy) + rotateY=0.0 + if(rotateYa0 >= 1.0): + rotateY = pi/2.0 + elif(rotateYa0 <= -1.0): + rotateY = -pi/2.0 + else: + rotateY = asin(rotateYa0) + + return rotateY + + def quat2Roll (self, qw, qx, qy, qz): + ''' + Translates from Quaternion to Roll. + + @param qw,qx,qy,qz: Quaternion values + + @type qw,qx,qy,qz: float + + @return Roll value translated from Quaternion + + ''' + rotateXa0=2.0*(qy*qz + qw*qx) + rotateXa1=qw*qw - qx*qx - qy*qy + qz*qz + rotateX=0.0 + + if(rotateXa0 != 0.0 and rotateXa1 != 0.0): + rotateX=atan2(rotateXa0, rotateXa1) + return rotateX + + + + + +class Pose3dIceClient: + ''' + Pose3d Ice Client. Recives Pose3d from Ice interface running Pose3d update method in a thread. + ''' + def __init__(self,ic,prefix, start = False): + ''' + Pose3dIceClient Contructor. + + @param ic: Ice Communicator + @param prefix: prefix name of client in config file + @param start: indicates if start automatically the client + + @type ic: Ice Communicator + @type prefix: String + @type start: Boolean + ''' + self.pose3d = Pose3D(ic,prefix) + + self.kill_event = threading.Event() + self.thread = ThreadSensor(self.pose3d, self.kill_event) + self.thread.daemon = True + + if start: + self.start() + + + def start(self): + ''' + Starts the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.clear() + self.thread.start() + + + def stop(self): + ''' + Stops the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.set() + + def getPose3d(self): + ''' + Returns last Pose3d. + + @return last JdeRobotTypes Pose3d saved + + ''' + return self.pose3d.getPose3d() + + def hasproxy (self): + ''' + Returns if proxy has ben created or not. + + @return if proxy has ben created or not (Boolean) + + ''' + return self.pose3d.hasproxy() diff --git a/src/libs/comm_py/comm/ice/threadSensor.py b/src/libs/comm_py/comm/ice/threadSensor.py new file mode 100644 index 000000000..e30ece981 --- /dev/null +++ b/src/libs/comm_py/comm/ice/threadSensor.py @@ -0,0 +1,46 @@ +# +# Copyright (C) 1997-2016 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Alberto Martin Florido +# Aitor Martinez Fernandez +# +import threading +import time +from datetime import datetime + +time_cycle = 80 + + +class ThreadSensor(threading.Thread): + + def __init__(self, sensor, kill_event): + self.sensor = sensor + self.kill_event = kill_event + threading.Thread.__init__(self, args=kill_event) + + def run(self): + while (not self.kill_event.is_set()): + start_time = datetime.now() + + self.sensor.update() + + finish_Time = datetime.now() + + dt = finish_Time - start_time + ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds / 1000.0 + #print (ms) + if (ms < time_cycle): + time.sleep((time_cycle - ms) / 1000.0) diff --git a/src/libs/comm_py/comm/laserClient.py.only-ice.in b/src/libs/comm_py/comm/laserClient.py.only-ice.in new file mode 100644 index 000000000..4769be465 --- /dev/null +++ b/src/libs/comm_py/comm/laserClient.py.only-ice.in @@ -0,0 +1,75 @@ +import sys +import Ice +from .ice.laserIceClient import LaserIceClient + + +def __getLaserIceClient(jdrc, prefix): + ''' + Returns a Laser Ice Client. This function should never be used. Use getLaserClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Laser Ice Client + + ''' + print("Receiving " + prefix + " LaserData from ICE interfaces") + client = LaserIceClient(jdrc, prefix) + client.start() + return client + +def __getListenerLaser(jdrc, prefix): + ''' + Returns a Laser ROS Subscriber. This function should never be used. Use getLaserClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Laser ROS Subscriber + + ''' + print(prefix + ": ROS msg are diabled") + return None + +def __Laserdisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getLaserClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None + + ''' + print( prefix + " Disabled") + return None + +def getLaserClient (jdrc, prefix): + ''' + Returns a Laser Client. + + @param jdrc: Comm Communicator + @param name: name of client in config file + + @type jdrc: Comm Communicator + @type name: String + + @return None if Laser is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Laserdisabled, __getLaserIceClient, __getListenerLaser] + + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/comm_py/comm/laserClient.py.ros.in b/src/libs/comm_py/comm/laserClient.py.ros.in new file mode 100644 index 000000000..c6145f208 --- /dev/null +++ b/src/libs/comm_py/comm/laserClient.py.ros.in @@ -0,0 +1,84 @@ +import sys +import Ice +import rospy +from .ice.laserIceClient import LaserIceClient + +if (sys.version_info[0] == 2): + from .ros.listenerLaser import ListenerLaser + +def __getLaserIceClient(jdrc, prefix): + ''' + Returns a Laser Ice Client. This function should never be used. Use getLaserClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Laser Ice Client + + ''' + print("Receiving " + prefix + " LaserData from ICE interfaces") + client = LaserIceClient(jdrc, prefix) + client.start() + return client + +def __getListenerLaser(jdrc, prefix): + ''' + Returns a Laser ROS Subscriber. This function should never be used. Use getLaserClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Laser ROS Subscriber + + ''' + if (sys.version_info[0] == 2): + print("Receiving " + prefix + " LaserData from ROS messages") + topic = jdrc.getConfig().getProperty(prefix+".Topic") + client = ListenerLaser(topic) + return client + else: + print(prefix + ": ROS msg are diabled for python "+ sys.version_info[0]) + return None + +def __Laserdisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getLaserClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None + + ''' + print( prefix + " Disabled") + return None + +def getLaserClient (jdrc, prefix): + ''' + Returns a Laser Client. + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type name: String + + @return None if Laser is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Laserdisabled, __getLaserIceClient, __getListenerLaser] + + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/comm_py/comm/motorsClient.py.only-ice.in b/src/libs/comm_py/comm/motorsClient.py.only-ice.in new file mode 100644 index 000000000..e27632584 --- /dev/null +++ b/src/libs/comm_py/comm/motorsClient.py.only-ice.in @@ -0,0 +1,79 @@ +import sys +import Ice +from .ice.motorsIceClient import MotorsIceClient + + + +def __getMotorsIceClient(jdrc, prefix): + ''' + Returns a Motors Ice Client. This function should never be used. Use getMotorsClient instead of this + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Motors Ice Client + + ''' + print("Publishing "+ prefix +" with ICE interfaces") + client = MotorsIceClient(jdrc, prefix) + client.start() + return client + +def __getPublisherMotors(jdrc, prefix): + ''' + Returns a Motors ROS Publisher. This function should never be used. Use getMotorsClient instead of this + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Motors ROS Publisher + + ''' + + print(prefix + ": ROS msg are diabled") + return None + +def __Motorsdisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getMotorsClient instead of this + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None + + ''' + print(prefix + " Disabled") + return None + +def getMotorsClient (jdrc, prefix): + ''' + Returns a Motors Client. + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + @param node: ROS node + + @type jdrc: Comm Communicator + @type prefix: String + @type node: ROS node + + @return None if Motors is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Motorsdisabled, __getMotorsIceClient, __getPublisherMotors] + + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/comm_py/comm/motorsClient.py.ros.in b/src/libs/comm_py/comm/motorsClient.py.ros.in new file mode 100644 index 000000000..58859a2bd --- /dev/null +++ b/src/libs/comm_py/comm/motorsClient.py.ros.in @@ -0,0 +1,99 @@ +import sys +import Ice +import rospy +from .ice.motorsIceClient import MotorsIceClient + +if (sys.version_info[0] == 2): + from .ros.publisherMotors import PublisherMotors + +def __getMotorsIceClient(jdrc, prefix): + ''' + Returns a Motors Ice Client. This function should never be used. Use getMotorsClient instead of this + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Motors Ice Client + + ''' + print("Publishing "+ prefix +" with ICE interfaces") + client = MotorsIceClient(jdrc, prefix) + client.start() + return client + +def __getPublisherMotors(jdrc, prefix): + ''' + Returns a Motors ROS Publisher. This function should never be used. Use getMotorsClient instead of this + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Motors ROS Publisher + + ''' + if (sys.version_info[0] == 2): + print("Publishing "+ prefix + " with ROS messages") + topic = jdrc.getConfig().getProperty(prefix+".Topic") + + maxW = jdrc.getConfig().getProperty(prefix+".maxW") + if not maxW: + maxW = 0.5 + print (prefix+".maxW not provided, the default value is used: "+ repr(maxW)) + + + maxV = jdrc.getConfig().getProperty(prefix+".maxV") + if not maxV: + maxV = 5 + print (prefix+".maxV not provided, the default value is used: "+ repr(maxV)) + + + client = PublisherMotors(topic, maxV, maxW) + return client + else: + print(prefix + ": ROS msg are diabled for python "+ sys.version_info[0]) + return None + +def __Motorsdisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getMotorsClient instead of this + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None + + ''' + print(prefix + " Disabled") + return None + +def getMotorsClient (jdrc, prefix): + ''' + Returns a Motors Client. + + @param jdrc: Comm Communicator + @param prefix: Name of client in config file + @param node: ROS node + + @type jdrc: Comm Communicator + @type prefix: String + @type node: ROS node + + @return None if Motors is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Motorsdisabled, __getMotorsIceClient, __getPublisherMotors] + + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/comm_py/comm/pose3dClient.py.only-ice.in b/src/libs/comm_py/comm/pose3dClient.py.only-ice.in new file mode 100644 index 000000000..dc66d9326 --- /dev/null +++ b/src/libs/comm_py/comm/pose3dClient.py.only-ice.in @@ -0,0 +1,76 @@ +import sys +import Ice +from .ice.pose3dIceClient import Pose3dIceClient + + +def __getPoseIceClient(jdrc, prefix): + ''' + Returns a Pose3D Ice Client. This function should never be used. Use getPose3dClient instead of this + + @@param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Pose3D Ice Client + + ''' + print("Receiving " + prefix + " from ICE interfaces") + client = Pose3dIceClient(jdrc, prefix) + client.start() + return client + +def __getListenerPose(jdrc, prefix): + ''' + Returns a Pose3D ROS Subscriber. This function should never be used. Use getPose3dClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Pose3D ROS Subscriber + + ''' + print(prefix + ": ROS msg are diabled") + return None + + +def __Posedisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getPose3dClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None + + ''' + print(prefix + " Disabled") + return None + +def getPose3dClient (jdrc, prefix): + ''' + Returns a Pose3D Client. + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None if pose3d is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Posedisabled, __getPoseIceClient, __getListenerPose] + + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/comm_py/comm/pose3dClient.py.ros.in b/src/libs/comm_py/comm/pose3dClient.py.ros.in new file mode 100644 index 000000000..3ed047f00 --- /dev/null +++ b/src/libs/comm_py/comm/pose3dClient.py.ros.in @@ -0,0 +1,87 @@ +import sys +import Ice +import rospy +from .ice.pose3dIceClient import Pose3dIceClient + +if (sys.version_info[0] == 2): + from .ros.listenerPose3d import ListenerPose3d + + + +def __getPoseIceClient(jdrc, prefix): + ''' + Returns a Pose3D Ice Client. This function should never be used. Use getPose3dClient instead of this + + @@param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Pose3D Ice Client + + ''' + print("Receiving " + prefix + " from ICE interfaces") + client = Pose3dIceClient(jdrc, prefix) + client.start() + return client + +def __getListenerPose(jdrc, prefix): + ''' + Returns a Pose3D ROS Subscriber. This function should never be used. Use getPose3dClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return Pose3D ROS Subscriber + + ''' + if (sys.version_info[0] == 2): + print("Receiving " + prefix + " from ROS messages") + topic = jdrc.getConfig().getProperty(prefix+".Topic") + client = ListenerPose3d(topic) + return client + else: + print(prefix + ": ROS msg are diabled for python "+ sys.version_info[0]) + return None + + +def __Posedisabled(jdrc, prefix): + ''' + Prints a warning that the client is disabled. This function should never be used. Use getPose3dClient instead of this + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None + + ''' + print(prefix + " Disabled") + return None + +def getPose3dClient (jdrc, prefix): + ''' + Returns a Pose3D Client. + + @param jdrc: Comm Communicator + @param prefix: name of client in config file + + @type jdrc: Comm Communicator + @type prefix: String + + @return None if pose3d is disabled + + ''' + server = jdrc.getConfig().getProperty(prefix+".Server") + if not server: + server=0 + + cons = [__Posedisabled, __getPoseIceClient, __getListenerPose] + + return cons[server](jdrc, prefix) \ No newline at end of file diff --git a/src/libs/comm_py/comm/ros/__init__.py b/src/libs/comm_py/comm/ros/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/libs/comm_py/comm/ros/listenerCamera.py b/src/libs/comm_py/comm/ros/listenerCamera.py new file mode 100644 index 000000000..a9376dedb --- /dev/null +++ b/src/libs/comm_py/comm/ros/listenerCamera.py @@ -0,0 +1,107 @@ +import rospy +from sensor_msgs.msg import Image as ImageROS +import threading +from math import pi as PI +from jderobotTypes import Image +import cv2 +from cv_bridge import CvBridge, CvBridgeError + + + + +def imageMsg2Image(img, bridge): + ''' + Translates from ROS Image to JderobotTypes Image. + + @param img: ROS Image to translate + @param bridge: bridge to do translation + + @type img: sensor_msgs.msg.Image + @type brige: CvBridge + + @return a JderobotTypes.Image translated from img + + ''' + image = Image() + + image.width = img.width + image.height = img.height + image.format = "RGB8" + image.timeStamp = img.header.stamp.secs + (img.header.stamp.nsecs *1e-9) + cv_image = bridge.imgmsg_to_cv2(img, "rgb8") + image.data = cv_image + return image + +class ListenerCamera: + ''' + ROS Camera (Image) Subscriber. Camera Client to Receive Images from ROS nodes. + ''' + def __init__(self, topic): + ''' + ListenerCamera Constructor. + + @param topic: ROS topic to subscribe + + @type topic: String + + ''' + self.topic = topic + self.data = Image() + self.sub = None + self.lock = threading.Lock() + + self.bridge = CvBridge() + self.start() + + def __callback (self, img): + ''' + Callback function to receive and save Images. + + @param img: ROS Image received + + @type img: sensor_msgs.msg.Image + + ''' + image = imageMsg2Image(img, self.bridge) + + self.lock.acquire() + self.data = image + self.lock.release() + + def stop(self): + ''' + Stops (Unregisters) the client. + + ''' + self.sub.unregister() + + def start (self): + ''' + Starts (Subscribes) the client. + + ''' + self.sub = rospy.Subscriber(self.topic, ImageROS, self.__callback) + + def getImage(self): + ''' + Returns last Image. + + @return last JdeRobotTypes Image saved + + ''' + self.lock.acquire() + image = self.data + self.lock.release() + + return image + + def hasproxy (self): + ''' + Returns if Subscriber has ben created or not. + + @return if Subscriber has ben created or not (Boolean) + + ''' + return hasattr(self,"sub") and self.sub + + diff --git a/src/libs/comm_py/comm/ros/listenerLaser.py b/src/libs/comm_py/comm/ros/listenerLaser.py new file mode 100644 index 000000000..363e330c8 --- /dev/null +++ b/src/libs/comm_py/comm/ros/listenerLaser.py @@ -0,0 +1,99 @@ +import rospy +from sensor_msgs.msg import LaserScan +import threading +from math import pi as PI +from jderobotTypes import LaserData + + + +def laserScan2LaserData(scan): + ''' + Translates from ROS LaserScan to JderobotTypes LaserData. + + @param scan: ROS LaserScan to translate + + @type scan: LaserScan + + @return a LaserData translated from scan + + ''' + laser = LaserData() + laser.values = scan.ranges + ''' + ROS Angle Map JdeRobot Angle Map + 0 PI/2 + | | + | | + PI/2 --------- -PI/2 PI --------- 0 + | | + | | + ''' + laser.minAngle = scan.angle_min + PI/2 + laser.maxAngle = scan.angle_max + PI/2 + laser.maxRange = scan.range_max + laser.minRange = scan.range_min + laser.timeStamp = scan.header.stamp.secs + (scan.header.stamp.nsecs *1e-9) + return laser + +class ListenerLaser: + ''' + ROS Laser Subscriber. Laser Client to Receive Laser Scans from ROS nodes. + ''' + def __init__(self, topic): + ''' + ListenerLaser Constructor. + + @param topic: ROS topic to subscribe + + @type topic: String + + ''' + self.topic = topic + self.data = LaserData() + self.sub = None + self.lock = threading.Lock() + self.start() + + def __callback (self, scan): + ''' + Callback function to receive and save Laser Scans. + + @param scan: ROS LaserScan received + + @type scan: LaserScan + + ''' + laser = laserScan2LaserData(scan) + + self.lock.acquire() + self.data = laser + self.lock.release() + + def stop(self): + ''' + Stops (Unregisters) the client. + + ''' + self.sub.unregister() + + def start (self): + ''' + Starts (Subscribes) the client. + + ''' + self.sub = rospy.Subscriber(self.topic, LaserScan, self.__callback) + + def getLaserData(self): + ''' + Returns last LaserData. + + @return last JdeRobotTypes LaserData saved + + ''' + self.lock.acquire() + laser = self.data + self.lock.release() + + return laser + + diff --git a/src/libs/comm_py/comm/ros/listenerPose3d.py b/src/libs/comm_py/comm/ros/listenerPose3d.py new file mode 100644 index 000000000..89fa69f3f --- /dev/null +++ b/src/libs/comm_py/comm/ros/listenerPose3d.py @@ -0,0 +1,156 @@ +import rospy +from nav_msgs.msg import Odometry +import threading +from math import asin, atan2, pi +from jderobotTypes import Pose3d + +def quat2Yaw(qw, qx, qy, qz): + ''' + Translates from Quaternion to Yaw. + + @param qw,qx,qy,qz: Quaternion values + + @type qw,qx,qy,qz: float + + @return Yaw value translated from Quaternion + + ''' + rotateZa0=2.0*(qx*qy + qw*qz) + rotateZa1=qw*qw + qx*qx - qy*qy - qz*qz + rotateZ=0.0 + if(rotateZa0 != 0.0 and rotateZa1 != 0.0): + rotateZ=atan2(rotateZa0,rotateZa1) + return rotateZ + +def quat2Pitch(qw, qx, qy, qz): + ''' + Translates from Quaternion to Pitch. + + @param qw,qx,qy,qz: Quaternion values + + @type qw,qx,qy,qz: float + + @return Pitch value translated from Quaternion + + ''' + + rotateYa0=-2.0*(qx*qz - qw*qy) + rotateY=0.0 + if(rotateYa0 >= 1.0): + rotateY = pi/2.0 + elif(rotateYa0 <= -1.0): + rotateY = -pi/2.0 + else: + rotateY = asin(rotateYa0) + + return rotateY + +def quat2Roll (qw, qx, qy, qz): + ''' + Translates from Quaternion to Roll. + + @param qw,qx,qy,qz: Quaternion values + + @type qw,qx,qy,qz: float + + @return Roll value translated from Quaternion + + ''' + rotateXa0=2.0*(qy*qz + qw*qx) + rotateXa1=qw*qw - qx*qx - qy*qy + qz*qz + rotateX=0.0 + + if(rotateXa0 != 0.0 and rotateXa1 != 0.0): + rotateX=atan2(rotateXa0, rotateXa1) + return rotateX + + +def odometry2Pose3D(odom): + ''' + Translates from ROS Odometry to JderobotTypes Pose3d. + + @param odom: ROS Odometry to translate + + @type odom: Odometry + + @return a Pose3d translated from odom + + ''' + pose = Pose3d() + ori = odom.pose.pose.orientation + + pose.x = odom.pose.pose.position.x + pose.y = odom.pose.pose.position.y + pose.z = odom.pose.pose.position.z + #pose.h = odom.pose.pose.position.h + pose.yaw = quat2Yaw(ori.w, ori.x, ori.y, ori.z) + pose.pitch = quat2Pitch(ori.w, ori.x, ori.y, ori.z) + pose.roll = quat2Roll(ori.w, ori.x, ori.y, ori.z) + pose.q = [ori.w, ori.x, ori.y, ori.z] + pose.timeStamp = odom.header.stamp.secs + (odom.header.stamp.nsecs *1e-9) + + return pose + + +class ListenerPose3d: + ''' + ROS Pose3D Subscriber. Pose3D Client to Receive pose3d from ROS nodes. + ''' + def __init__(self, topic): + ''' + ListenerPose3d Constructor. + + @param topic: ROS topic to subscribe + + @type topic: String + + ''' + self.topic = topic + self.data = Pose3d() + self.sub = None + self.lock = threading.Lock() + self.start() + + def __callback (self, odom): + ''' + Callback function to receive and save Pose3d. + + @param odom: ROS Odometry received + + @type odom: Odometry + + ''' + pose = odometry2Pose3D(odom) + + self.lock.acquire() + self.data = pose + self.lock.release() + + def stop(self): + ''' + Stops (Unregisters) the client. + + ''' + self.sub.unregister() + + def start (self): + ''' + Starts (Subscribes) the client. + + ''' + self.sub = rospy.Subscriber(self.topic, Odometry, self.__callback) + + def getPose3d(self): + ''' + Returns last Pose3d. + + @return last JdeRobotTypes Pose3d saved + + ''' + self.lock.acquire() + pose = self.data + self.lock.release() + + return pose + + diff --git a/src/libs/comm_py/comm/ros/publisherMotors.py b/src/libs/comm_py/comm/ros/publisherMotors.py new file mode 100644 index 000000000..345e42f5e --- /dev/null +++ b/src/libs/comm_py/comm/ros/publisherMotors.py @@ -0,0 +1,177 @@ +import rospy +from geometry_msgs.msg import Twist +import threading +from math import pi as PI +from jderobotTypes import CMDVel +from .threadPublisher import ThreadPublisher + + + +def cmdvel2Twist(vel): + ''' + Translates from JderobotTypes CMDVel to ROS Twist. + + @param vel: JderobotTypes CMDVel to translate + + @type img: JdeRobotTypes.CMDVel + + @return a Twist translated from vel + + ''' + tw = Twist() + tw.linear.x = vel.vx + tw.linear.y = vel.vy + tw.linear.z = vel.vz + tw.angular.x = vel.ax + tw.angular.y = vel.ay + tw.angular.z = vel.az + + return tw + +class PublisherMotors: + ''' + ROS Motors Publisher. Motors Client to Send CMDVel to ROS nodes. + ''' + def __init__(self, topic, maxV, maxW): + ''' + ListenerMotors Constructor. + + @param topic: ROS topic to publish + + @type topic: String + + ''' + self.maxW = maxW + self.maxV = maxV + + self.topic = topic + self.data = CMDVel() + self.pub = self.pub = rospy.Publisher(self.topic, Twist, queue_size=1) + self.lock = threading.Lock() + + self.kill_event = threading.Event() + self.thread = ThreadPublisher(self, self.kill_event) + + self.thread.daemon = True + self.start() + + def publish (self): + ''' + Function to publish cmdvel. + ''' + self.lock.acquire() + tw = cmdvel2Twist(self.data) + self.lock.release() + self.pub.publish(tw) + + def stop(self): + ''' + Stops (Unregisters) the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.set() + self.pub.unregister() + + def start (self): + ''' + Starts (Subscribes) the client. If client is stopped you can not start again, Threading.Thread raised error + + ''' + self.kill_event.clear() + self.thread.start() + + + + def getMaxW(self): + return self.maxW + + def getMaxV(self): + return self.maxV + + + def sendVelocities(self, vel): + ''' + Sends CMDVel. + + @param vel: CMDVel to publish + + @type vel: CMDVel + + ''' + self.lock.acquire() + self.data = vel + self.lock.release() + + def sendV(self, v): + ''' + Sends V velocity. uses self.sendVX + + @param v: V velocity + + @type v: float + + ''' + self.sendVX(v) + + def sendL(self, l): + ''' + Sends L velocity. uses self.sendVY + + @param l: L velocity + + @type l: float + + ''' + self.sendVY(l) + + def sendW(self, w): + ''' + Sends W velocity. uses self.sendAZ + + @param w: W velocity + + @type w: float + + ''' + self.sendAZ(w) + + def sendVX(self, vx): + ''' + Sends VX velocity. + + @param vx: VX velocity + + @type vx: float + + ''' + self.lock.acquire() + self.data.vx = vx + self.lock.release() + + def sendVY(self, vy): + ''' + Sends VY velocity. + + @param vy: VY velocity + + @type vy: float + + ''' + self.lock.acquire() + self.data.vy = vy + self.lock.release() + + def sendAZ(self, az): + ''' + Sends AZ velocity. + + @param az: AZ velocity + + @type az: float + + ''' + self.lock.acquire() + self.data.vz = vz + self.lock.release() + + diff --git a/src/libs/comm_py/comm/ros/threadPublisher.py b/src/libs/comm_py/comm/ros/threadPublisher.py new file mode 100644 index 000000000..69aa0ad48 --- /dev/null +++ b/src/libs/comm_py/comm/ros/threadPublisher.py @@ -0,0 +1,46 @@ +# +# Copyright (C) 1997-2016 JDE Developers Team +# +# 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 http://www.gnu.org/licenses/. +# Authors : +# Alberto Martin Florido +# Aitor Martinez Fernandez +# +import threading +import time +from datetime import datetime + +time_cycle = 80 + + +class ThreadPublisher(threading.Thread): + + def __init__(self, pub, kill_event): + self.pub = pub + self.kill_event = kill_event + threading.Thread.__init__(self, args=kill_event) + + def run(self): + while (not self.kill_event.is_set()): + start_time = datetime.now() + + self.pub.publish() + + finish_Time = datetime.now() + + dt = finish_Time - start_time + ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds / 1000.0 + #print (ms) + if (ms < time_cycle): + time.sleep((time_cycle - ms) / 1000.0) \ No newline at end of file diff --git a/src/libs/comm_py/test.yml b/src/libs/comm_py/test.yml new file mode 100644 index 000000000..e22b1cb39 --- /dev/null +++ b/src/libs/comm_py/test.yml @@ -0,0 +1,38 @@ +Test: + Motors: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Motors:default -h localhost -p 9001" + Topic: "/cmd_vel_mux/input/teleop" + Name: testMotors + maxV: 3 + maxW: 0.7 + + Camera1: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraL:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera1 + + Camera2: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "CameraR:default -h localhost -p 9001" + Format: RGB8 + Topic: "/camera/rgb/image_raw" + Name: testCamera2 + + Pose3D: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Pose3D:default -h localhost -p 9001" + Topic: "/odom" + Name: testPose3d + + Laser: + Server: 1 # 0 -> Deactivate, 1 -> Ice , 2 -> ROS + Proxy: "Laser:default -h localhost -p 9001" + Topic: "/scan" + Name: testLaser + + Vmax: 3 + Wmax: 0.7 + NodeName: JdeRobotCommTest \ No newline at end of file diff --git a/src/libs/comm_py/testCamera.py b/src/libs/comm_py/testCamera.py new file mode 100755 index 000000000..dece71e67 --- /dev/null +++ b/src/libs/comm_py/testCamera.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python2 +import config +import comm +import sys +import time +import signal + +from jderobotTypes import Image + + + + +if __name__ == '__main__': + + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg, "Test") + + client = jdrc.getCameraClient("Test.Camera1") + + for i in range (10): + #print("client1", end=":") + image = client.getImage() + print(image) + time.sleep(1) + + client.stop() + + + jdrc.destroy() + + + + + + + + + diff --git a/src/libs/comm_py/testLaser.py b/src/libs/comm_py/testLaser.py new file mode 100755 index 000000000..75de3f623 --- /dev/null +++ b/src/libs/comm_py/testLaser.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python2 +import config +import comm +import sys +import time +import signal + +from jderobotTypes import LaserData + + + + +if __name__ == '__main__': + + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg, "Test") + + client = jdrc.getLaserClient("Test.Laser") + client2 = jdrc.getLaserClient("Test.Laser") + + for i in range (10): + #print("client1", end=":") + laser = client.getLaserData() + #print(laser) + time.sleep(1) + + + for i in range (10): + laser = client2.getLaserData() + print(laser) + time.sleep(1) + + jdrc.destroy() + + + + + + + + + diff --git a/src/libs/comm_py/testMotors.py b/src/libs/comm_py/testMotors.py new file mode 100644 index 000000000..1b9b554c7 --- /dev/null +++ b/src/libs/comm_py/testMotors.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import config +import comm +import sys +import time +import signal + +from jderobotTypes import CMDVel + + + + +if __name__ == '__main__': + + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg, "Test") + + vel = CMDVel() + vel.vx = 1 + vel.az = 0.1 + + client = jdrc.getMotorsClient("Test.Motors") + for i in range (10): + client.sendVelocities(vel) + time.sleep(1) + + jdrc.destroy() \ No newline at end of file diff --git a/src/libs/comm_py/testPose.py b/src/libs/comm_py/testPose.py new file mode 100644 index 000000000..d2171a9fe --- /dev/null +++ b/src/libs/comm_py/testPose.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +import config +import comm +import sys +import time +import signal + +from jderobotTypes import Pose3d + + + + +if __name__ == '__main__': + + cfg = config.load(sys.argv[1]) + jdrc= comm.init(cfg, "Test") + + client = jdrc.getPose3dClient("Test.Pose3D") + + for i in range (10): + #print("client1", end=":") + laser = client.getPose3d() + print(laser) + time.sleep(1) + + jdrc.destroy() \ No newline at end of file From fc940610ac030985079730823e79c0a57ff1ed7d Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 4 Oct 2017 08:47:01 +0200 Subject: [PATCH 13/14] updated config licenses --- src/libs/config_cpp/LICENSE | 18 - src/libs/config_cpp/README.md | 9 - src/libs/config_py/LICENSE | 675 ---------------------------------- 3 files changed, 702 deletions(-) delete mode 100644 src/libs/config_cpp/LICENSE delete mode 100644 src/libs/config_cpp/README.md delete mode 100644 src/libs/config_py/LICENSE diff --git a/src/libs/config_cpp/LICENSE b/src/libs/config_cpp/LICENSE deleted file mode 100644 index cc37edd33..000000000 --- a/src/libs/config_cpp/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 1997-2015 JDE Developers Team - * - * 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 http://www.gnu.org/licenses/. - * Authors : - * Victor Arribas Raigadas <.varribas.urjc@gmail.com> - */ diff --git a/src/libs/config_cpp/README.md b/src/libs/config_cpp/README.md deleted file mode 100644 index e417bf81e..000000000 --- a/src/libs/config_cpp/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# libEasyIceConfig -***A library to tame Ice.Config*** - - -## Expected usage -`#include ` -Then just replace: - * **Ice::initialize** ---> **EasyIce::initialize** - * **Ice::createProperties** ---> **EasyIce::createProperties** diff --git a/src/libs/config_py/LICENSE b/src/libs/config_py/LICENSE deleted file mode 100644 index 733c07236..000000000 --- a/src/libs/config_py/LICENSE +++ /dev/null @@ -1,675 +0,0 @@ - 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. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - 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: - - {project} Copyright (C) {year} {fullname} - 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 -. - From 29fc3503f35436db1363ce878f436b56d5498677 Mon Sep 17 00:00:00 2001 From: Aitor Martinez Date: Wed, 4 Oct 2017 13:08:14 +0200 Subject: [PATCH 14/14] solved bug in cameraclientRos of comm --- src/libs/comm_py/comm/cameraClient.py.ros.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/comm_py/comm/cameraClient.py.ros.in b/src/libs/comm_py/comm/cameraClient.py.ros.in index 4d8f913d8..7f84d847b 100644 --- a/src/libs/comm_py/comm/cameraClient.py.ros.in +++ b/src/libs/comm_py/comm/cameraClient.py.ros.in @@ -39,7 +39,7 @@ def __getListenerCamera(jdrc, prefix): ''' if (sys.version_info[0] == 2): print("Receiving " + prefix + " Image from ROS messages") - topic = jdrc.getConfig().getProperty(prefix+".topic") + topic = jdrc.getConfig().getProperty(prefix+".Topic") client = ListenerCamera(topic) return client else: