ra-mtp-ntnu / moto

A Python library for controlling Yaskawa MOTOMAN robots.
https://github.com/tingelst/moto
Apache License 2.0
37 stars 10 forks source link

Connection Refused when using sim with motoman #18

Closed rr-tom-noble closed 2 years ago

rr-tom-noble commented 2 years ago

I'm trying to use MotoSim with motoman via ROS to get a feel for what it's capable of currently. I've created a small node to launch the sim:

#!/usr/bin/python

from moto.sim.motosim import ControlGroupSim, MotoSim
import rospy

if __name__ == "__main__":
    m = MotoSim("localhost", [ControlGroupSim(0, 6, [0.0] * 6)])
    m.start()
    while not rospy.is_shutdown():
        pass

and am launching motoman as follows:

    <include ns="$(arg robot_name)" file="$(find motoman_driver)/launch/robot_interface_streaming_yrc1000.launch">
      <arg name="robot_ip" value="localhost"/>
    </include>

However, I get the following errors on startup:

[ERROR] [1655978882.411580341] [/yaskawa/joint_state]: Failed to find topic_list parameter
[ WARN] [1655978882.412350151] [/yaskawa/joint_state]: Unable to find user-specified joint names in 'controller_joint_names'
[ WARN] [1655978882.413277066] [/yaskawa/joint_state]: Unable to find URDF joint names in 'robot_description'
[ERROR] [1655978882.413374606] [/yaskawa/joint_state]: Cannot find user-specified joint names. Tried ROS parameter 'controller_joint_names' and the URDF in 'robot_description'.
[ WARN] [1655978882.413569817] [/yaskawa/joint_state]: Unable to read 'controller_joint_names' param.  Using standard 6-DOF joint names.
[ERROR] [1655978882.413768800] [/yaskawa/joint_state]: Failed to connect to server, rc: -1. Error: 'Connection refused' (errno: 111)
[ERROR] [1655978882.415865930] [/yaskawa/joint_state]: Failed to connect to server, rc: -1. Error: 'Connection refused' (errno: 111)
[ WARN] [1655978882.415884926] [/yaskawa/joint_state]: Not connected, bytes not sent
[ERROR] [1655978882.415967579] [/yaskawa/joint_state]: Failed to receive message length
[ERROR] [1655978882.416037751] [/yaskawa/joint_state]: Failed to receive incoming message
[ WARN] [1655978882.416105299] [/yaskawa/joint_state]: Send failure, no callback support
...
[ WARN] [1655978882.476274494] [/yaskawa/io_relay]: Failed to get '~port' parameter: using default (50242)
[ERROR] [1655978882.493015715] [/yaskawa/io_relay]: Failed to connect to server, rc: -1. Error: 'Connection refused' (errno: 111)
[FATAL] [1655978882.493063405] [/yaskawa/io_relay]: Failed to connect
...
[ERROR] [1655978882.533790482] [/yaskawa/motion_streaming_interface]: Failed to find topic_list parameter
[ WARN] [1655978882.535837568] [/yaskawa/joint_trajectory_action]: Unable to find user-specified joint names in 'controller_joint_names'
[ WARN] [1655978882.536914233] [/yaskawa/joint_trajectory_action]: Unable to find URDF joint names in 'robot_description'
[ERROR] [1655978882.536943071] [/yaskawa/joint_trajectory_action]: Cannot find user-specified joint names. Tried ROS parameter 'controller_joint_names' and the URDF in 'robot_description'.
[ERROR] [1655978882.536972796] [/yaskawa/joint_trajectory_action]: Failed to initialize joint_names.
[ WARN] [1655978882.557413508] [/yaskawa/motion_streaming_interface]: Unable to find user-specified joint names in 'controller_joint_names'
[ WARN] [1655978882.558106726] [/yaskawa/motion_streaming_interface]: Unable to find URDF joint names in 'robot_description'
[ERROR] [1655978882.558181152] [/yaskawa/motion_streaming_interface]: Cannot find user-specified joint names. Tried ROS parameter 'controller_joint_names' and the URDF in 'robot_description'.
[ WARN] [1655978882.558324505] [/yaskawa/motion_streaming_interface]: Unable to read 'controller_joint_names' param.  Using standard 6-DOF joint names.
[ERROR] [1655978882.558618124] [/yaskawa/motion_streaming_interface]: Failed to connect to server, rc: -1. Error: 'Connection refused' (errno: 111)
[ WARN] [1655978882.559086520] [/yaskawa/motion_streaming_interface]: Unable to read velocity limits from 'robot_description' param.  Velocity validation disabled.
...
[ERROR] [1655978882.639311133] [/yaskawa/motion_streaming_interface]: Failed to connect to server, rc: -1. Error: 'Connection refused' (errno: 111)
[ERROR] [1655978882.889759774] [/yaskawa/motion_streaming_interface]: Timeout connecting to robot controller.  Send new motion command to retry.

I believe some of these errors may be due to me still having a fake MoveIt "controller" set up, however, I was expecting motoman would still be able to connect to the server (the ports and IP look correct). Any help would be much appreciated.

gavanderhoorn commented 2 years ago
<include ns="$(arg robot_name)" file="$(find motoman_driver)/launch/robot_interface_streaming_yrc1000.launch">
   <arg name="robot_ip" value="localhost"/>
</include>

I would advise against loading robot_interface_streaming_yrc1000.launch directly.

As explained here, you'll be responsible for making sure all the required parameters are present and in the right namespaces.

Using a robot support package makes that much easier.

This won't solve the connection problem, but it will solve all the other ("unable to find ..") errors, and will make the various nodes in motoman_driver much happier.


Edit: this might also be sub-optimal:

    while not rospy.is_shutdown():
        pass

this is a very tight while-loop, which probably occupies a single core by itself.

I'd recommend using time.sleep(..), or some other similar approach.

Also: why are you using rospy?

rr-tom-noble commented 2 years ago
<include ns="$(arg robot_name)" file="$(find motoman_driver)/launch/robot_interface_streaming_yrc1000.launch">
   <arg name="robot_ip" value="localhost"/>
</include>

I would advise against loading robot_interface_streaming_yrc1000.launch directly.

As explained here, you'll be responsible for making sure all the required parameters are present and in the right namespaces.

Using a robot support package makes that much easier.

This won't solve the connection problem, but it will solve all the other ("unable to find ..") errors, and will make the various nodes in motoman_driver much happier.

Edit: this might also be sub-optimal:

    while not rospy.is_shutdown():
        pass

this is a very tight while-loop, which probably occupies a single core by itself.

I'd recommend using time.sleep(..), or some other similar approach.

Also: why are you using rospy?

Thanks, I'll have a read over that tutorial. Realise that the loop isn't the best! I'll add a sleep. I tried using m.start() without the loop and the node immediately exited (unsure if that's expected behaviour though), so I'm using rospy and the loop to tie the lifetime of the server to the rest of my nodes.

rr-tom-noble commented 2 years ago

Just realised that the sim servers are launched as daemons, so I suppose it's fine that the node exits after starting? The servers should still be running?

tingelst commented 2 years ago

I usually run the sim script in interactive mode to keep everything alive: python -i sim.py

gavanderhoorn commented 2 years ago

I'm using rospy and the loop to tie the lifetime of the server to the rest of my nodes.

for ros tests that could be a way to approach setup/teardown.

But it doesn't really match reality (if that's a concern): MotoROS obviously doesn't shut down when motoman_driver disconnects/exits.

tingelst commented 2 years ago

Were you able to connect, @rr-tom-noble?

rr-tom-noble commented 2 years ago

I had some success! It looked like the issue was caused by motoman launching before the motoros server. Launching the server separately fixed the issue. I was getting some other errors on startup (can't remember the exact messages and I'm being pulled away by other work at the moment), so I'll close this issue for now and raise another when I have some time to pick this back up