Code Monkey home page Code Monkey logo

mavros-takeoff-n-land's Introduction

MavRos takeoff and land

Install ROS [1]

Open a terminal and then copy and paste the following commands into it. (each block can be copied and pasted at once)

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install ros-kinetic-mavros ros-kinetic-mavros-extras
sudo /opt/ros/kinetic/lib/mavros/install_geographiclib_datasets.sh

Download and run PX4 Gazebo simulator

Prepare tools for building PX4

sudo apt-get update
sudo apt-get install python-argparse git-core wget zip python-empy qtcreator cmake build-essential genromfs -y
sudo apt-get install ant protobuf-compiler libeigen3-dev libopencv-dev openjdk-8-jdk openjdk-8-jre clang-3.5 lldb-3.5 python-toml python-numpy -y
sudo apt-get install python-pip -y
sudo -H pip install pandas jinja2

Download source files from Github

cd /tmp
mkdir me190
cd me190
git clone https://github.com/PX4/Firmware.git
cd Firmware
git submodule update --init --recursive

Wait until downloading finish correctly, then run

make posix_sitl_default gazebo

A window will pop up shows a quadcoter

Alt text

Create ROS work space, make and run our ROS node

Open a new Terminal and run:

cd ~
mkdir catkin_ws
cd  catkin_ws
mkdir src
cd src

Create an empty ROS package called ex1 node which depends on mavros. It will create CMakeLists.txt and packages.xml for you.

catkin_create_pkg ex1 mavros

Then you can pull the given c++ source code to your ex1 package folder

cd ex1/
wget https://github.com/UCM-ME190/MavRos-takeoff-n-land/raw/master/takeoff_n_land.cpp

After that, let's change the generated CMakeLists.txt file so that ros knows how to build this package

gedit CMakeLists.txt

Put those two lines at the end of the CMakeLists.txt file.

add_executable(takeoff_n_land takeoff_n_land.cpp)
target_link_libraries(takeoff_n_land ${catkin_LIBRARIES})

Here you have finished modifing files. Build this ROS package by

cd ~/catkin_ws
catkin_make

run following command so that rosrun can find our new nodes in your ex1 package

Run roscore, mavros and this ros nodde

In the terminal you have, run

roscore

Open another two terminals, inside one you run

roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14540"

inside another, run the ROS node you just built

cd ~/catkin_ws
source ./devel/setup.bash 
rosrun ex1 takeoff_n_land 

Alt text

[1] http://wiki.ros.org/kinetic/Installation/Ubuntu

[2] https://dev.px4.io/en/simulation/ros_interface.html

[3] https://dev.px4.io/en/simulation/gazebo.html

mavros-takeoff-n-land's People

Contributors

gzhang8 avatar cnpcshangbo avatar

Stargazers

 avatar  avatar Dennis Baldwin avatar Bertug Dilman avatar  avatar Kai avatar Aravind E Vijayan avatar Xiaolong Zhu avatar Chen Yunan avatar Leah LaSalla avatar 郭正龙, BUAA 可靠飞行控制组 avatar  avatar

Watchers

James Cloos avatar Leah LaSalla avatar  avatar  avatar

mavros-takeoff-n-land's Issues

AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'

Hi @gzhang8 ,

Thanks for your great contributions to ROS community, which indeed helped me a lot.

However, I followed your instructions and got an issue.

When running sudo -H pip install pandas jinja2 I got the traceback error

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
    from pip._internal import cmdoptions
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
    from pip._internal.index import (
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
    from pip._vendor import html5lib, requests, six
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 204, in <module>
    if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'

I guess this error comes from the old version of some library. After searching on Google I found an solution. (need to check if the directory exists before removing it, in some system the path should be /usr/lib)
$ sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
$ sudo apt install --reinstall python-openssl

This solved my problem. But after running sudo -H pip install pandas jinja2, I got an warning message in red color, though the pandas and jinja2 packages are installed successfully.

pyopenssl 17.5.0 has requirement cryptography>=2.1.4, but you'll have cryptography 1.2.3 which is incompatible.
astroid 1.6.0 has requirement enum34>=1.1.3; python_version < "3.4", but you'll have enum34 1.1.2 which is incompatible.

I am not sure if this solution will bring some other potential risks in the future.

By the way, why not put this repo into a ROS package? Then beginners can just git clone and catkin make to start their first try.

Missing installation step

During the installation on a fresh Ubuntu 16.04.3 x64 Desktop, I got an error message while trying to run Gazebo with make posix_sitl_default gazebo. Running the following command resolved the issue: sudo pip install numpy toml

Also, before building the ROS package with
cd ~/catkin_ws catkin_make
I had to install some additional dependencies with rosdep install --from-paths src --ignore-src.

Finally, before launching mavros with roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14540", I had to run sudo /opt/ros/kinetic/lib/mavros/install_geographiclib_datasets.sh.

How to run the code?

I was trying to repeat what you did in the video and I encountered some issues.

When I ran the gazebo simulation, I got some errors like

[ERROR] [1493507121.030549466]: FCU: Accel #0 fail: TOUT!
[ERROR] [1493507121.036021491]: FCU: Gyro #0 fail: TOUT!

I also tried to run the basic simulation, and I found a similar error.
So I guess it should be normal to get some error like that. Then I moved to build a project based on your example code.
I created the package by using:

catkin_create_pkg ex1 std_msgs rospy roscpp geometry_msgs mavros_msgs

I am not sure if I have included correct dependencies.

Then I downloaded your example code.

wget https://github.com/UCM-ME190/MavRos-takeoff-n-land/raw/master/takeoff_n_land.cpp

After that I changed the CMakeList.txt by adding:

add_executable(takeoff_n_land src/takeoff_n_land.cpp)
add_dependencies(takeoff_n_land ex1)
target_link_libraries(takeoff_n_land ${catkin_LIBRARIES})

After that I used "catkin_make" to compile and some errors appear.

In file included from /opt/ros/kinetic/include/ros/ros.h:40:0,
                 from /home/parallels/catkin_ws/src/ex1/src/takeoff_n_land.cpp:7:
/home/parallels/catkin_ws/src/ex1/src/takeoff_n_land.cpp: In function ‘int main(int, char**)’:
/opt/ros/kinetic/include/ros/console.h:346:176: warning: format not a string literal and no format arguments [-Wformat-security]
 location__loc.level_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__)
                                                                               ^
/opt/ros/kinetic/include/ros/console.h:349:5: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER’
     ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(0, __VA_ARGS__)
     ^
/opt/ros/kinetic/include/ros/console.h:379:7: note: in expansion of macro ‘ROSCONSOLE_PRINT_AT_LOCATION’
       ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \
       ^
/opt/ros/kinetic/include/ros/console.h:561:35: note: in expansion of macro ‘ROS_LOG_COND’
 #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__)
                                   ^
/opt/ros/kinetic/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’
 #define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_
                       ^
/home/parallels/catkin_ws/src/ex1/src/takeoff_n_land.cpp:77:11: note: in expansion of macro ‘ROS_INFO’
           ROS_INFO(current_state.mode.c_str());
           ^
[100%] Linking CXX executable /home/parallels/catkin_ws/devel/lib/ex1/takeoff_n_land
[100%] Built target takeoff_n_land

Finally, the compiling was not successful.
My questions are:

  1. Do you think I have used the correct way to create a package?
  2. Do you think I have made a proper CMakeList file?

Please advice.
Thanks,
Bo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.