Comments (3)
You could have your BT that takes in the set of goals
publish out the goals
vector that the MPC can listen to so that when it receives the path, its knows which points belong to the waypoints and which are path-planned points. You could do that right before calling the MPC controller so you know its received before that is attempted to start tracking it. To guarantee that, you could make it a service & the Nav2 BT tools provides a base class to make service calls easy.
Basically all you need to do is make a ~20 line BT node, add it to your BT XML right before sending the path to the controller, and then make a service/subscription in the MPC plugin that stores that information. Then you should be good to go 😄
from navigation2.
Thank you for this solution. I tried to implement such a BT node and ran into the problem, that cmake doesn't find the package behaviortree_cpp.
If you need more details:
I used remove_passed_goals_action.hpp and remove_passed_goals_action.cpp as a starting point to copy and modify it to what I need. For the CMakeList, I used this for guidance. My whole CMakeList.txt now looks like this:
cmake_minimum_required(VERSION 3.8)
project(nav2_controller_mpc_w_dyn_obstacles)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(nav2_common REQUIRED)
find_package(nav2_core REQUIRED)
find_package(nav2_costmap_2d REQUIRED)
find_package(nav2_util REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(pluginlib REQUIRED)
find_package(tf2 REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclpy REQUIRED)
find_package(var_predictor_interfaces REQUIRED)
find_package(nav2_mpc_interface REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(behaviortree_cpp REQUIRED)
nav2_package()
include_directories(
include
)
set(dependencies
rclcpp
geometry_msgs
nav2_costmap_2d
pluginlib
nav_msgs
std_msgs
nav2_util
nav2_core
tf2
var_predictor_interfaces
nav2_mpc_interface
rclcpp_action
rclcpp_lifecycle
behaviortree_cpp
)
add_library(nav2_controller_mpc_w_dyn_obstacles SHARED
src/nav2_controller_mpc_w_dyn_obstacles.cpp)
# prevent pluginlib from using boost
target_compile_definitions(nav2_controller_mpc_w_dyn_obstacles PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")
ament_target_dependencies(nav2_controller_mpc_w_dyn_obstacles
${dependencies}
)
add_library(bt_waypoint_pub_bt_node SHARED src/bt_waypoint_pub.cpp)
ament_target_dependencies(bt_waypoint_pub_bt_node ${dependencies})
target_compile_definitions(bt_waypoint_pub_bt_node PRIVATE BT_PLUGIN_EXPORT)
install(TARGETS nav2_controller_mpc_w_dyn_obstacles bt_waypoint_pub_bt_node
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY include/
DESTINATION include/
)
ament_python_install_package(${PROJECT_NAME})
install(PROGRAMS
nav2_controller_mpc_w_dyn_obstacles/vel_smoother_integrator.py
nav2_controller_mpc_w_dyn_obstacles/mpc_calculation_node.py
nav2_controller_mpc_w_dyn_obstacles/define_mpc.py
DESTINATION lib/${PROJECT_NAME}
)
install(
DIRECTORY launch behavior_trees
DESTINATION share/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_export_include_directories(include)
ament_export_libraries(nav2_controller_mpc_w_dyn_obstacles bt_waypoint_pub_bt_node)
ament_export_dependencies(${dependencies})
pluginlib_export_plugin_description_file(nav2_core nav2_controller_mpc_w_dyn_obstacles.xml)
ament_package()
from navigation2.
I know it sounds like a dumb question, but is it installed? Also its behaviortree_cpp_v3
for Humble https://github.com/ros-navigation/navigation2/blob/humble/nav2_behavior_tree/CMakeLists.txt#L37
Make sure to reference the right branch for your distribution :-)
Closing since I think this is answered, but feel free to comment back if you need anything else! I'd love to see a link to your MPC controller / BT use once its ready (if its open-source)! We definitely need more controller options in the ROS 2 ecosystem :-)
from navigation2.
Related Issues (20)
- Nav2 Docking: The docking_server does not work if you do not define instances of docks using the DockDatabase HOT 4
- Services for `get_costmap` are advertised with same name HOT 1
- Problems with Reverse Motion for Ackermann Steering Vehicles Using Nav2 MPPI Controller HOT 6
- Navigation2 for Jazzy HOT 4
- NAV2 Doesn't Abort The NAV2 Goal HOT 1
- ROS1 leftovers HOT 1
- Use static map in outdoor environment without fixed initial pose HOT 2
- Add missing descriptions to package.xml
- NullPtr bug during the `computeVelocityCommands()` during shutdown HOT 5
- NullPtr bug during the `getRobotPose()` calculation of `costmap_ros_` in `nav2_controller` HOT 4
- NullPtr bug during the `computeVelocityCommands()` calculation of `nav2_regulated_pure_pursuit_controller` HOT 1
- controller_server `computeControl()` blocks simple_action_server `work()` HOT 1
- cross-compiling ros2-humble nav2_costmap_2d error HOT 1
- Docking - Unexpected behavior when trying to dock while already docked or undock while already not docked HOT 4
- Port nav2 systems test to new gazebo HOT 1
- Dockerfile buid warnings
- Invalidate Pointer Accessed during `isUnsafeToPlan()` calculation of `nav2_theta_planner` HOT 1
- Obstacle Layer is still current after enable/disable
- NullPointer Accessed during `makePlan` calculation of nav2_navfn_planner HOT 1
- NullPointer Accessed during `findCircumscribedCost` calculation of nav2_smac_planner HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from navigation2.