Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joystick #273

Merged
merged 8 commits into from
Aug 11, 2023
Merged

Joystick #273

merged 8 commits into from
Aug 11, 2023

Conversation

NannCai
Copy link

@NannCai NannCai commented Aug 8, 2023

The takeoff height, duration and the function of different buttons of the joystick can be changed in teleop.yaml.

@NannCai NannCai marked this pull request as ready for review August 8, 2023 11:58
Copy link

@whoenig whoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job overall - thanks! Minor changes requested before we can merge.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't include any .vscode file

crazyflie/config/teleop.yaml Outdated Show resolved Hide resolved
duration: 1.0
height: 0.25
button: 6 # 7 start
land_paras:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

land:

button: 6 # 7 start
land_paras:
button: 7 # 6 back
emergency_paras:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emergency

('notify_setpoints_stop', 'cf6/notify_setpoints_stop'),
('takeoff', 'all/takeoff'),
('land', 'all/land'),
('cmd_vel_legacy', 'all/cmd_vel_legacy'),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those two should not be changed to all.

request->height = 0.5;
request->duration = rclcpp::Duration::from_seconds(2);
request->height = takeoff_paras_.height;
request->duration = rclcpp::Duration::from_seconds(takeoff_paras_.duration);
client_takeoff_->async_send_request(request);

timer_takeoff_ = this->create_wall_timer(2s, [this]() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 2s also needs to be changed

client_takeoff_->async_send_request(request);

timer_takeoff_ = this->create_wall_timer(2s, [this]() {
state_.z = 0.5;
state_.z = takeoff_paras_.height; // Is here right? should I change the 2s in line 293
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is correct, and yes, the 2s also need to be changed.

@NannCai NannCai requested a review from whoenig August 9, 2023 08:54
Copy link

@whoenig whoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - thanks! I'll merge once the CI is happy.

Copy link

@whoenig whoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing: please use as default values the ones we had before for the button mapping, otherwise users will be very surprised.

@NannCai NannCai requested a review from whoenig August 10, 2023 11:50
Copy link

@whoenig whoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a compiler error, see comments.

client_takeoff_->async_send_request(request);

timer_takeoff_ = this->create_wall_timer(2s, [this]() {
state_.z = 0.5;
timer_takeoff_ = this->create_wall_timer(takeoff_paras_.duration, [this]() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work for your locally? The CI reports the following error:

 [  8%] Building CXX object deps/crazyflie_tools/crazyflie_cpp/crazyflie-link-cpp/CMakeFiles/crazyflieLinkCpp.dir/src/Connection.cpp.o
  /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp: In member function ‘void TeleopNode::takeoff()’:
  /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp:297:10: error: no matching function for call to ‘TeleopNode::create_wall_timer(float&, TeleopNode::takeoff()::<lambda()>)’
    297 |         });
        |          ^
  In file included from /opt/ros/galactic/include/rclcpp/node.hpp:1329,
                   from /opt/ros/galactic/include/rclcpp/executors/single_threaded_executor.hpp:28,
                   from /opt/ros/galactic/include/rclcpp/executors.hpp:22,
                   from /opt/ros/galactic/include/rclcpp/rclcpp.hpp:156,
                   from /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp:5:
  /opt/ros/galactic/include/rclcpp/node_impl.hpp:111:1: note: candidate: ‘template<class DurationRepT, class DurationT, class CallbackT> typename rclcpp::WallTimer<CallbackT>::SharedPtr rclcpp::Node::create_wall_timer(std::chrono::duration<_Rep1, _Period1>, CallbackT, rclcpp::CallbackGroup::SharedPtr)’
    111 | Node::create_wall_timer(
        | ^~~~
  /opt/ros/galactic/include/rclcpp/node_impl.hpp:111:1: note:   template argument deduction/substitution failed:
  /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp:297:10: note:   mismatched types ‘std::chrono::duration<_Rep1, _Period1>’ and ‘float’
    297 |         });
        |          ^
  [ 11%] Building CXX object deps/crazyflie_tools/crazyflie_cpp/crazyflie-link-cpp/CMakeFiles/crazyflieLinkCpp.dir/src/USBDevice.cpp.o
  [ 13%] Building CXX object deps/crazyflie_tools/crazyflie_cpp/crazyflie-link-cpp/CMakeFiles/crazyflieLinkCpp.dir/src/Crazyradio.cpp.o
  [ 16%] Building CXX object deps/crazyflie_tools/crazyflie_cpp/crazyflie-link-cpp/CMakeFiles/crazyflieLinkCpp.dir/src/CrazyradioThread.cpp.o
  [ 19%] Building CXX object deps/crazyflie_tools/crazyflie_cpp/crazyflie-link-cpp/CMakeFiles/crazyflieLinkCpp.dir/src/CrazyflieUSB.cpp.o
  [ 22%] Building CXX object deps/crazyflie_tools/crazyflie_cpp/crazyflie-link-cpp/CMakeFiles/crazyflieLinkCpp.dir/src/CrazyflieUSBThread.cpp.o
  make[2]: *** [CMakeFiles/teleop.dir/build.make:63: CMakeFiles/teleop.dir/src/teleop.cpp.o] Error 1
  make[1]: *** [CMakeFiles/Makefile2:184: CMakeFiles/teleop.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....
  [ 25%] Building CXX object deps/crazyflie_tools/crazyflie_cpp/crazyflie-link-cpp/CMakeFiles/crazyflieLinkCpp.dir/src/Version.cpp.o
  [ 27%] Linking CXX static library libcrazyflieLinkCpp.a
  [ 27%] Built target crazyflieLinkCpp
  make: *** [Makefile:141: all] Error 2
  ---
  --- stderr: crazyflie
  /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp: In member function ‘void TeleopNode::takeoff()’:
  /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp:297:10: error: no matching function for call to ‘TeleopNode::create_wall_timer(float&, TeleopNode::takeoff()::<lambda()>)’
    297 |         });
        |          ^
  In file included from /opt/ros/galactic/include/rclcpp/node.hpp:1329,
                   from /opt/ros/galactic/include/rclcpp/executors/single_threaded_executor.hpp:28,
                   from /opt/ros/galactic/include/rclcpp/executors.hpp:22,
                   from /opt/ros/galactic/include/rclcpp/rclcpp.hpp:156,
                   from /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp:5:
  /opt/ros/galactic/include/rclcpp/node_impl.hpp:111:1: note: candidate: ‘template<class DurationRepT, class DurationT, class CallbackT> typename rclcpp::WallTimer<CallbackT>::SharedPtr rclcpp::Node::create_wall_timer(std::chrono::duration<_Rep1, _Period1>, CallbackT, rclcpp::CallbackGroup::SharedPtr)’
    111 | Node::create_wall_timer(
        | ^~~~
  /opt/ros/galactic/include/rclcpp/node_impl.hpp:111:1: note:   template argument deduction/substitution failed:
  /__w/crazyswarm2/crazyswarm2/ros_ws/src/ypobr1p6gmn/crazyswarm2/crazyflie/src/teleop.cpp:297:10: note:   mismatched types ‘std::chrono::duration<_Rep1, _Period1>’ and ‘float’
    297 |         });
        |          ^
  make[2]: *** [CMakeFiles/teleop.dir/build.make:63: CMakeFiles/teleop.dir/src/teleop.cpp.o] Error 1
  make[1]: *** [CMakeFiles/Makefile2:184: CMakeFiles/teleop.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:141: all] Error 2
  ---
  Failed   <<< crazyflie [11.7s, exited with code 2]

@NannCai NannCai requested a review from whoenig August 11, 2023 12:22
@NannCai
Copy link
Author

NannCai commented Aug 11, 2023

Sorry, I fixed the bug and it works for me now. Could you please try again?

@whoenig whoenig merged commit 9483029 into IMRCLab:main Aug 11, 2023
2 checks passed
@whoenig
Copy link

whoenig commented Aug 11, 2023

Thanks!

boomer319 pushed a commit to boomer319/verrueckterschwarm2 that referenced this pull request Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants