Created
December 8, 2018 06:07
-
-
Save TheProjectsGuy/24cccbd799be05b3bd9d4b292c6e8594 to your computer and use it in GitHub Desktop.
Argument parser made using python for ROS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We can use the argparse library as well (docs here)