rock-core / tools-orocosrb

Rock's low-level component control library in Ruby
0 stars 12 forks source link

Ruby 3.0 #151

Open pierrewillenbrockdfki opened 1 year ago

pierrewillenbrockdfki commented 1 year ago

The change from potentially converting the last hash in the argument list to keyword arguments to not doing that at all breaks some pieces of orocos.rb. This becomes visible when trying to pass keyword arguments through the new method of the TaskContext and NameServer, and when calling the get method of the ruby side of the nameserver.

The exact errors are:

/home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/ruby_tasks/task_context.rb:61:in `initialize': wrong number of arguments (given 2, expected 1) (ArgumentError)
        from /home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/ruby_tasks/task_context.rb:45:in `new'
        from /home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/ruby_tasks/task_context.rb:45:in `new'
        from /home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/base.rb:304:in `initialize'
        from /home/pierre/autoproj-dev/workspace/base/scripts/lib/rock/bundles.rb:440:in `initialize'
        from /home/pierre/autoproj-dev/workspace/gui/vizkit/bin/rock-display:65:in `<main>'

when starting rock-display

/home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/name_service.rb:606:in `get': wrong number of arguments (given 2, expected 0..1) (ArgumentError)
        from /home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/async/name_service.rb:332:in `get'
        from /home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/name_service.rb:317:in `block in get'
        from /home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/name_service.rb:314:in `each'
        from /home/pierre/autoproj-dev/workspace/tools/orocos.rb/lib/orocos/name_service.rb:314:in `get'
        from /home/pierre/autoproj-dev/workspace/tools/utilrb/lib/utilrb/thread_pool.rb:444:in `sync'
        from /home/pierre/autoproj-dev/workspace/tools/utilrb/lib/utilrb/thread_pool.rb:191:in `execute'
        from /home/pierre/autoproj-dev/workspace/tools/utilrb/lib/utilrb/thread_pool.rb:594:in `block in spawn_thread'
        from /home/pierre/autoproj-dev/workspace/tools/utilrb/lib/utilrb/event_loop.rb:623:in `step'
        from /usr/lib/ruby/3.0.0/forwardable.rb:238:in `step'
        from /home/pierre/autoproj-dev/workspace/gui/vizkit/lib/vizkit/vizkit.rb:142:in `block in exec'
        from /home/pierre/.local/share/autoproj/gems/ruby/3.0.0/bundler/gems/rock-qtbindings-9f5d2abc9a54/lib/Qt/qtruby4.rb:2470:in `invoke'
        from /home/pierre/.local/share/autoproj/gems/ruby/3.0.0/bundler/gems/rock-qtbindings-9f5d2abc9a54/lib/Qt/qtruby4.rb:479:in `qt_metacall'
        from /home/pierre/.local/share/autoproj/gems/ruby/3.0.0/bundler/gems/rock-qtbindings-9f5d2abc9a54/lib/Qt/qtruby4.rb:479:in `method_missing'
        from /home/pierre/.local/share/autoproj/gems/ruby/3.0.0/bundler/gems/rock-qtbindings-9f5d2abc9a54/lib/Qt/qtruby4.rb:479:in `exec'
        from /home/pierre/autoproj-dev/workspace/gui/vizkit/lib/vizkit/vizkit.rb:146:in `exec'
        from /home/pierre/autoproj-dev/workspace/gui/vizkit/bin/rock-display:108:in `<main>'

when trying to create a vizkit3d widget

Compare also two commits that work around the issues: https://github.com/rock-core/tools-orocosrb/compare/master...pierrewillenbrockdfki:tools-orocosrb:master

On the bright side: the qt4 rock-display works on ubuntu 22.04, with this and the change to the qtbindings.

@doudou i did not want to do a PR with this because i barely have an idea what is going on here, and the changeset above may or may not be appropriate. It working may also be a fluke. Also, no idea if that is actually working with ruby 2.7 or before, i only tried with ruby 3.0.

pierrewillenbrockdfki commented 10 months ago

We made a ruby run-script somewhat work, result for orocos.rb can be found https://github.com/pierrewillenbrockdfki/tools-orocosrb/tree/fix-ruby3

We managed to get into the block passed to Orocos.run, find and start configuring tasks, where things stopped working for issues with the tasks.

Similar changes were needed for drivers/orogen/transformer/rock/runtime.rb and base/scripts/lib/rock/bundles.rb that i did not push anywhere. I can do that if there is interest.