ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How can I understand the failed connection attempt for a SimpleActionClient ?

asked 2021-01-01 06:24:08 -0500

fabian gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

Comments

1

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?

Dragonslayer gravatar image Dragonslayer  ( 2021-01-02 05:45:56 -0500 )edit

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.

fabian gravatar image fabian  ( 2021-01-02 08:41:14 -0500 )edit

3 Answers

Sort by » oldest newest most voted
1

answered 2021-01-02 08:46:14 -0500

fabian gravatar image

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.

edit flag offensive delete link more
0

answered 2021-05-19 02:22:57 -0500

To configure Niryo robots as ROS multimachine:

Connect your computer to your Ned by ssh: (password: robotics)
https://niryo.com/docs/niryo-one/deve...

ssh niryo@<robot_ip>

On your Robot:

sudo service niryo_robot_ros stop
export ROS_MASTER_URI=http://<robot_ip>:11311
export ROS_IP=<robot_ip>
roslaunch niryo_robot_bringup niryo_ned_robot.launch

On your computer:

export ROS_MASTER_URI=http://<robot_ip>:11311
export ROS_IP=<computer_ip>

and lanch your code

edit flag offensive delete link more
0

answered 2021-02-11 18:45:00 -0500

HectorP gravatar image

Hello,

I am new with ROS and I am also working with the robot Niryo One. I have the same problem with connection attempt for a SimpleActionClient. I readed your solution but I dont understand how to change the flag (net==host) and how start de docker cointainer. Could you explain me how did you solution this?

Thanks in advance

edit flag offensive delete link more

Comments

1

Happy to hear you are also working with the Niryo One! After spending some time with it, things mostly work for me. For the docker container, I use two files, the Dockerfile to create the container, and the simple script to start the container for the first time. The container is build with docker build -t <my_container_name> <location_dockerfile> After you create the container, you can basically start it with the command docker run -it --net=host --privileged <my_container_name> bash. Insider the container, you can then install ros-kinetic and the niryo packages from github. The net=host options makes sure that the container can communicate with the niryo arm. After you have sourced the packages inside the docker container, please set the ROS_IP (equal to your comptuer) and the ROS_MASTER_IP equal to the IP of the arm. Then, you should be able to connect via the simple action client. Is this ...(more)

fabian gravatar image fabian  ( 2021-02-12 11:21:28 -0500 )edit
1

The idea of ​​my project with Niryo One is use a calibrated 2D camera to adquire coordinates and send that coordinates to the robot. Then I am trying to control the robot and send that positions by a program in C ++ (I am using the same example of code in C++ as you: https://github.com/smaassen/niryo_one...).

As you told me, I will try to create the container and install all. When I get it installed and I test the connection with the robot, I will tell you some news.

Thanks you for answering my question and explain all to me. Very Thanks

HectorP gravatar image HectorP  ( 2021-02-12 16:08:19 -0500 )edit

This sounds fantastic! I'm trying something similar but also use a depth camera and try to leverage the moveit stack. Good luck & looking very much forward to hearing how your work goes!

fabian gravatar image fabian  ( 2021-02-13 03:30:16 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-01-01 06:24:08 -0500

Seen: 262 times

Last updated: Jan 02 '21