roslaunch exit code 2 error
I am implementing a simple roslaunch file but I am getting an exit code 2 status I have pasted the exact log below any idea what would cause this and how I can rectify it. I can run it perfectly using rosrun
kshitij@Kshitij:~/catkin_ws$ roslaunch apriltag_ros apriltag.launch
... logging to /home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/roslaunch-Kshitij-20782.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://Kshitij:38583/
SUMMARY
========
PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.15.13
NODES
/
apriltag_ros (apriltag_ros/tagdetector.py)
auto-starting new master
process[master]: started with pid [20790]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to c7672d6c-479d-11ec-bd02-c56b9aa24743
process[rosout-1]: started with pid [20800]
started core service [/rosout]
process[apriltag_ros-2]: started with pid [20803]
usage: tagdetector.py [-h] [-f FAMILIES] [-B N] [-t N] [-x SCALE] [-b SIGMA] [-0] [-1] [-2] [-c]
tagdetector.py: error: unrecognized arguments: __name:=apriltag_ros __log:=/home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/apriltag_ros-2.log
[apriltag_ros-2] process has died [pid 20803, exit code 2, cmd /home/kshitij/catkin_ws/src/apriltag_ros/scripts/tagdetector.py __name:=apriltag_ros __log:=/home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/apriltag_ros-2.log].
log file: /home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/apriltag_ros-2*.log
The launch file code is as below
<?xml version = "1.0"?>
<launch>
<node name = "apriltag_ros" pkg = "apriltag_ros" type = "tagdetector.py" output="screen" />
</launch>
As per my understanding I should add an extra line in my publisher that is rospy.myargv(argv=sys.argv)
but it doesn't seem to work. Please let me know if I am missing something.
The function I am using to publish the data is as below
def location_publisher():
"""
ROS Publisher: Publishes X, Y and Yaw values
"""
pub = rospy.Publisher('apriltag_pose', tag, queue_size=10)
rospy.init_node('apriltag_ros', anonymous=False)
msg = tag()
msg.location.x = z # z in camera frame of reference is the distance from the tag i.e. x in general frame of reference
msg.location.y = y
msg.location.theta = yaw
msg.status.data = status_tag
msg.tagid.data = tag_id
rospy.loginfo(msg)
pub.publish(msg)
Any help is appreciated.
Thanks