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

Trislam1 #40

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
49e6b69
Draft of face following capability
Feb 6, 2022
da8bdf2
Merge branch 'main' into behaviors
Feb 17, 2022
5c15f5c
Minor cleanup
Feb 17, 2022
8c91260
Merge branch 'main' of github.com:gaia-platform/examples-internal int…
dr-soong Mar 10, 2022
9d9f653
Merge branch 'main' of github.com:gaia-platform/examples-internal int…
dr-soong Mar 10, 2022
cc6b503
Merge branch 'main' of github.com:gaia-platform/examples-internal int…
dr-soong Mar 14, 2022
d5ee693
Merge branch 'main' of github.com:gaia-platform/examples-internal int…
dr-soong Mar 24, 2022
0e11a8e
Snapshot save migrating SLAM to ClearPath-oriented example
dr-soong Mar 25, 2022
5f14de4
Update rules/ddl so they compile
dr-soong Mar 25, 2022
1ce766a
Fixing compile errors
dr-soong Mar 25, 2022
a2a9414
Snapshot save investigating link error
dr-soong Mar 25, 2022
1ffb9c3
App compiles. Start testing next
dr-soong Mar 26, 2022
ea52e7c
Snapshot. State: apparent left/right inversion in range radials
dr-soong Mar 26, 2022
ea66c47
Fixed axis inversion issue w/ ray tracing
dr-soong Mar 26, 2022
563b607
Running to produce demo. DDL/rules in draft
dr-soong Mar 27, 2022
59f3f91
Address some PR comments
dr-soong Mar 30, 2022
9cb963c
Reordered DDL to hopefully improve understandability. Added comment t…
dr-soong Mar 30, 2022
b26a384
PR comments (mostly re: constants and making types consistent)
dr-soong Mar 30, 2022
2165b0b
Comments to Makefiles
dr-soong Mar 30, 2022
095ccde
Found another data type inconsistency (float/double)
dr-soong Mar 30, 2022
15fbf7c
Remove debug code, clean up comments, other PR changes
dr-soong Mar 30, 2022
17d1b2c
Split ruleset into serial and non-serial sections
dr-soong Mar 30, 2022
9d7c532
Minor cleanup. Bug fix on map output
dr-soong Mar 30, 2022
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
4 changes: 4 additions & 0 deletions trislam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tmp
*.o
.*.swp
build
117 changes: 117 additions & 0 deletions trislam/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
###################################################
# Copyright (c) Gaia Platform LLC
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE.txt file
# or at https://opensource.org/licenses/MIT.
###################################################

cmake_minimum_required(VERSION 3.16)

enable_testing()

project(slam_sim)

set(CMAKE_CXX_STANDARD 17)

set(GAIA_COMPILE_FLAGS "-c -Wall -Wextra -ggdb")
set(GAIA_LINK_FLAGS "-ggdb")

# We need pthreads support.
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)

include("/opt/gaia/cmake/gaia.cmake")

# Default compiler/linker flags.
add_compile_options(-c -Wall -Wextra -ggdb)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is redundant with set(GAIA_COMPILE_FLAGS "-c -Wall -Wextra -ggdb").

I'd remove the following:

set(GAIA_COMPILE_FLAGS "-c -Wall -Wextra -ggdb")
set(GAIA_LINK_FLAGS "-ggdb")


# --- Generate Direct Access classes from DDL---
process_schema(
DDL_FILE ${PROJECT_SOURCE_DIR}/gaia/slam.ddl
DATABASE_NAME slam
)

# -- Translate ruleset into CPP --
translate_ruleset(
RULESET_FILE ${PROJECT_SOURCE_DIR}/gaia/slam.ruleset
DATABASE_NAME slam
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no DATABASE_NAME parameter in translate_ruleset.

CLANG_PARAMS
-I ${PROJECT_SOURCE_DIR}/include
)

# Application

add_executable(slam_sim
src/analyze.cpp
src/occupancy.cpp
src/paths.cpp
src/rule_api.cpp
src/slam_sim.cpp
src/utils/coord_list.cpp
src/utils/line_segment.cpp
)

target_add_gaia_generated_sources(slam_sim)

target_include_directories(slam_sim PRIVATE
${GAIA_INC}
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/gaia/slam
)

target_link_directories(slam_sim PRIVATE ${GAIA_LIB_DIR})
target_link_libraries(slam_sim PRIVATE ${GAIA_LIB} rt Threads::Threads)


########################################################################
# Tests

################################
add_executable(test_coord_list
tests/test_coord_list.cpp
src/utils/coord_list.cpp
)

set_target_properties(test_coord_list PROPERTIES COMPILE_FLAGS "${GAIA_COMPILE_FLAGS}")
set_target_properties(test_coord_list PROPERTIES LINK_FLAGS "${GAIA_LINK_FLAGS}")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can get rid of all the set_target_properties declarations.

target_include_directories(test_coord_list PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(test_coord_list PRIVATE rt)

add_test(NAME test_coord_list COMMAND test_coord_list)


################################
add_executable(test_line_segment
tests/test_line_segment.cpp
src/utils/line_segment.cpp
)

set_target_properties(test_line_segment PROPERTIES COMPILE_FLAGS "${GAIA_COMPILE_FLAGS}")
set_target_properties(test_line_segment PROPERTIES LINK_FLAGS "${GAIA_LINK_FLAGS}")
target_include_directories(test_line_segment PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(test_line_segment PRIVATE rt)

add_test(NAME test_line_segment COMMAND test_line_segment)


################################
add_executable(test_analyze
tests/test_analyze.cpp
src/analyze.cpp
src/occupancy.cpp
src/paths.cpp
src/rule_api.cpp
src/utils/coord_list.cpp
src/utils/line_segment.cpp
)
target_add_gaia_generated_sources(test_analyze)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we need to split slam_sim into a library and an executable re-use the library for tests.


set_target_properties(test_analyze PROPERTIES COMPILE_FLAGS "${GAIA_COMPILE_FLAGS}")
set_target_properties(test_analyze PROPERTIES LINK_FLAGS "${GAIA_LINK_FLAGS}")
target_include_directories(test_analyze PRIVATE ${GAIA_INC})
target_include_directories(test_analyze PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(test_analyze PRIVATE ${GAIA_LIB} rt)

add_test(NAME test_analyze COMMAND test_analyze)
17 changes: 17 additions & 0 deletions trislam/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

all:
mkdir -p build && cd build && cmake .. && make -j 4

run:
cd src && make run

# At present there's no method to delete the contents of the database
# from w/in the program, so add a way to do so outside.
refresh_db:
gaiac gaia/slam.ddl --db-name slam -g -o /tmp/slam

refresh: clean all

clean:
rm -Rf build

Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you are doing here, and it makes sense to me, but AFAIK this is the only project where we do this. I know that we had a bunch of shell scripts in the AMR swarm, but the jury was out on whether they helped or caused more confusion. I prefer this to shell scripts, but I also wonder if there is a way to generalize this so that we could just drop a copy of this in with all the examples? The only project specific rule is refresh_db.
What do other folks think?

69 changes: 69 additions & 0 deletions trislam/data/map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"description": "4 rooms, 3 with table",
daxhaw marked this conversation as resolved.
Show resolved Hide resolved
"width": 15.0,
"height": 10.0,
"world": [
{
"name": "Walls",
"vertices": [
{ "x": -6.9, "y": 4.9 },
{ "x": -0.1, "y": 4.9 },
{ "x": -0.1, "y": 0.1 },
{ "x": -1.5, "y": 0.1 },
{ "x": -1.5, "y": -0.1 },
{ "x": -0.1, "y": -0.1 },
{ "x": -0.1, "y": -3.0 },
{ "x": 0.1, "y": -3.0 },
{ "x": 0.1, "y": 4.9 },
{ "x": 6.9, "y": 4.9 },
{ "x": 6.9, "y": -1.9 },
{ "x": 2.1, "y": 0.1 },
{ "x": 2.1, "y": -0.1 },
{ "x": 6.9, "y": -2.1 },
{ "x": 6.9, "y": -4.9 },
{ "x": -6.9, "y": -4.9 },
{ "x": -6.9, "y": -0.1 },
{ "x": -3.4, "y": -0.1 },
{ "x": -3.4, "y": 0.1 },
{ "x": -6.9, "y": 0.1 },
{ "x": -6.9, "y": 4.9 }
]
},
{
"name": "Table-1",
"vertices": [
{ "x": -5.5, "y": 3.5 },
{ "x": -4.0, "y": 3.5 },
{ "x": -4.0, "y": 2.5 },
{ "x": -5.5, "y": 2.5 },
{ "x": -5.5, "y": 3.5 }
]
},
{
"name": "Table-2",
"vertices": [
{ "x": 2.5, "y": -2.5 },
{ "x": 3.8, "y": -3.5 },
{ "x": 1.2, "y": -3.5 },
{ "x": 2.5, "y": -2.5 }
]
},
{
"name": "Table-3",
"vertices": [
{ "x": 3.0, "y": 3.0 },
{ "x": 4.0, "y": 3.0 },
{ "x": 4.0, "y": 2.0 },
{ "x": 3.0, "y": 2.0 },
{ "x": 3.0, "y": 3.0 }
]
}
],
"landmarks": [
{ "x": -3.5, "y": 4.9, "id": 1, "name": "mark-1" },
{ "x": 3.5, "y": 4.9, "id": 2, "name": "mark-2" },
{ "x": -3.5, "y": -4.9, "id": 2, "name": "mark-3" },
{ "x": 3.5, "y": -4.9, "id": 2, "name": "mark-4" },
{ "x": 6.0, "y": -0.0, "id": 2, "name": "mark-5" }
]
}
36 changes: 36 additions & 0 deletions trislam/data/path.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-4 4
daxhaw marked this conversation as resolved.
Show resolved Hide resolved
-3 4
-2.5 3.5
-2.2 3.2
-2 2.5
-2.3 2.2
-3 2.0
-4 2
-4.5 1.5
-4.4 1
-4 1
-3 1
-2.5 0.5
-2.4 0
-2.3 -1
-2.8 -1.2
-3.5 -1.3
-4.0 -2.0
-4.0 -3.0
-3.5 -3.5
-2.5 -4.0
-1.5 -4.0
-0.5 -4
0.5 -3.9
0.8 -3.2
1.5 -2
1.9 -1.5
1.2 -0.5
1.0 0.5
1.5 1.5
1.8 2.5
2.1 3.5
3 4
4 4
5 4
5.5 3.5
5 changes: 5 additions & 0 deletions trislam/data/test_coords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1.0 1.0
1.0 2.0
-1 2.0
-5 -2.0
5 -2
17 changes: 17 additions & 0 deletions trislam/gaia/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

empty line (mayve you should put the Gaia copyright)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file will be deleted. It's a shortcut to build ddl/rules w/o jumping back to cmake.

RULES_CPP = slam_rules.cpp
DB_NAME = slam
INC = -I/opt/gaia/include/ -Islam/ -I../include/

OBJS = slam_rules.o slam/gaia_slam.o

all:
gaiac slam.ddl -g --db-name $(DB_NAME) -o $(DB_NAME)
gaiat slam.ruleset -output $(RULES_CPP) -- -I/usr/lib/clang/10/include $(INC)

refresh: clean all

clean:
rm -f *.o $(RULES_CPP)
rm -rf $(DB_NAME)

Loading