0
$\begingroup$

I am trying to fly a tello drone in a gazebo simulation ROS Driver for the tello Drone. When I try running the following script, (after ofcourse building the package) -

#!/usr/bin/env python3

import rclpy
from rclpy.node import Node

from geometry_msgs.msg import Twist

class DroneSim(Node):

    def __init__(self):
        super().__init__('velocity_publisher_node')
        self.publisher_ = self.create_publisher(Twist, '/drone1/cmd_vel', 10)
        timer_period = 0.5  # seconds
        self.timer = self.create_timer(timer_period, self.timer_callback)
        self.i = 0

    def timer_callback(self):
        twist = Twist()
        twist.linear.x = 1.0
        twist.angular.z = 1.0
        # add code to check if drone has taken off and only then publish velocity
        self.publisher_.publish(twist)
        self.get_logger().info(f'Publishing: {twist.linear.x}, {twist.angular.z}')
        self.i += 1


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

    drone_sim = DroneSim()

    rclpy.spin(drone_sim)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    drone_sim.destroy_node()
    rclpy.shutdown()


if __name__ == '__main__':
    main()

I use the following command to run the script -

ros2 run drone_sim test.py

I face the following error -

/opt/ros/foxy/bin/ros2:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
No executable found

I have tried upgrading, uninstalling and installing setuptools package, and numerous other things but it still does not seem to work.

I am on Ubunutu 20.04 and running ROS2 Foxy. The package is an ament_cmake package.

Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

Downgrade setuptools when you are using ROS2 foxy. Which is a known issue (mentioned here in the ROS 2 repository) :)

pip3 install setuptools==58.2.0

$\endgroup$
1
  • $\begingroup$ Hey, thanks for the reply but I was able to get this running successfully. I honestly don't remember how as I didn't document it at the time. Thabk you so much for the help. Hopefully this is helpful to someone. $\endgroup$ Commented Dec 12, 2023 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.