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

cflib Add notify setpoints stop #309

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crazyflie/scripts/crazyflie_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,15 @@ def _go_to_callback(self, request, response, uri="all"):
return response

def _notify_setpoints_stop_callback(self, request, response, uri="all"):
self.get_logger().info("Notify setpoint stop not yet implemented")

self.get_logger().info(f"{uri}: Received notify setpoint stop")

if uri == "all":
for link_uri in self.uris:
self.swarm._cfs[link_uri].cf.commander.send_notify_setpoint_stop()
else:
self.swarm._cfs[uri].cf.commander.send_notify_setpoint_stop()

return response

def _upload_trajectory_callback(self, request, response, uri="all"):
Expand Down
6 changes: 4 additions & 2 deletions crazyflie/scripts/vel_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rclpy.node import Node

from geometry_msgs.msg import Twist
from crazyflie_interfaces.srv import Takeoff, Land
from crazyflie_interfaces.srv import Takeoff, Land, NotifySetpointsStop
from crazyflie_interfaces.msg import Hover
import time

Expand All @@ -39,6 +39,7 @@ def __init__(self):
self.takeoff_client = self.create_client(Takeoff, robot_prefix + '/takeoff')
self.publisher_hover = self.create_publisher(Hover, robot_prefix + '/cmd_hover', 10)
self.land_client = self.create_client(Land, robot_prefix + '/land')
self.notify_client = self.create_client(NotifySetpointsStop, robot_prefix + '/notify_setpoints_stop')
self.cf_has_taken_off = False

self.takeoff_client.wait_for_service()
Expand Down Expand Up @@ -72,6 +73,8 @@ def timer_callback(self):
msg.z_distance = self.hover_height
self.publisher_hover.publish(msg)
else:
req = NotifySetpointsStop.Request()
self.notify_client.call_async(req)
req = Land.Request()
req.height = 0.1
req.duration = rclpy.duration.Duration(seconds=2.0).to_msg()
Expand All @@ -80,7 +83,6 @@ def timer_callback(self):
self.cf_has_taken_off = False
self.received_first_cmd_vel = False


def main(args=None):
rclpy.init(args=args)

Expand Down
2 changes: 1 addition & 1 deletion crazyflie_examples/launch/keyboard_velmux_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def generate_launch_description():
output='screen',
parameters=[{"hover_height": 0.3},
{"incoming_twist_topic": "/cmd_vel"},
{"robot_prefix": "/cf1"}]
{"robot_prefix": "/cf231"}]
),
])
6 changes: 4 additions & 2 deletions docs2/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ Teleoperation keyboard
We have an example of the telop_twist_keyboard package working together with the crazyflie

First, make sure that the crazyflies.yaml has the right URI and if you are using the `Flow deck <https://www.bitcraze.io/products/flow-deck-v2/>`_ or `any other position system available <https://www.bitcraze.io/documentation/system/positioning//>`_ to the crazyflie.
set the controller to 1 (PID)
set the controller to 1 (PID).

And if you have not already, install the teleop package for the keyboard. (replace DISTRO with humble or galactic):

.. code-block:: bash

sudo apt-get install ros-DISTRO-teleop-twist-keyboard

Then, run the following launch file to start up the crazyflie server (CFlib):
Then, first checkout keyboard_velmux_launch.py and make sure that the 'robot_prefix' of vel_mux matches your crazyflie ID in crazyfies.yaml ('cf231').

Then run the following launch file to start up the crazyflie server (CFlib):

.. code-block:: bash

Expand Down
Loading