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

Set up nodes for joystick (XBox) controller #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jfisac
Copy link
Member

@jfisac jfisac commented Aug 29, 2018

This allows the XBox controller to call services. The code in the controller node (from crazyflie_clean) calls the Takeoff, Land and Emergency services; it's originally meant to work for the implementations given by the default crazyflie ROS code, but in principle should work out of the box with our own implementations of the services.

TODO:

  • Actually, before merging this branch with master, we should test it out once the launch file works (I'll rebase this branch onto master once master has it fixed).
  • We should probably also consider improving the Takeoff and Landing service implementation and adding an Emergency service. Given how well they work, I would advocate for relying heavily on the services in the default crazyflie ROS code.

@dfridovi
Copy link
Member

Let's make changes to crazyflie_clean to add the emergency land server and shorten the normal landing sequence a little bit.


<!-- Joystick controller node (listens to XBox controller for service calls). -->
<node name="joystick_controller" pkg="crazyflie_demo" type="controller.py" output="screen">
<param name="use_crazyflie_controller" value="True" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this use_crazyflie_controller parameter does but I suspect we'll need to look at the source code for this node and make sure it calls the right services. Alternatively (preferably) we can rename the services used by crazyflie_takeoff to match the ones assumed by the joystick.

Copy link
Member Author

@jfisac jfisac Aug 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I agree, I think it's the cleanest thing: we just provide the same interface with an alternative implementation of the services.

Regarding the use_crazyflie_controller argument, it seems this simply tells the controller whether or not to look for the takeoff and land services and set up the corresponding proxies (which then get called by a Subscriber set up by the controller node listening to the \joy topic); the emergency proxy is always set up regardless.

From crazyflie_demo's controller.py:

if use_controller:
            rospy.loginfo("waiting for land service")
            rospy.wait_for_service('land')
            rospy.loginfo("found land service")
            self._land = rospy.ServiceProxy('land', Empty)

            rospy.loginfo("waiting for takeoff service")
            rospy.wait_for_service('takeoff')
            rospy.loginfo("found takeoff service")
            self._takeoff = rospy.ServiceProxy('takeoff', Empty)
        else:
            self._land = None
            self._takeoff = None

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also, killing it with markdown :P)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're already calling our services /takeoff and /land respectively. The controller.cpp file defines the services as takeoff and land, but I think the slash doesn't make a difference here.

Based on this it looks like all that would be left would be implementing the emergency service. By the way, I'm not sure who implements their emergency service, currently, it's not controller.cpp.

@dfridovi
Copy link
Member

dfridovi commented Aug 29, 2018 via email

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

Successfully merging this pull request may close these issues.

2 participants