diff --git a/book.json b/book.json index 3e74303d..8b5f2ff9 100644 --- a/book.json +++ b/book.json @@ -2,7 +2,7 @@ "title": "Clever", "description": "Конструктор квадрокоптера «Клевер»", "author": "Copter Express", - "language": "ru", + "language": "en", "root": "docs/", "gitbook": "^3.2.2", "plugins": [ diff --git a/builder/test/tests.py b/builder/test/tests.py index 50e5f457..6d7f6e60 100755 --- a/builder/test/tests.py +++ b/builder/test/tests.py @@ -15,7 +15,7 @@ from mavros_msgs.srv import CommandBool, CommandLong, SetMode from std_srvs.srv import Trigger from clever.srv import GetTelemetry, Navigate, NavigateGlobal, SetPosition, SetVelocity, \ - SetAttitude, SetRates + SetAttitude, SetRates, SetLEDEffect import tf2_ros import tf2_geometry_msgs diff --git a/clever/src/led.cpp b/clever/src/led.cpp index 92d01281..e72354d3 100644 --- a/clever/src/led.cpp +++ b/clever/src/led.cpp @@ -230,7 +230,7 @@ void handleState(const led_msgs::LEDStateArray& msg) led_count = state.leds.size(); } -bool notify(const std::string& event) +void notify(const std::string& event) { if (ros::param::has("~notify/" + event + "/effect") || ros::param::has("~notify/" + event + "/r") || diff --git a/clever/src/selfcheck.py b/clever/src/selfcheck.py index 2aff0fb1..5b9c58fa 100755 --- a/clever/src/selfcheck.py +++ b/clever/src/selfcheck.py @@ -477,7 +477,7 @@ def check_local_position(): @check('Velocity estimation') def check_velocity(): try: - velocity = rospy.wait_for_message('mavros/local_position/velocity', TwistStamped, timeout=1) + velocity = rospy.wait_for_message('mavros/local_position/velocity_local', TwistStamped, timeout=1) horiz = math.hypot(velocity.twist.linear.x, velocity.twist.linear.y) vert = velocity.twist.linear.z if abs(horiz) > 0.1: @@ -485,6 +485,7 @@ def check_velocity(): if abs(vert) > 0.1: failure('vertical velocity estimation is %.2f m/s; is copter staying still?' % vert) + velocity = rospy.wait_for_message('mavros/local_position/velocity_body', TwistStamped, timeout=1) angular = velocity.twist.angular ANGULAR_VELOCITY_LIMIT = 0.1 if abs(angular.x) > ANGULAR_VELOCITY_LIMIT: diff --git a/clever/src/vpe_publisher.cpp b/clever/src/vpe_publisher.cpp index 34f54152..580a5f4e 100644 --- a/clever/src/vpe_publisher.cpp +++ b/clever/src/vpe_publisher.cpp @@ -19,11 +19,13 @@ #include #include #include +#include // #include using std::string; using namespace geometry_msgs; +bool reset_flag = false; string local_frame_id, frame_id, child_frame_id, offset_frame_id; tf2_ros::Buffer tf_buffer; ros::Publisher vpe_pub; @@ -84,13 +86,14 @@ void callback(const T& msg) // offset if (!offset_frame_id.empty()) { - if (msg->header.stamp - vpe.header.stamp > offset_timeout) { + if (reset_flag || msg->header.stamp - vpe.header.stamp > offset_timeout) { // calculate the offset offset = tf_buffer.lookupTransform(local_frame_id, frame_id, msg->header.stamp, ros::Duration(0.02)); // offset.header.frame_id = vpe.header.frame_id; offset.child_frame_id = offset_frame_id; br.sendTransform(offset); + reset_flag = false; ROS_INFO("offset reset"); } // apply the offset @@ -106,6 +109,13 @@ void callback(const T& msg) } } +bool reset(std_srvs::Trigger::Request& req, std_srvs::Trigger::Response& res) +{ + reset_flag = true; + res.success = true; + return true; +} + int main(int argc, char **argv) { ros::init(argc, argv, "vpe_publisher"); ros::NodeHandle nh, nh_priv("~"); @@ -139,6 +149,8 @@ int main(int argc, char **argv) { local_position_sub = nh.subscribe("mavros/local_position/pose", 1, &localPositionCallback); } + auto reset_serv = nh_priv.advertiseService("reset", &reset); + ROS_INFO("ready"); ros::spin(); } diff --git a/docs/en/aruco_map.md b/docs/en/aruco_map.md index 300333d0..cd6a97ca 100644 --- a/docs/en/aruco_map.md +++ b/docs/en/aruco_map.md @@ -120,6 +120,13 @@ time.sleep(5) navigate(2, 2, 2, speed=1, frame_id='aruco_map') ``` +Starting from the [image](image.md) version 0.18, the drone also can fly relative to a marker in the map, even if it doesn't see it: + +```python +# Fly to 1 meter above the marker 5 +navigate(frame_id='aruco_5', x=0, y=0, z=1) +``` + ## Additional settings If the drone's position is not stable when VPE is used, try increasing the *P* term in the velocity PID regulator: increase the `MPC_XY_VEL_P` and `MPC_Z_VEL_P` parameters. diff --git a/docs/en/sonar.md b/docs/en/sonar.md index bc515dfd..1ec802d5 100644 --- a/docs/en/sonar.md +++ b/docs/en/sonar.md @@ -70,6 +70,7 @@ def fall(gpio, level, tick): done.set() def read_distance(): + global low done.clear() pi.gpio_trigger(TRIG, 50, 1) done.wait(timeout=5) diff --git a/docs/ru/aruco_map.md b/docs/ru/aruco_map.md index ba0ec89c..f531f3b0 100644 --- a/docs/ru/aruco_map.md +++ b/docs/ru/aruco_map.md @@ -128,6 +128,13 @@ time.sleep(5) navigate(2, 2, 2, speed=1, frame_id='aruco_map') # полет в координату 2:2, высота 3 метра ``` +Начиная с версии [образа](image.md) 0.18, доступны также полеты относительно отдельного маркера в карте, даже если дрон его не видит: + +```python +# Полет на высоту 1 м над маркером 5 +navigate(frame_id='aruco_5', x=0, y=0, z=1) +``` + ## Дополнительные настройки diff --git a/docs/ru/sonar.md b/docs/ru/sonar.md index 8d92ddce..be979100 100644 --- a/docs/ru/sonar.md +++ b/docs/ru/sonar.md @@ -70,6 +70,7 @@ def fall(gpio, level, tick): done.set() def read_distance(): + global low done.clear() pi.gpio_trigger(TRIG, 50, 1) done.wait(timeout=5) diff --git a/redirects.json b/redirects.json index 24d10962..e6dd4a11 100644 --- a/redirects.json +++ b/redirects.json @@ -1,6 +1,5 @@ { "redirects": [ - { "from": "index.html", "to": "ru/index.html" }, { "from": "assemble.html", "to": "ru/assemble_2.html" }, { "from": "assemble_clever3_4in1.html", "to": "ru/assemble_3.html" }, { "from": "glossary.html", "to": "ru/gloss.html" },