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

[WIP] World Model refactor and new features #516

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
58513fd
Created a base class for world representations
orduno Dec 20, 2018
6447ce2
Addressing compilation errors
orduno Dec 21, 2018
a2cedc7
Fixed runtime bug
orduno Dec 21, 2018
5535940
Adding a world model client class
orduno Dec 21, 2018
b4fe663
Implemented check for free space
orduno Dec 26, 2018
d08d07c
Started implementing the motion primitive side
orduno Dec 26, 2018
92df77a
Adding publishers to visualize regions in RVIZ
orduno Dec 28, 2018
d9670a1
Removed publisher on world_model
orduno Dec 28, 2018
de51b8c
Adding example of world model client to DWB
orduno Dec 28, 2018
3f6901d
Fixed bug
orduno Dec 31, 2018
5497dbf
Added region rotation
orduno Dec 31, 2018
55da1bb
Cleaned up function
orduno Jan 2, 2019
fd2e903
Enabling marker array publishing
orduno Jan 2, 2019
5600606
Fixed bug with offsetting of region
orduno Jan 2, 2019
4a6c9f6
Minor fixes
orduno Jan 4, 2019
2e91db3
Made the marker visualization a separate class
orduno Jan 4, 2019
23bf5de
Adding check for free space before executing primitive
orduno Jan 4, 2019
03e1b69
Cleaned functions inside world model. DWB is now checking free space …
orduno Jan 7, 2019
9d202c5
Fixed bug of backup primitive using world model
orduno Jan 7, 2019
4542a4a
Fixed linter errors
orduno Jan 7, 2019
98a33f4
Removed unnecessary file
orduno Jan 8, 2019
fc01f1b
Fixed linter failures
orduno Jan 8, 2019
ad8dbc7
Removed world model client from DWB
orduno Jan 10, 2019
ff9f3db
Removed checking for robot initial pose from motion primitives
orduno Jan 11, 2019
25bb1d7
Added more detail to TODO comments on spin primitive
orduno Jan 11, 2019
4840edf
Changed default resolution for the planner costmap request
orduno Jan 11, 2019
07ff376
Changed ProcessRegion service signature
orduno Jan 11, 2019
231d53b
Modified the signature of the internal world model service clients
orduno Jan 11, 2019
ff28d06
Removed MapLocation() constructor
orduno Jan 11, 2019
a6cacee
Modified costmap to use the new MapLocation constructor
orduno Jan 11, 2019
af0b396
Minor code cleanup
orduno Jan 11, 2019
38d9b6b
Addressing pull request feedback
orduno Jan 11, 2019
14927e7
Renamed Point class to Point2D
orduno Jan 11, 2019
71d4c91
Fixing rebase conflicts mainly on the backup primitive.
orduno Jan 14, 2019
f20121d
Fixed bug
orduno Jan 14, 2019
5fdbd57
fixed typo
orduno Jan 17, 2019
91ba671
Removed clear area service placeholders
orduno Jan 24, 2019
d947fd9
Fixed typo
orduno Jan 24, 2019
8ba2821
Adding method for getting robot width
orduno Jan 24, 2019
88dea35
Added comments, fixed typo
orduno Jan 24, 2019
caaac11
Added issue number to track TODO
orduno Jan 24, 2019
cb3bc42
Addressing feedback
orduno Jan 24, 2019
905b5c3
Enabling obstacle layer in costmaps
orduno Jan 29, 2019
2c1facb
Enabling dynamic obstacle detection
orduno Jan 29, 2019
92e91bc
Using costmap centered on robot for checking free space
orduno Jan 30, 2019
f283a55
Fixing typo
orduno Jan 30, 2019
09ce837
Fixed bug
orduno Jan 31, 2019
1e01eb2
Fix linter errors
orduno Jan 31, 2019
fc522ce
Fix linter error
orduno Jan 31, 2019
14accae
Fixed typo
orduno Feb 1, 2019
1c5fc8d
Fixed typo
orduno Feb 4, 2019
a0de14e
Fixing tf listener issue
orduno Feb 6, 2019
d106d10
Fixed typo
orduno Feb 6, 2019
d8621c4
Fix linter error
orduno Feb 8, 2019
f1cd625
Addressing PR feedback
orduno Feb 13, 2019
b1163bf
Previous issue with Node constructor was solved, reverting
orduno Feb 21, 2019
ef82ba9
Changing navfn output message type
orduno Feb 21, 2019
2e9285b
Disabling dynamic params test to test my PR in CI
orduno Feb 22, 2019
c7e6145
Addressing feedback
orduno Mar 5, 2019
67a1197
A few additional simplifications
orduno Mar 5, 2019
d955c2e
Moved clients back to nav2_tasks
orduno Mar 6, 2019
361685d
Fixed linter fail
orduno Mar 6, 2019
bc04ad9
Re-enabling dynamic params tests
orduno Mar 6, 2019
b18f98a
Fixed a coordinate frame mismatch
orduno Mar 6, 2019
b9cfd4d
Addressed rebase conflicts
orduno Mar 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nav2_bringup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Set the World Model and the two costmap nodes to use simulation time
```
ros2 param set /world_model use_sim_time True
ros2 param set /global_costmap/global_costmap use_sim_time True
ros2 param set /robot_centric_costmap/robot_centric_costmap use_sim_time True
ros2 param set /local_costmap/local_costmap use_sim_time True
```

Expand Down Expand Up @@ -113,7 +114,10 @@ ros2 launch nav2_bringup nav2_bringup_launch.py map:=<full/path/to/map.yaml>
If running in simulation:
```
ros2 launch nav2_bringup nav2_bringup_launch.py map:=<full/path/to/map.yaml> use_sim_time:=True
ros2 param set /world_model use_sim_time True; ros2 param set /global_costmap/global_costmap use_sim_time True; ros2 param set /local_costmap/local_costmap use_sim_time True
ros2 param set /world_model use_sim_time True
ros2 param set /global_costmap/global_costmap use_sim_time True
ros2 param set /robot_centric_costmap/robot_centric_costmap use_sim_time True
ros2 param set /local_costmap/local_costmap use_sim_time True
```

## Future Work
Expand Down
106 changes: 78 additions & 28 deletions nav2_bringup/config/nav2_default_view.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Panels:
- /TF1/Frames1
- /TF1/Tree1
- /Global Planner1
- /Global Planner1/Global Costmap1
Splitter Ratio: 0.5833333134651184
Tree Height: 574
- /Local Planner1
- /World Model1
Splitter Ratio: 0.583333313
Tree Height: 640
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expand Down Expand Up @@ -76,10 +77,18 @@ Visualization Manager:
Value: true
base_scan:
Value: false
caster_back_link:
Value: false
imu_link:
Value: false
map:
Value: true
odom:
Value: true
wheel_left_link:
Value: false
wheel_right_link:
Value: false
Marker Scale: 1
Name: TF
Show Arrows: true
Expand All @@ -89,7 +98,17 @@ Visualization Manager:
map:
odom:
base_footprint:
{}
base_link:
base_scan:
{}
caster_back_link:
{}
imu_link:
{}
wheel_left_link:
{}
wheel_right_link:
{}
Update Interval: 0
Value: true
- Alpha: 1
Expand Down Expand Up @@ -180,16 +199,6 @@ Visualization Manager:
Value: true
- Class: rviz_common/Group
Displays:
- Alpha: 0.699999988
Class: rviz_default_plugins/Map
Color Scheme: map
Draw Behind: true
Enabled: false
Name: Global Costmap
Topic: /global_costmap/costmap
Unreliable: false
Use Timestamp: false
Value: false
- Class: rviz_default_plugins/Marker
Enabled: true
Name: PathEndPoints
Expand All @@ -198,7 +207,7 @@ Visualization Manager:
Queue Size: 10
Topic: /endpoints
Unreliable: false
Value: false
Value: true
- Alpha: 1
Buffer Length: 1
Class: rviz_default_plugins/Path
Expand All @@ -225,18 +234,18 @@ Visualization Manager:
- Alpha: 1
Class: rviz_default_plugins/Polygon
Color: 25; 255; 0
Enabled: false
Enabled: true
Name: Polygon
Topic: /global_costmap/footprint
Unreliable: false
Value: false
Value: true
Enabled: true
Name: Global Planner
- Class: rviz_common/Group
Displays:
- Alpha: 0.699999988
- Alpha: 0.5
Class: rviz_default_plugins/Map
Color Scheme: costmap
Color Scheme: map
Draw Behind: false
Enabled: true
Name: Local Costmap
Expand Down Expand Up @@ -286,6 +295,47 @@ Visualization Manager:
Value: true
Enabled: true
Name: Local Planner
- Class: rviz_common/Group
Displays:
- Alpha: 0.5
Class: rviz_default_plugins/Map
Color Scheme: costmap
Draw Behind: false
Enabled: true
Name: Global Costmap
Topic: /global_costmap/costmap
Unreliable: false
Use Timestamp: false
Value: true
- Alpha: 0.5
Class: rviz_default_plugins/Map
Color Scheme: map
Draw Behind: false
Enabled: true
Name: Robot Centric Costmap
Topic: /robot_centric_costmap/costmap
Unreliable: false
Use Timestamp: false
Value: true
- Alpha: 1
Class: rviz_default_plugins/Polygon
Color: 25; 255; 0
Enabled: true
Name: Polygon
Topic: /robot_centric_costmap/footprint
Unreliable: false
Value: true
- Class: rviz_default_plugins/Marker
Enabled: true
Name: Query
Namespaces:
{}
Queue Size: 10
Topic: /query_region
Unreliable: false
Value: true
Enabled: true
Name: World Model
Enabled: true
Global Options:
Background Color: 48; 48; 48
Expand All @@ -311,7 +361,7 @@ Visualization Manager:
Value: true
Views:
Current:
Angle: -1.57000005
Angle: -1.56999958
Class: rviz_default_plugins/TopDownOrtho
Enable Stereo Rendering:
Stereo Eye Separation: 0.0599999987
Expand All @@ -321,25 +371,25 @@ Visualization Manager:
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.00999999978
Scale: 134.638428
Scale: 150.21405
Target Frame: <Fixed Frame>
Value: TopDownOrtho (rviz_default_plugins)
X: -0.0326152146
Y: -0.0801941454
X: 0.0214617159
Y: -0.0895999148
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 914
Height: 995
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd00000004000000000000016a0000034cfc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006100fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007301000000280000034c000000d700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000034cfc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a0056006900650077007301000000280000034c000000ad00fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000003840000034c00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
QMainWindow State: 000000ff00000000fd00000004000000000000018f00000384fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006100fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000004100000384000000d700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000003f5fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a005600690065007700730000000041000003f5000000ad00fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000004640000038400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 1545
X: 2085
Y: 124
Width: 1529
X: 632
Y: 206
19 changes: 19 additions & 0 deletions nav2_bringup/launch/nav2_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,22 @@ global_costmap:
max_obstacle_height: 2.0
clearing: True
marking: True
robot_centric_costmap:
robot_centric_costmap:
ros__parameters:
width: 5
height: 5
origin_x: -2.5
origin_y: -2.5
plugin_names: ["obstacle_layer", "inflation_layer"]
plugin_types: ["nav2_costmap_2d::ObstacleLayer", "nav2_costmap_2d::InflationLayer"]
global_frame: "base_link"
obstacle_layer:
enabled: True
always_send_full_costmap: True
observation_sources: scan
scan:
topic: /scan
max_obstacle_height: 2.0
clearing: True
marking: True
5 changes: 4 additions & 1 deletion nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ namespace nav2_costmap_2d
// convenient for storing x/y point pairs
struct MapLocation
{
MapLocation(const unsigned int x, const unsigned int y)
: x(x), y(y) {}

unsigned int x;
unsigned int y;
};
Expand Down Expand Up @@ -483,7 +486,7 @@ class Costmap2D
// just push the relevant cells back onto the list
inline void operator()(unsigned int offset)
{
MapLocation loc;
MapLocation loc{0, 0};
costmap_.indexToCells(offset, loc.x, loc.y);
cells_.push_back(loc);
}
Expand Down
10 changes: 5 additions & 5 deletions nav2_costmap_2d/src/costmap_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ bool Costmap2D::setConvexPolygonCost(
// we need to transform it to map coordinates
std::vector<MapLocation> map_polygon;
for (unsigned int i = 0; i < polygon.size(); ++i) {
MapLocation loc;
MapLocation loc{0, 0};
if (!worldToMap(polygon[i].x, polygon[i].y, loc.x, loc.y)) {
// ("Polygon lies outside map bounds, so we can't fill it");
return false;
Expand Down Expand Up @@ -377,7 +377,7 @@ void Costmap2D::convexFillCells(
polygonOutlineCells(polygon, polygon_cells);

// quick bubble sort to sort points by x
MapLocation swap;
MapLocation swap{0, 0};
unsigned int i = 0;
while (i < polygon_cells.size() - 1) {
if (polygon_cells[i].x > polygon_cells[i + 1].x) {
Expand All @@ -394,8 +394,8 @@ void Costmap2D::convexFillCells(
}

i = 0;
MapLocation min_pt;
MapLocation max_pt;
MapLocation min_pt{0, 0};
MapLocation max_pt{0, 0};
unsigned int min_x = polygon_cells[0].x;
unsigned int max_x = polygon_cells[polygon_cells.size() - 1].x;

Expand Down Expand Up @@ -423,7 +423,7 @@ void Costmap2D::convexFillCells(
++i;
}

MapLocation pt;
MapLocation pt{0, 0};
// loop though cells in the column
for (unsigned int y = min_pt.y; y < max_pt.y; ++y) {
pt.x = x;
Expand Down
6 changes: 6 additions & 0 deletions nav2_costmap_2d/src/costmap_2d_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ bool Costmap2DROS::getRobotPose(geometry_msgs::msg::PoseStamped & global_pose) c
robot_pose.header.stamp = rclcpp::Time();

rclcpp::Time current_time = node_->now(); // save time for checking tf delay later

if (robot_base_frame_ == global_frame_) {
// Robot is at the origin
return true;
}

// get the global pose of the robot
try {
tf_.transform(robot_pose, global_pose, global_frame_);
Expand Down
2 changes: 2 additions & 0 deletions nav2_motion_primitives/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ find_package(nav2_tasks REQUIRED)
find_package(nav2_util REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_robot REQUIRED)
find_package(nav2_world_model REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
Expand All @@ -30,6 +31,7 @@ set(dependencies
nav2_tasks
nav2_msgs
nav2_robot
nav2_world_model
nav_msgs
tf2
tf2_geometry_msgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class BackUp : public MotionPrimitive<nav2_tasks::BackUpCommand, nav2_tasks::Bac

nav2_tasks::TaskStatus onCycleUpdate(nav2_tasks::BackUpResult & result) override;

bool pathIsClear() override;

protected:
double min_linear_vel_;
double max_linear_vel_;
double linear_acc_lim_;
geometry_msgs::msg::Twist default_vel_;

nav_msgs::msg::Odometry::SharedPtr initial_pose_;
orduno marked this conversation as resolved.
Show resolved Hide resolved
double command_x_;
Expand Down
Loading