git-afsantos / haros_tutorials

Example code for a fictitious ROS robot to try out HAROS
MIT License
6 stars 3 forks source link

Question: Use haros to list topics, services and parameters from py source code #8

Open thetaleofnarutouzumaki opened 3 years ago

thetaleofnarutouzumaki commented 3 years ago

Hi,

I am trying to parse a python ros node to get the list of topics, services and parameters. It's finding a bit difficult for me. Can someone help with this use case? I've tried to add a launch file with the node and add the configuration as below.

%YAML 1.1
---
packages:
    - lgsvl_tools
configurations:
    sim_connect:
        launch:
            - lgsvl_tools/launch/sim_connect.launch
        user_data:
            haros_plugin_pyflwor:
                - name: Query 6 - One Publisher Per Topic
                  details: "Found {n} topics with multiple publishers - {entities}"
                  query: "topics[len(self.publishers) > 1]"

Command

python3 haros-runner.py full -p ../../packages.yaml -n

Logs

[HAROS] Running setup operations...
[HAROS] Loading common definitions...
[HAROS] Loading plugins...
  > Loaded haros_plugin_cccc
  > Loaded haros_plugin_ccd
  > Loaded haros_plugin_cppcheck
  > Loaded haros_plugin_cpplint
  > Loaded haros_plugin_lizard
  > Loaded haros_plugin_mi_calculator
  > Loaded haros_plugin_pyflwor
  > Loaded haros_plugin_pylint
  > Loaded haros_plugin_radon
[HAROS] Reading project and indexing source code...
  > Parsing nodes might take some time.
WARNING:haros.extractor:C++ AST parser not found.
[HAROS] Running analysis...
ERROR:haros.analysis_manager:Plugin haros_plugin_radon ran into an error.
[HAROS] Saving analysis results...
[HAROS] Serving visualisation at localhost:8080

Result is this:

image

git-afsantos commented 3 years ago

Hello, Mithun.

Unfortunately, Python source code was never fully supported. I (the author and maintainer) have only implemented support for C++. The Python parser was an external contribution. But this does not mean that it won't work in your case.

I am going to run some tests on my side and let you know more.

Meanwhile, we can go through some basic pitfalls, to make sure everything is set up correctly.

  1. Is the source code available, for the nodes you want to analyse, or are the packages installed from binaries?
  2. Is your environment set up correctly? If you run rospack find MY_PACKAGE, does it return a path to the source code?
  3. Are you running the latest version of HAROS? I see you are running from source, so it is likely the case.
  4. Let's add a few options to your command and see if the result is the same. Add --ws /path/to/catkin/workspace and --no-cache. Same output?

If all else fails, feel free to run the analysis again in debug mode.

python3 haros-runner.py --debug full ...

You will find a ~/.haros/log.txt file that you can share with me, so I can try to pinpoint the problem.

git-afsantos commented 3 years ago

After running a few tests on a minimal Python package, I can confirm that it is not working. I will see if I can fix some of the issues and release an update.

This does not invalidate my previous comment. You can still go through those steps/questions and let me know further details.

git-afsantos commented 3 years ago

Hi @Balussery I went on a bug hunt and fixed multiple issues that were affecting Python parsing. Please update to HAROS v3.10.18 and bonsai v0.6.8.

Both are available via pip.