Skip to content

Instantly share code, notes, and snippets.

@TheProjectsGuy
Created December 8, 2018 06:07
Show Gist options
  • Save TheProjectsGuy/24cccbd799be05b3bd9d4b292c6e8594 to your computer and use it in GitHub Desktop.
Save TheProjectsGuy/24cccbd799be05b3bd9d4b292c6e8594 to your computer and use it in GitHub Desktop.
Argument parser made using python for ROS
#!/usr/bin/env python
# Import files
import rospy
import sys
# Only if the script is directly run
if __name__ == "__main__":
# Initialize node
rospy.init_node('ArgumentParser_Python', anonymous=True)
# Print all the arguments used
print('{num} argument(s)'.format(num=len(sys.argv)))
for num, i in enumerate(sys.argv, start=1):
print('Argument {0}: {1}'.format(num, i))
@TheProjectsGuy
Copy link
Author

We can use the argparse library as well (docs here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment