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 all 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
6 changes: 6 additions & 0 deletions trislam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tmp
*.o
.*.swp
build
*.pgm
*.jpg
107 changes: 107 additions & 0 deletions trislam/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
###################################################
# 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_demo)

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")

# --- 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
CLANG_PARAMS
-I ${PROJECT_SOURCE_DIR}/include
)

# Application

add_executable(slam_demo
src/analyze.cpp
src/occupancy.cpp
src/main.cpp
src/support.cpp
src/rule_api.cpp
src/utils/coord_list.cpp
src/utils/line_segment.cpp
)

target_add_gaia_generated_sources(slam_demo)

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

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


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

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

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
)

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/rule_api.cpp
src/support.cpp
src/utils/coord_list.cpp
src/utils/line_segment.cpp
)
target_add_gaia_generated_sources(test_analyze)

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)
28 changes: 28 additions & 0 deletions trislam/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.

# 'make all' executes cmake in 'build' directory.
# 'make clean' deletes the cmake build/ folder.
# 'make refresh_db' runs gaiac to clean out old content.
# 'make refresh' runs 'make clann all'

all:
#mkdir -p build && cd build && cmake .. && make
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

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" }
]
}
38 changes: 38 additions & 0 deletions trislam/data/path.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Path coordinates. Note that +Y is upward (not downward in an image
# processing sense).
-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
22 changes: 22 additions & 0 deletions trislam/gaia/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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.

# The purpose of this makefile is to simply execute gaiac and gaiat
# to make sure there are not errors (without executing higher level
# make). The single target then cleans up after itself.

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)
rm -f *.o $(RULES_CPP)
rm -rf $(DB_NAME)

Loading