RobotWebTools / rosbridge_suite

Server Implementations of the rosbridge v2 Protocol
https://robotwebtools.github.io
BSD 3-Clause "New" or "Revised" License
866 stars 506 forks source link

when send action goal , gets an error and tried to find action interface in the msg packages #903

Closed Cra2yQi closed 5 months ago

Cra2yQi commented 5 months ago

Description

Steps To Reproduce

when i use roslibjs to send a action goal ,rosbridge-suit gets an error and tried to find action interface in the msg packages.

action(serverName, actionName, argument) {
    const rosAction = new ROSLIB.ActionClient({
      ros: this.ros,
      serverName: serverName,
      actionName: actionName
    })
    const goal = new ROSLIB.Goal({
      actionClient: rosAction,
      goalMessage: argument
    });
    // Print out their output into the terminal.
    goal.on('feedback', function (feedback) {
      console.log('Feedback: ' + feedback.sequence);
    });
    goal.on('result', function (result) {
      console.log('Final Result: ' + result.sequence);
    });

    goal.send()
  }
image

And I tried to use python to send the action, and I got the same error

import roslibpy
import roslibpy.actionlib
import time

def feedback_callback(feedback):
    print('Feedback received: ', feedback['sequence'])

def result_callback(result):
    print('Result received: ', result['sequence'])

def call_fibonacci_action(order):
    client = roslibpy.Ros(host='10.211.55.5', port=9090)
    client.run()

    action_client = roslibpy.actionlib.ActionClient(client, '/fibonacci', 'actionlib_tutorials/Fibonacci')

    goal = roslibpy.actionlib.Goal(action_client, roslibpy.Message({'order': order}))

    goal.on('feedback', feedback_callback)
    goal.on('result', result_callback)

    print('Sending goal...')
    goal.send()

    # 等待结果
    while not goal.is_finished:
        time.sleep(1)

    print('Goal processing done.')
    client.terminate()

if __name__ == '__main__':
    call_fibonacci_action(5)
image
sea-bass commented 5 months ago

ROS 2 action support was added recently to rosbridge_suite in https://github.com/RobotWebTools/rosbridge_suite/pull/886. and is only implemented in roslibjs, not roslibpy yet.

The APIs you are using are the ones that work in ROS 1, where indeed the .msg namespace is searched to publish to the action's hidden topics.

sea-bass commented 5 months ago

Oh, the roslibjs example that does work in ROS 2 is here: https://github.com/RobotWebTools/roslibjs/blob/develop/examples/ros2_action_client.html

sea-bass commented 5 months ago

I've also created the underlying issue for roslibpy here: https://github.com/gramaziokohler/roslibpy/issues/122

So will go ahead and close this one, if that's okay.