ROS Q&A | How to Start Programming Drones using ROS

ROS Q&A | How to Start Programming Drones using ROS

In this video answer, we walk through the basics of a Parrot AR Drone Gazebo simulation.
You will learn the topics provided by the simulation and how to use a ROS program to interact, sending commands or reading sensors, with this robot.

[irp posts=”8190″ name=”Performing LSD-SLAM with a ROS based Parrot AR. Drone”]

Let’s get started!

Step1. Create a new project on ROS Development Studio(RDS)

We’ll use ROS Development Studio(RDS) for this tutorial, you can register a free account here.

After logging into RDS, click on create my project. It will move to the public simulation. You can find tons of public simulation here offered by the construct for free and start to work on any of them in just minutes. See how powerful RDS is! For today, we’ll use sjtu_drone_tc project. Please click on it. Click the tools menu, you can find some tools that help you develop in RDS. For example, you have the:

  1.  Shell: it is the terminal where you can execute commands in RDS. You can open it as many as you want in RDS!
  2.  IDE: It’s the best way to explore the source tree of your project. With a right click, you can add or remove files easily.
  3. Jupyter Notebook: You can take notes for your project here. Since it’s working with python shell, you can directly execute python script here. A default notebook is provided to help you start the simulation.
  4. Graphical tool: You can use all the GUIs supported by ROS here(e.g. RViz, rqt_gui…etc.)

Notice:

We are not automatically running the simulation when you start RDS now. In order to have the same simulation shown in the video. Please go Simulations->Select launch file->main.launch to launch it by yourself. Then you can type the following command in a shell to check if the topics are correctly publishing by the drone.

$ rostopic list

 


Step2. Get started with the simulation

Let’s get started by following the instruction in the default jupyter notebook. Open it from tools->jupyter notebook->default.ipynb.

We can make the drone take off with the shell command

$ rostopic pub /drone/takeoff std_msgs/Empty "{}"

You should see the drone take off as soon as you send this command.

Notice:

You can use the ROS auto-completion function while you are typing a ROS command by pressing [TAB]. It’s a good idea to do that when the command is too long and hard to type it correctly.

You can also land the drone with the following command

$ rostopic pub /drone/land std_msgs/Empty "{}"

You can also find an instruction in the default.ipynb shows you how to do it with a python script instead of sending commend from shell.


Step3. Program with drones

We have more examples for you! Let’s say, we want to use the position control function provided by the drone. We found there is a topic called /drone/posctrl, but how to use it? By typing

rostopic info /drone/posctrl

You’ll see the output like this.

Type: std_msgs/Bool

Publishers:
* /my_node (http://ip-172-31-35-31:45972/)

Subscribers:
* /gazebo (http://10.8.0.1:44685/)

It seems that the topic is using the Bool message, but what is Bool message and how can I use it? You can further investigate it by typing

rosmsg show std_msgs/Bool

and got the output

bool data

The Bool message is very simple. It contains only one attribute called data with the type bool. Let’s try to send a message to this topic! Before we publish to the topic, we set up a monitor first with

rostopic echo /drone/posctrl

Then copy, paste and execute the following code in jupyter notebook.

from std_msgs.msg import Bool

var_bool = Bool()
pub_posctrl = rospy.Publisher('/drone/posctrl',Bool,queue_size = 1)
var_bool.data = True
pub_posctrl.publish(var_bool)

You should see

data: True

which means the message is published correctly. We enable the position control function on the drone successfully. Similarly, you can move the drone by publishing Twist message to the /cmd_vel topic. Here is an example script

from geometry_msgs.msg import Twist

var_twist = Twist()
pub_position = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
var_twist.linear.x = 1
var_twist.linear.y = 1
var_twist.linear.z = 2
pub_position.publish(var_twist)

Now you know how to start programming drones easily with RDS! You can do lots of things in RDS(e.g. using the cameras on the drone to implement computer vision algorithms). If you are interested but have no ideas how to do it, you can check our Programming drones with ROS course on robot ignite academy!

 

Edit by Tony Huang

[Links and resources mentioned in the video]

– ROS Development Studio: https://goo.gl/1Qb4AT

– The course of Programming Drones with ROS is available here: https://goo.gl/x6yaZW


programming-drone-with-ros-course-banner

[ROS Q&A] 003 – How to control a Gazebo simulated robot with MoveIt! ? (UR5)

[ROS Q&A] 003 – How to control a Gazebo simulated robot with MoveIt! ? (UR5)

 

In this ROS video tutorial we will show you a quick example of how to control a Gazebo simulated ur5 robotic arm with MoveIt!.

* Get all the ROS code of the video in this link: http://www.rosject.io/l/c3b7cee/

 

Step 1. Create a project in ROS Development Studio(ROSDS)

We can do any ROS development we want easily, without setting up environment locally in ROSDS and that’s the reason why we will use ROSDS for this tutorial. If you haven’t had an account yet. You can create one here for free now. After logging in, let’s begin our journey by clicking on the create new project and call it demo.

Step 2. Clone the universal robot repo

Please open a shell in ROSDS(tools->shell) and type the following command to clone the repo from ROS Industrial

NOTICE: We now put every simulation-related content under simulation_ws

cd ~/simulation_ws/src
git clone https://github.com/ros-industrial/universal_robot.git

NOTICE: Then you can launch the simulation from Simulations->Select Launch file->ur5.launch

Step 3. Generate Moveit config file

Type the following command to start configuration

roslaunch moveit_setup_assistant setup_assistant.launch

Then you can open the graphical tool from tools:

1.Select the xarco file (NOTICE: Use simulation_ws instead of catkin_ws now)

2.Self-Collisions: click generate collision matrix

3.Virtual Joints: click add virtual joint then edit it as the following image.

4.Planning Group: click add group then configure it as the following image. click on add kinetic chain and use base_link as Base Link and tool0 as Tip Link

5.Robot Poses: Add the following poses

6.Skip the end effectors and passive joints to the author information

7. Finish and generate config file: select the folder under simulation_ws

Step 4. Configure the controller

Create a file called controller.yaml under /demo_moveit_config/config directory with the following content

controller_list:
  - name: arm_contoller
    action_ns: "follow_joint_trajectory"
    type: FollowJointTrajectory
    joints: [shoulder_pan_joint, shoulder_lift_joint, elbow_joint, wrist_1_joint, wrist_2_joint, wrist_3_joint]

Create another file called joint_names.yaml under the same directory with the following content

controller_joint_names: [shoulder_pan_joint, shoulder_lift_joint, elbow_joint, wrist_1_joint, wrist_2_joint, wrist_3_joint]

Modify the ur5_moveit_controller_manager.launch file with the following content

<launch>
  <rosparam file="$(find demo_moveit_config)/config/controllers.yaml"/>
  <param name="use_controller_manager" value="false"/>
  <param name="trajectory_execution/execution_duration_monitoring" value="false"/>
  <param name="moveit_controller_manager" value="moveit_simple_controller_manager/MoveItSimpleControllerManager"/>
</launch>

Create a new launch file called demo_planning_execution.launch with the following content

<launch>

  <rosparam command="load" file="$(find myrobot_moveit_config)/config/joint_names.yaml"/>

  <include file="$(find demo_moveit_config)/launch/planning_context.launch" >
    <arg name="load_robot_description" value="true" />
  </include>

  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="/use_gui" value="false"/>
    <rosparam param="/source_list">[/joint_states]</rosparam>
  </node>

  <include file="$(find demo_moveit_config)/launch/move_group.launch">
    <arg name="publish_monitored_planning_scene" value="true" />
  </include>

  <include file="$(find demo_moveit_config)/launch/moveit_rviz.launch">
    <arg name="config" value="true"/>
  </include>

</launch>

Now you can launch the controller with the command

roslaunch demo_moveit_config demo_planning_execution.launch

You may also want to resize the window in graphical tool with

wmctrl -r :ACTIVE: -e 0,65,24,1500,550

You can try to do the planning now and execute, you should see the robot arm moving as you planned in moveit!

 

Edit by: Tony Huang

ROS Q&A | Why print works but rospy.loginfo doesn’t?

ROS Q&A | Why print works but rospy.loginfo doesn’t?

When we are developing ROS Programs, it’s common to use “print” or “rospy.loginfo” to print some text on the screen in order to see if our program is working as expected.

The problem is that sometimes the “rospy.loginfo” doesn’t work and we have no idea why it happens.

In this video we show how to make the rospy.loginfo shows the texts on the screen, by answering a real question asked on ROS Answers.

If you want to see the question and get the code used on the video, you can find it on the following link:

https://answers.ros.org/question/268370/print-works-but-rospyloginfo-doesnt/

 

ROS Q&A | How to create and spawn humans in Gazebo7

ROS Q&A | How to create and spawn humans in Gazebo7

 

Here you have a fast tutorial for creating your own human models in a format that can be spawned in Gazebo7 without any problems.

You will use makehuman software and ROS Development Studio for showing all this.

If you are interested in any element of the video to be explained in extra videos please leave a comment telling us what you would like to be explained in more detail.

ROS Q&A | How to start with OpenAI + ROS fast

ROS Q&A | How to start with OpenAI + ROS fast

 

A video describes an already set up online environment where to teach ROS based robots to do things using the Open AI Gym.
Everything is already set up and working. You just have to modify the environments to your necessities.

[irp posts=”8239″ name=”Using OpenAI with ROS”]

This video and the adaptation of OpenAI Gym Gazebo for the ROS Development Studio has been done by Vengatesan Govindaraju https://www.linkedin.com/in/vengatesang/

You can find this environment for free on the ROS Development Studio: http://rds.theconstructsim.com

If you need to learn more about OpenAI with ROS, watch this tutorial. https://youtu.be/o9FpZ1QQqcc

 

Pin It on Pinterest