Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argparse issue with launchfiles #460

Closed
thomaspeyrucain opened this issue Sep 4, 2023 · 3 comments · Fixed by #465
Closed

argparse issue with launchfiles #460

thomaspeyrucain opened this issue Sep 4, 2023 · 3 comments · Fixed by #465
Assignees
Labels
bug Something isn't working

Comments

@thomaspeyrucain
Copy link
Contributor

Hello,

If I want to integrate the nodes in a launchfile like this:

<?xml version="1.0" encoding="UTF-8"?>
<launch>
    <arg name="rgb_topic" default="/xtion/rgb/image_raw"/>
    <node name="face_reco_node" pkg="opendr_perception" type="face_recognition_node.py" args="-i $(arg rgb_topic) -dataset_path $(arg face_reco_path)" output="screen"/> 

</launch>

I get this error:

opendr_ws$ roslaunch opendr_perception opendr_demo.launch 
... logging to /home/thomaspeyrucain/.ros/log/0e98f1ec-4afe-11ee-b07b-68545ace404b/roslaunch-manama-16957.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://192.168.6.172:39345/

SUMMARY
========

PARAMETERS
 * /rosdistro: noetic
 * /rosversion: 1.16.0

NODES
  /
    face_reco_node (opendr_perception/face_recognition_node.py)

ROS_MASTER_URI=http://tiago-145c:11311

process[face_reco_node-1]: started with pid [16980]
usage: face_recognition_node.py [-h] [-i INPUT_RGB_IMAGE_TOPIC] [-o OUTPUT_RGB_IMAGE_TOPIC] [-d DETECTIONS_TOPIC]
                                [-id DETECTIONS_ID_TOPIC] [--performance_topic PERFORMANCE_TOPIC] [--device {cuda,cpu}]
                                [--backbone {mobilefacenet}] [--dataset_path DATASET_PATH]
face_recognition_node.py: error: unrecognized arguments: __name:=face_reco_node __log:=/home/thomaspeyrucain/.ros/log/0e98f1ec-4afe-11ee-b07b-68545ace404b/face_reco_node-1.log
INFO:rospy.core:signal_shutdown [atexit]
[face_reco_node-1] process has died [pid 16980, exit code 2, cmd /home/thomaspeyrucain/Desktop/OpenDR/opendr/projects/opendr_ws/src/opendr_perception/scripts/face_recognition_node.py -i /xtion/rgb/image_raw __name:=face_reco_node __log:=/home/thomaspeyrucain/.ros/log/0e98f1ec-4afe-11ee-b07b-68545ace404b/face_reco_node-1.log].
log file: /home/thomaspeyrucain/.ros/log/0e98f1ec-4afe-11ee-b07b-68545ace404b/face_reco_node-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done

To fix it I replaced this line:


By this line: args = parser.parse_args(rospy.myargv()[1:])
In all the ROS scripts

@tsampazk
Copy link
Collaborator

tsampazk commented Sep 4, 2023

Hey @thomaspeyrucain, thank you for reporting this and the fix. I will test this out and get back to you.

@tsampazk tsampazk added the bug Something isn't working label Sep 22, 2023
@tsampazk tsampazk self-assigned this Sep 22, 2023
@tsampazk
Copy link
Collaborator

Hello again @thomaspeyrucain, i did some testing regarding this issue.

I used the launch file you provided with some minor modifications to fit my system:

<?xml version="1.0" encoding="UTF-8"?>
<launch>
    <arg name="rgb_topic" default="/usb_cam/image_raw"/>
    <node name="face_reco_node" pkg="opendr_perception" type="face_recognition_node.py" args="-i $(arg rgb_topic)" output="screen"/> 
</launch>

and i got the same error as the one you reported.

Your fix looks perfectly fine to me as it doesn't interfere with non-launch running of the nodes.

The issue originates from the fact that the launch process seems to use the rospy arguments rospy.myargv() which includes the node's path, e.g. when i printed it i got ['/home/kostas/dev/opendr/projects/opendr_ws/src/opendr_perception/scripts/face_recognition_node.py', '-i', '/usb_cam/image_raw'], so your fix of skipping the first element of this list rectifies the issue.

One minor issue i noticed, which you should probably be already aware of, is that the working directory when using the launchfile is not the workspace directory but something similar to /home/<user>/.ros, so in this particular node you need to position your ./database folder appropriately or provide an appropriate path for face recognition to work properly.

I will go ahead and fix this across all ROS1 nodes so they can be used with launch files. Thank you for your efforts!

@thomaspeyrucain
Copy link
Contributor Author

Perfect thanks @tsampazk , for the directory I most often put the whole path of the file or folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants