From 7b431fa021a28fd8c1e132e27a559ed91d621c08 Mon Sep 17 00:00:00 2001 From: Sergey Stetsky <46196443+stinger000@users.noreply.github.com> Date: Fri, 23 Sep 2022 20:15:57 +0300 Subject: [PATCH 1/6] docs: add command for updating markers map in the sim (#456) Co-authored-by: Oleg Kalachev --- docs/en/simulation_usage.md | 10 ++++++++++ docs/ru/simulation_usage.md | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/en/simulation_usage.md b/docs/en/simulation_usage.md index c8cc6ecb..e189b60f 100644 --- a/docs/en/simulation_usage.md +++ b/docs/en/simulation_usage.md @@ -97,3 +97,13 @@ PX4_SIM_SPEED_FACTOR=0.42 roslaunch clover_simulation simulator.launch The virtual machine may benefit from several CPU cores, especially if the cores are not very performant. In our tests, a four-core machine with only a single core allocated to the VM was unable to run the simulation, with constant interface freezes and dropped ROS messages. The same machine with all four cores available to the VM was able to run the simulation at 0.25 real-time speed. Do note that you should not allocate more resources than you have on your host hardware. + +### Changing the map of ArUco-markers in the simulator + +In order to change the map of ArUco-markers in the simulator, you can use the following command: + +```bash +rosrun clover_simulation aruco_gen --single-model --source-world=$(catkin_find clover_simulation resources/worlds/clover.world) $(catkin_find aruco_pose map/map.txt) > $(catkin_find clover_simulation resources/worlds/clover_aruco.world) +``` + +In this example, `map.txt` is the name of markers name. diff --git a/docs/ru/simulation_usage.md b/docs/ru/simulation_usage.md index 591862b3..f6ce2b64 100644 --- a/docs/ru/simulation_usage.md +++ b/docs/ru/simulation_usage.md @@ -99,3 +99,13 @@ PX4_SIM_SPEED_FACTOR=0.42 roslaunch clover_simulation simulator.launch Выделение нескольких процессорных ядер для виртуальной машины может значительно повысить производительность симуляции. В наших испытаниях виртуальная машина, для которой было выделено одно ядро, не позволяла работать в симуляторе: окно Gazebo не реагировало на пользовательский ввод, сообщения ROS терялись. После выделения четырёх ядер для этой же виртуальной машины симуляция стала работать со скоростью 0.25 от реального времени. При этом не следует пытаться выделить для виртуальной машины больше ресурсов, чем доступно на основной системе. + +### Изменение карты ArUco-меток в симуляторе + +Для того, чтобы изменить карту ArUco-меток в симуляторе, можно использовать следующую команду: + +```bash +rosrun clover_simulation aruco_gen --single-model --source-world=$(catkin_find clover_simulation resources/worlds/clover.world) $(catkin_find aruco_pose map/map.txt) > $(catkin_find clover_simulation resources/worlds/clover_aruco.world) +``` + +В данном примере `map.txt` – имя карты меток. From 91c69986335bf427b42d045972bd568414330503 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Thu, 29 Sep 2022 01:40:16 +0300 Subject: [PATCH 2/6] docs: add snippet to subscribe and decode incoming mavlink messages --- docs/en/snippets.md | 24 ++++++++++++++++++++++++ docs/ru/snippets.md | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/docs/en/snippets.md b/docs/en/snippets.md index 87eade17..af2e36c9 100644 --- a/docs/en/snippets.md +++ b/docs/en/snippets.md @@ -240,6 +240,30 @@ ros_msg = mavlink.convert_to_rosmsg(msg) mavlink_pub.publish(ros_msg) ``` + + +### # {#mavlink-receive} + + + +Subscribe to all MAVLink messages from the flight controller and decode them: + +```python +from mavros_msgs.msg import Mavlink +from mavros import mavlink +from pymavlink import mavutil + +link = mavutil.mavlink.MAVLink('', 255, 1) + +def mavlink_cb(msg): + mav_msg = link.decode(mavlink.convert_to_bytes(msg)) + print('msgid =', msg.msgid, mav_msg) # print message id and parsed message + +mavlink_sub = rospy.Subscriber('mavlink/from', Mavlink, mavlink_cb) + +rospy.spin() +``` + ### # {#rc-sub} React to the drone's mode switching (may be used for starting an autonomous flight, see [example](https://gist.github.com/okalachev/b709f04522d2f9af97e835baedeb806b)): diff --git a/docs/ru/snippets.md b/docs/ru/snippets.md index 30bf38ce..85af2531 100644 --- a/docs/ru/snippets.md +++ b/docs/ru/snippets.md @@ -251,6 +251,30 @@ ros_msg = mavlink.convert_to_rosmsg(msg) mavlink_pub.publish(ros_msg) ``` + + +### # {#mavlink-receive} + + + +Подписка на все MAVLink-сообщения от полетного контроллера и их декодирование: + +```python +from mavros_msgs.msg import Mavlink +from mavros import mavlink +from pymavlink import mavutil + +link = mavutil.mavlink.MAVLink('', 255, 1) + +def mavlink_cb(msg): + mav_msg = link.decode(mavlink.convert_to_bytes(msg)) + print('msgid =', msg.msgid, mav_msg) # print message id and parsed message + +mavlink_sub = rospy.Subscriber('mavlink/from', Mavlink, mavlink_cb) + +rospy.spin() +``` + ### # {#rc-sub} Реакция на переключение режима на пульте радиоуправления (может быть использовано для запуска автономного полета, см. [пример](https://gist.github.com/okalachev/b709f04522d2f9af97e835baedeb806b)): From c0707e066aca586d6138a3144cf6ad31bd989117 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Wed, 5 Oct 2022 15:10:17 +0500 Subject: [PATCH 3/6] actions: build Debian packages and upload to artifacts (#458) --- .github/workflows/build.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba7fbe05..92d9f927 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,8 +25,8 @@ jobs: - uses: actions/checkout@v2 with: path: catkin_ws/src/clover - - name: Install pip - run: apt-get update && apt-get -y install python3-pip + - name: Install requirements + run: apt-get update && apt-get -y install python3-pip fakeroot python3-bloom debhelper dpkg-dev - name: Install dependencies run: rosdep update && rosdep install --from-paths src --ignore-src -y - name: Install GeographicLib datasets @@ -35,5 +35,17 @@ jobs: run: source /opt/ros/$ROS_DISTRO/setup.bash && catkin_make - name: Run tests run: source devel/setup.bash && catkin_make run_tests && catkin_test_results - - name: Install - run: source devel/setup.bash && catkin_make install + - name: Build Debian packages + run: | + source devel/setup.bash + for file in `find . -name "package.xml"`; do + cd $(dirname ${file}) + bloom-generate rosdebian --os-name ubuntu --os-version $(lsb_release -cs) --ros-distro $ROS_DISTRO + fakeroot debian/rules binary + cd - + done + - uses: actions/upload-artifact@v3 + with: + name: debian-packages + path: catkin_ws/src/clover/*.deb + retention-days: 1 From eb448ae0e79e3e192dafd85a625756a91b453b83 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Wed, 12 Oct 2022 00:25:12 +0600 Subject: [PATCH 4/6] main_camera.launch: run image_raw_throttled topic by default (#248) --- clover/launch/main_camera.launch | 6 ++++++ clover/test/basic.test | 3 +++ docs/en/camera.md | 2 ++ docs/ru/camera.md | 2 ++ 4 files changed, 13 insertions(+) diff --git a/clover/launch/main_camera.launch b/clover/launch/main_camera.launch index 312a0f15..8e932ce4 100644 --- a/clover/launch/main_camera.launch +++ b/clover/launch/main_camera.launch @@ -4,6 +4,8 @@ + + @@ -43,4 +45,8 @@ + + + diff --git a/clover/test/basic.test b/clover/test/basic.test index 3aac7f10..bd5366f0 100755 --- a/clover/test/basic.test +++ b/clover/test/basic.test @@ -37,6 +37,9 @@ + + diff --git a/docs/en/camera.md b/docs/en/camera.md index bbf68d87..ba0dbd3a 100644 --- a/docs/en/camera.md +++ b/docs/en/camera.md @@ -145,6 +145,8 @@ rospy.spin() The script will take up to 100% CPU capacity. To slow down the script artificially, you can use [throttling](http://wiki.ros.org/topic_tools/throttle) of frames from the camera, for example, at 5 Hz (`main_camera.launch`): +> **Note** Starting from [image](image.md) version **0.24** `image_raw_throttled` topic is available without addition configuration. + ```xml diff --git a/docs/ru/camera.md b/docs/ru/camera.md index 7d90084e..0f9b6a14 100644 --- a/docs/ru/camera.md +++ b/docs/ru/camera.md @@ -147,6 +147,8 @@ rospy.spin() Скрипт будет занимать 100% процессора. Для искусственного замедления работы скрипта можно запустить [throttling](http://wiki.ros.org/topic_tools/throttle) кадров с камеры, например, в 5 Гц (`main_camera.launch`): +> **Note** Начиная с версии [образа](image.md) **0.24** топик `image_raw_throttled` доступен без дополнительной конфигурации. + ```xml From 94171d51aceecd72cdc3d5ff7d3fa6b022142871 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Thu, 13 Oct 2022 00:07:27 +0600 Subject: [PATCH 5/6] simple_offboard: implement simple_offboard/release service --- clover/src/simple_offboard.cpp | 8 ++++++++ docs/en/simple_offboard.md | 10 ++++++++++ docs/ru/simple_offboard.md | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/clover/src/simple_offboard.cpp b/clover/src/simple_offboard.cpp index b8f57033..fc755d77 100644 --- a/clover/src/simple_offboard.cpp +++ b/clover/src/simple_offboard.cpp @@ -860,6 +860,13 @@ bool land(std_srvs::Trigger::Request& req, std_srvs::Trigger::Response& res) return false; } +bool release(std_srvs::Trigger::Request& req, std_srvs::Trigger::Response& res) +{ + setpoint_timer.stop(); + res.success = true; + return true; +} + int main(int argc, char **argv) { ros::init(argc, argv, "simple_offboard"); @@ -933,6 +940,7 @@ int main(int argc, char **argv) auto sa_serv = nh.advertiseService("set_attitude", &setAttitude); auto sr_serv = nh.advertiseService("set_rates", &setRates); auto ld_serv = nh.advertiseService("land", &land); + auto rl_serv = nh_priv.advertiseService("release", &release); // Setpoint timer setpoint_timer = nh.createTimer(ros::Duration(1 / nh_priv.param("setpoint_rate", 30.0)), &publishSetpoint, false, false); diff --git a/docs/en/simple_offboard.md b/docs/en/simple_offboard.md index 832bd363..cff1c743 100644 --- a/docs/en/simple_offboard.md +++ b/docs/en/simple_offboard.md @@ -305,6 +305,16 @@ rosservice call /land "{}" > **Caution** In recent PX4 versions, the vehicle will be switched out of LAND mode to manual mode, if the remote control sticks are moved significantly. +### release + +If it's necessary to pause sending setpoint messages, use the `simple_offboard/release` service: + +```python +release = rospy.ServiceProxy('simple_offboard/release', Trigger) + +release() +``` + ## Additional materials * [ArUco-based position estimation and navigation](aruco.md). diff --git a/docs/ru/simple_offboard.md b/docs/ru/simple_offboard.md index 29938e25..c9d51474 100644 --- a/docs/ru/simple_offboard.md +++ b/docs/ru/simple_offboard.md @@ -305,6 +305,16 @@ rosservice call /land "{}" > **Caution** В более новых версиях PX4 коптер выйдет из режима LAND в ручной режим, если сильно перемещать стики. +### release + +В случае необходимости приостановки отправки setpoint-сообщений, используйте сервис `simple_offboard/release`: + +```python +release = rospy.ServiceProxy('simple_offboard/release', Trigger) + +release() +``` + ## Дополнительные материалы * [Полеты в поле ArUco-маркеров](aruco.md). From 4e9d8a64d0141eced651557670418faaace42ff7 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Thu, 13 Oct 2022 00:08:35 +0600 Subject: [PATCH 6/6] simple_offboard: test for simple_offboard/release service presence --- clover/test/basic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/clover/test/basic.py b/clover/test/basic.py index 5d9d6c29..21440bd2 100755 --- a/clover/test/basic.py +++ b/clover/test/basic.py @@ -24,6 +24,7 @@ def test_simple_offboard_services_available(): rospy.wait_for_service('set_attitude', timeout=5) rospy.wait_for_service('set_rates', timeout=5) rospy.wait_for_service('land', timeout=5) + rospy.wait_for_service('simple_offboard/release', timeout=5) def test_web_video_server(node): try: