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

wrap rospy #8

Open
afdaniele opened this issue Aug 28, 2019 · 3 comments
Open

wrap rospy #8

afdaniele opened this issue Aug 28, 2019 · 3 comments

Comments

@afdaniele
Copy link
Member

We should try to wrap the functions we redefine in DTROS in the original rospy module.
Example, we want to use self.Publisher() instead of rospy.Publisher(), we can do something like this:

def wrapPublisher([args_for_rospy_Publisher]):
    print('WARNING: Your are using rospy.Publisher, use self.Publisher instead')
    return rospy._Publisher([args_for_rospy_Publisher])

rospy._Publisher = rospy.Publisher
rospy.Publisher = wrapPublisher

If we do this in DTROS.__init__(), then we can catch cases where we forget to use self.Publisher() instead of rospy.Publisher(). Everything will still work fine but at least we get a Warning.

@AleksandarPetrov
Copy link
Contributor

@afdaniele I think that is a good idea, but complicates the code and will throw unnecessary warnings in the case that someone intentionally wants to use a publisher or subscriber that are not deactivated by the switch

@afdaniele
Copy link
Member Author

Just something to keep in mind.
The easy fix to that would be

def wrapPublisher([args_for_rospy_Publisher], permanent=False):
    if not permanent:
        print('WARNING: Your are using rospy.Publisher, use self.Publisher instead')
    return rospy._Publisher([args_for_rospy_Publisher])

@afdaniele
Copy link
Member Author

Let's not do this now, we can work on this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants