0
$\begingroup$

Rosanswers logo

First of all: happy, healthy and productive new year to everybody!

I am trying in vain to connect a SimpleActionClient to a remotely started robot and wanted to ask if somebody has any idea why the connection might fail.

In particular, I am trying to run the following script:

int main(int argc, char **argv) {
ros::init(argc, argv, "niryo_one_tester");
ros::NodeHandle n("~");
ros::Rate loop_rate(10);
ros::AsyncSpinner spinner(3);
spinner.start();

// Connecting to the robot ===========================================
ROS_INFO("Connecting to robot  ========================");
NiryoClient ac("/niryo_one/commander/robot_action/", true);
// wait for the action server to start
bool connection_success = false;
connection_success = ac.waitForServer(ros::Duration(30.0));
if (! connection_success) {
    ROS_WARN("  Error connecting to Robot. Terminate");
    return 1;
}

The script always fails and exists with the code 1. There are a few observations that might help to track the problem:

  • I can run the script on the local computer of the robot itself without any problems.
  • On the remote computer, I can successfully call a different service asking the robot to calibrate itself. The service is called via the command line.
  • I did set ROS_IP and ROS_MASTER_URI on both computers as described in the first answers of this question
  • The log file on the robot (the master) does register a connection attempt in its log. The information provided is:
[rosmaster.master][INFO] 2021-01-01 13:09:04,638: +PUB [/niryo_one/commander/robot_action/cancel] /niryo_one_tester http://172.17.0.2:39609/
[rosmaster.master][INFO] 2021-01-01 13:09:04,714: publisherUpdate[/niryo_one/commander/robot_action/cancel] -> http://192.168.1.162:43633/ ['http://172.17.0.2:39609/']
[rosmaster.master][INFO] 2021-01-01 13:09:04,719: publisherUpdate[/niryo_one/commander/robot_action/cancel] -> http://192.168.1.162:43633/ ['http://172.17.0.2:39609/']: sec=0.00, result=[1, '', 0]
[rosmaster.master][INFO] 2021-01-01 13:09:34,731: -SUB [/niryo_one/commander/robot_action/status] /niryo_one_tester http://172.17.0.2:39609/
[rosmaster.master][INFO] 2021-01-01 13:09:34,745: -PUB [/niryo_one/commander/robot_action/cancel] /niryo_one_tester http://172.17.0.2:39609/
[rosmaster.master][INFO] 2021-01-01 13:09:34,764: publisherUpdate[/niryo_one/commander/robot_action/cancel] -> http://192.168.1.162:43633/ []
[rosmaster.master][INFO] 2021-01-01 13:09:34,770: publisherUpdate[/niryo_one/commander/robot_action/cancel] -> http://192.168.1.162:43633/ []: sec=0.00, result=[1, '', 0]
[rosmaster.master][INFO] 2021-01-01 13:09:34,773: -PUB [/niryo_one/commander/robot_action/goal] /niryo_one_tester http://172.17.0.2:39609/
[rosmaster.master][INFO] 2021-01-01 13:09:34,784: -SUB [/niryo_one/commander/robot_action/feedback] /niryo_one_tester http://172.17.0.2:39609/
[rosmaster.master][INFO] 2021-01-01 13:09:34,787: publisherUpdate[/niryo_one/commander/robot_action/goal] -> http://192.168.1.162:43633/ []
[rosmaster.master][INFO] 2021-01-01 13:09:34,792: publisherUpdate[/niryo_one/commander/robot_action/goal] -> http://192.168.1.162:43633/ []: sec=0.00, result=[1, '', 0]
[rosmaster.master][INFO] 2021-01-01 13:09:34,795: -SUB [/niryo_one/commander/robot_action/result] /niryo_one_tester http://172.17.0.2:39609/
[rosmaster.master][INFO] 2021-01-01 13:09:35,040: -PUB [/rosout] /niryo_one_tester http://172.17.0.2:39609/
[rosmaster.master][INFO] 2021-01-01 13:09:35,063: -SERVICE [/niryo_one_tester/get_loggers] /niryo_one_tester rosrpc://172.17.0.2:41231
[rosmaster.master][INFO] 2021-01-01 13:09:35,069: publisherUpdate[/rosout] -> http://192.168.1.162:39004/ ['http://192.168.1.162:33130/', 'http://192.168.1.162:32774/', 'http://192.168.1.162:41839/', 'http://192.168.1.162:35047/', 'http://192.168.1.162:34530/', 'http://192.168.1.162:38955/', 'http://192.168.1.162:33874/', 'http://192.168.1.162:44178/', 'http://192.168.1.162:35440/', 'http://192.168.1.162:42460/', 'http://192.168.1.162:39485/', 'http://192.168.1.162:43633/', 'http://192.168.1.162:46089/', 'http://192.168.1.162:38877/', 'http://192.168.1.162:41523/']
[rosmaster.master][INFO] 2021-01-01 13:09:35,072: publisherUpdate[/rosout] -> http://192.168.1.162:39004/ ['http://192.168.1.162:33130/', 'http://192.168.1.162:32774/', 'http://192.168.1.162:41839/', 'http://192.168.1.162:35047/', 'http://192.168.1.162:34530/', 'http://192.168.1.162:38955/', 'http://192.168.1.162:33874/', 'http://192.168.1.162:44178/', 'http://192.168.1.162:35440/', 'http://192.168.1.162:42460/', 'http://192.168.1.162:39485/', 'http://192.168.1.162:43633/', 'http://192.168.1.162:46089/', 'http://192.168.1.162:38877/', 'http://192.168.1.162:41523/']: sec=0.00, result=[1, '', 0]
[rosmaster.master][INFO] 2021-01-01 13:09:35,142: -SERVICE [/niryo_one_tester/set_logger_level] /niryo_one_tester rosrpc://172.17.0.2:41231

Does somebody have any idea why the program exists with error code 1? What other information would be helpful to understand the problem? I am grateful for any help or suggestions!


Originally posted by fabian on ROS Answers with karma: 46 on 2021-01-01

Post score: 0


Original comments

Comment by Dragonslayer on 2021-01-02:
What catches my eye is that at stamp 13:09:04 +pub, publisher updates. Then nothing and at 13:09:34 -sub, -pub. Thats 30 seconds later, seems to correspond to ac.waitForServer(ros::Duration(30.0). Coincidence? Timeout? Your ROS_INFO("Connecting to robot ========================"); isnt in this log, so I wouldnt expect ROS_WARN(" Error connecting to Robot. Terminate"); to be in it either. Where are they loged?

Comment by fabian on 2021-01-02:
Thank you very much indeed for your comment, @Dragonslayer. That is a very astute observation and indeed I cannot observe such delay when I run the node locally on the robot. I just figured out the solution to the problem as I report below.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I have figured out the solution to the problem I described above.

The remote computer run as a docker container. When trying the netcat test as described in the docs I realized that the container and the robot could only establish connection in one direction but not in both. I thus used the flag net=host when starting the docker container and set the ROS_IP in the remote computer (the docker container) equal to the host IP address. Then, everything worked.


Originally posted by fabian with karma: 46 on 2021-01-02

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.