Compare commits

..

58 Commits

Author SHA1 Message Date
Oleg Kalachev
50b9ad3ad8 Merge branch 'v0.24-release' into simple-offboard-update 2022-12-29 05:56:02 +03:00
Oleg Kalachev
b0021583c2 Add heading towards flight into autotest_flight 2022-12-29 05:51:57 +03:00
Oleg Kalachev
7cbd7e5d3f Handle yaw for navigate_target more smart for yaw rate and towards setpoints 2022-12-29 05:51:09 +03:00
Oleg Kalachev
34dd5d6c60 Comment 2022-12-29 05:50:30 +03:00
Oleg Kalachev
87de227553 Add const qualifier for speed in getNavigateSetpoint 2022-12-24 00:42:18 +03:00
Oleg Kalachev
55b613da23 Fix 2022-12-24 00:41:56 +03:00
Oleg Kalachev
d66eda5cd2 Head target frame forward when yaw forward 2022-12-24 00:32:42 +03:00
Oleg Kalachev
90620d148f Fix avoiding TF_REPEATED in publishing setpoint frame 2022-12-22 22:53:18 +03:00
Oleg Kalachev
d73b627579 Add terrain frame to blocks 2022-12-21 22:12:57 +03:00
Oleg Kalachev
66d4839f81 Use set_yaw in blocks 2022-12-21 20:56:44 +03:00
Oleg Kalachev
5a98e1ab78 Remove yaw_rate from navigate and use set_yaw in examples 2022-12-21 20:50:43 +03:00
Oleg Kalachev
84b085352e Whitespaces fixes 2022-12-21 20:49:46 +03:00
Oleg Kalachev
da4c722a70 Stop publishing setpoints when land called 2022-12-20 13:39:57 +03:00
Oleg Kalachev
6474a61544 Implement set_yaw and set_yaw_rate services, remove yaw_rate from other services 2022-12-20 12:37:05 +03:00
Oleg Kalachev
df6ecdb594 Update comment 2022-12-20 12:29:45 +03:00
Oleg Kalachev
d4f1706e0c Simplify code 2022-12-20 12:25:11 +03:00
Oleg Kalachev
e2536395e7 Fix tests 2022-12-19 21:50:53 +03:00
Oleg Kalachev
56db20c87d Remove redundant check 2022-12-19 21:48:47 +03:00
Oleg Kalachev
0b6dc17c4b Add terrain frame 2022-12-19 19:21:19 +03:00
Oleg Kalachev
62e3954805 Make set_altitude not to change current mode 2022-12-19 19:20:58 +03:00
Oleg Kalachev
288667a08d Allow speed be nan 2022-12-19 18:36:40 +03:00
Oleg Kalachev
26d65407fe Tests for set_altitude 2022-12-19 18:34:21 +03:00
Oleg Kalachev
5fa1f35e42 Fix include 2022-12-19 18:33:36 +03:00
Oleg Kalachev
758fd204f6 Bring back mistakenly remove line 2022-12-17 13:52:38 +03:00
Oleg Kalachev
f767ae0068 Whitespace fix 2022-12-17 05:28:24 +03:00
Oleg Kalachev
041560d971 Add set_altitude service 2022-12-16 20:41:37 +03:00
Oleg Kalachev
794fa264b4 Remove unused label 2022-12-16 14:38:26 +03:00
Oleg Kalachev
7e3ffc9626 Make release service invalidate position setpoint 2022-12-15 19:44:10 +03:00
Oleg Kalachev
323c1da325 Set correct order for pitch and roll everywhere to match XYZ convention 2022-12-15 19:35:23 +03:00
Oleg Kalachev
c004165eb0 Test with additional frame 2022-12-15 18:39:49 +03:00
Oleg Kalachev
86ad467460 More tests 2022-12-15 18:27:20 +03:00
Oleg Kalachev
716e50ae02 Tests for partial navigate 2022-12-15 18:23:32 +03:00
Oleg Kalachev
629ad72f8f Fix state.z 2022-12-15 18:23:15 +03:00
Oleg Kalachev
5d9a20497d Test for body frame 2022-12-15 17:53:18 +03:00
Oleg Kalachev
b99eee81ad Invalidate setpoint position on land, set_velocity, set_attitude, set_rates, and auto_arm=true 2022-12-15 17:14:31 +03:00
Oleg Kalachev
ffac7a721a Fix whitespace 2022-12-15 15:37:33 +03:00
Oleg Kalachev
22542dab2f Refactor simple_offboard: allow setting almost all the parameters to NaNs 2022-12-13 08:36:03 +03:00
Oleg Kalachev
00c35aff05 Test for navigate_target frame 2022-12-12 04:05:57 +03:00
Oleg Kalachev
288bd3d06b Tests 2022-12-11 16:06:25 +03:00
Oleg Kalachev
7cd8f2501e Tests 2022-12-11 13:47:30 +03:00
Oleg Kalachev
b36b1de5e4 setpoint_position_transformed => setpoint_position_local 2022-12-09 07:53:03 +03:00
Oleg Kalachev
6899093c43 Simplify publish code 2022-12-08 11:53:59 +03:00
Oleg Kalachev
3ebb5faa2a Remove unused variable 2022-12-08 11:52:01 +03:00
Oleg Kalachev
a1c7976ee3 Remove global att_raw_msg variable 2022-12-08 11:44:33 +03:00
Oleg Kalachev
3c21c5ea71 Add test for set_rates thrust output 2022-12-08 11:44:02 +03:00
Oleg Kalachev
2a74940140 Change thrust_msg to setpoint_thrust 2022-12-08 11:40:02 +03:00
Oleg Kalachev
68677fccdc Ensure set_rates arguments are not inf 2022-12-08 10:12:18 +03:00
Oleg Kalachev
051d094f37 Test set_attitude output messages 2022-12-08 09:12:20 +03:00
Oleg Kalachev
db293545df Comments 2022-12-08 08:52:30 +03:00
Oleg Kalachev
325d1c317b Allow using nans in set_rates 2022-12-08 08:51:58 +03:00
Oleg Kalachev
7980773d95 Fix 2022-12-08 08:49:48 +03:00
Oleg Kalachev
aa595f799e Fix 2022-12-08 08:37:20 +03:00
Oleg Kalachev
6a0753b1d2 Basic test for set_attitude 2022-12-08 08:15:59 +03:00
Oleg Kalachev
d1c39bb379 Add minor clarification comment 2022-12-08 08:14:49 +03:00
Oleg Kalachev
7afeff0633 Add simple_offboard/state topic publishing and some tests 2022-12-06 10:50:30 +03:00
Oleg Kalachev
201a20fe71 Split up setpoint to position and altitude 2022-12-06 09:39:37 +03:00
Oleg Kalachev
944cd28dba Add essential simple_offboard tests 2022-12-05 10:34:32 +03:00
Oleg Kalachev
27f6836ca8 Move setpoint_yaw_rate to setpoint_rates common for all commands 2022-11-25 02:54:27 +01:00
10 changed files with 3 additions and 161 deletions

View File

@@ -1,97 +0,0 @@
# This example makes the drone find and follow the red circle.
# To test in the simulator, place 'Red Circle' model on the floor.
# More information: https://clover.coex.tech/red_circle
# Input topic: main_camera/image_raw (camera image)
# Output topics:
# cv/mask (red color mask)
# cv/red_circle (position of the center of the red circle in 3D space)
import rospy
import cv2
import numpy as np
from math import nan
from sensor_msgs.msg import Image, CameraInfo
from geometry_msgs.msg import PointStamped, Point
from cv_bridge import CvBridge
from clover import long_callback, srv
import tf2_ros
import tf2_geometry_msgs
rospy.init_node('cv', disable_signals=True) # disable signals to allow interrupting with ctrl+c
get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry)
set_position = rospy.ServiceProxy('set_position', srv.SetPosition)
bridge = CvBridge()
tf_buffer = tf2_ros.Buffer()
tf_listener = tf2_ros.TransformListener(tf_buffer)
mask_pub = rospy.Publisher('~mask', Image, queue_size=1)
point_pub = rospy.Publisher('~red_circle', PointStamped, queue_size=1)
# read camera info
camera_info = rospy.wait_for_message('main_camera/camera_info', CameraInfo)
camera_matrix = np.float64(camera_info.K).reshape(3, 3)
distortion = np.float64(camera_info.D).flatten()
def img_xy_to_point(xy, dist):
xy = cv2.undistortPoints(xy, camera_matrix, distortion, P=camera_matrix)[0][0]
# Shift points to center
xy -= camera_info.width // 2, camera_info.height // 2
fx = camera_matrix[0, 0]
fy = camera_matrix[1, 1]
return Point(x=xy[0] * dist / fx, y=xy[1] * dist / fy, z=dist)
def get_center_of_mass(mask):
M = cv2.moments(mask)
if M['m00'] == 0:
return None
return M['m10'] // M['m00'], M['m01'] // M['m00']
follow_red_circle = False
@long_callback
def image_callback(msg):
img = bridge.imgmsg_to_cv2(msg, 'bgr8')
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# we need to use two ranges for red color
mask1 = cv2.inRange(img_hsv, (0, 150, 150), (15, 255, 255))
mask2 = cv2.inRange(img_hsv, (160, 150, 150), (180, 255, 255))
# combine two masks using bitwise OR
mask = cv2.bitwise_or(mask1, mask2)
# publish the mask
if mask_pub.get_num_connections() > 0:
mask_pub.publish(bridge.cv2_to_imgmsg(mask, 'mono8'))
# calculate x and y of the circle
xy = get_center_of_mass(mask)
if xy is None:
return
# calculate and publish the position of the circle in 3D space
altitude = get_telemetry('terrain').z
xy3d = img_xy_to_point(xy, altitude)
target = PointStamped(header=msg.header, point=xy3d)
point_pub.publish(target)
if follow_red_circle:
# follow the target
setpoint = tf_buffer.transform(target, 'map', timeout=rospy.Duration(0.2))
set_position(x=setpoint.point.x, y=setpoint.point.y, z=nan, yaw=nan, frame_id=setpoint.header.frame_id)
# process each camera frame:
image_sub = rospy.Subscriber('main_camera/image_raw', Image, image_callback, queue_size=1)
rospy.loginfo('Hit enter to follow the red circle')
input()
follow_red_circle = True
rospy.spin()

View File

@@ -31,7 +31,7 @@ param set-default EKF2_OF_DELAY 0
param set-default EKF2_OF_QMIN 10
param set-default EKF2_OF_N_MIN 0.05
param set-default EKF2_OF_N_MAX 0.2
param set-default EKF2_HGT_MODE 3 # 0 = baro, 1 = gps, 2 = range, 3 = vision
param set-default EKF2_HGT_MODE 2 # 0 = baro, 1 = gps, 2 = range, 3 = vision
param set-default EKF2_EVA_NOISE 0.1
param set-default EKF2_EVP_NOISE 0.1
param set-default EKF2_EV_DELAY 0

View File

@@ -1,16 +0,0 @@
material red_circle
{
technique
{
pass
{
scene_blend alpha_blend
texture_unit
{
texture red_circle.png
filtering none
scale 1.0 1.0
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

View File

@@ -1,13 +0,0 @@
<?xml version="1.0"?>
<model>
<name>Red Circle</name>
<version>1.0</version>
<sdf version="1.5">red_circle.sdf</sdf>
<author>
<name>Oleg Kalachev</name>
<email>okalachev@gmail.com</email>
</author>
<description>
Red circle of size 40 cm on the floor for recognizing by a drone
</description>
</model>

View File

@@ -1,24 +0,0 @@
<?xml version="1.0"?>
<sdf version="1.5">
<model name="red_circle">
<static>true</static>
<link name="red_circle_link">
<pose>0 0 1e-3 0 0 0</pose>
<visual name="red_circle_texture">
<cast_shadows>false</cast_shadows>
<geometry>
<box>
<size>0.4 0.4 1e-3</size>
</box>
</geometry>
<material>
<script>
<uri>model://red_circle/materials/scripts</uri>
<uri>model://red_circle/materials/textures</uri>
<name>red_circle</name>
</script>
</material>
</visual>
</link>
</model>
</sdf>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<title>
red_circle
</title><g fill="red">
<circle cx="10.05" cy="10.05" r="9.9"/>
</g></svg>

Before

Width:  |  Height:  |  Size: 221 B

View File

@@ -44,7 +44,7 @@ In case of using EKF2 (official firmware):
|`EKF2_OF_QMIN`|10||
|`EKF2_OF_N_MIN`|0.05||
|`EKF2_OF_N_MAX`|0.2||
|`EKF2_HGT_MODE`|3 (*Vision*)|If the [rangefinder](laser.md) is present and flying over horizontal floor  2 (*Range sensor*)|
|`EKF2_HGT_MODE`|2 (*Range sensor*)|If the [rangefinder](laser.md) is present and flying over horizontal floor|
|`EKF2_EVA_NOISE`|0.1||
|`EKF2_EVP_NOISE`|0.1||
|`EKF2_EV_DELAY`|0||

View File

@@ -44,7 +44,7 @@
|`EKF2_OF_QMIN`|10||
|`EKF2_OF_N_MIN`|0.05||
|`EKF2_OF_N_MAX`|0.2||
|`EKF2_HGT_MODE`|3 (*Vision*)|При наличии [дальномера](laser.md) и полете над ровным полом — 2 (*Range sensor*)|
|`EKF2_HGT_MODE`|2 (*Range sensor*)|При наличии [дальномера](laser.md) и полете над ровным полом|
|`EKF2_EVA_NOISE`|0.1||
|`EKF2_EVP_NOISE`|0.1||
|`EKF2_EV_DELAY`|0||

View File

@@ -65,7 +65,6 @@
{ "from": "clover_vm/", "to": "en/simulation_vm.html" },
{ "from": "gpio/", "to": "en/gpio.html" },
{ "from": "blocks/", "to": "en/blocks.html" },
{ "from": "red_circle/", "to": "en/camera.html" },
{ "from": "ru/microsd_images.html", "to": "image.html" },
{ "from": "en/microsd_images.html", "to": "image.html" },