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

[Citadel] Add all features to tpeplugin #46

Merged
merged 92 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
0f8b124
add tpe plugin, need update
Mar 17, 2020
d7816d3
update based on new folder structure
Mar 17, 2020
154559b
restore test.world in worlds folder to keep cmakelists consistent
Mar 17, 2020
0fef7f9
merge tpe_lib_citadel
Mar 18, 2020
ba51c49
merge tpe_lib_citadel
Mar 20, 2020
c0ea98f
use tpelib and tpeplugin
Mar 20, 2020
8159b43
move /worlds in /plugin folder to fix sdffeatures test
Mar 21, 2020
49d53ac
change uint64_t to size_t to avoid xcode reference ambiguity
Mar 24, 2020
5102831
merge tpe_lib_citadel
Mar 24, 2020
b51c62a
keep consistency with dartsim test, remove dummy EXPECT_EQ
Mar 24, 2020
1376a6b
merge tpe_lib_citadel
Mar 25, 2020
fe7add8
merge tpe_lib
Apr 1, 2020
12e2bd6
add unversioned install to plugin CMakeLists
Apr 1, 2020
32b4162
Merged ign-physics2 into tpe_plugin_citadel
Apr 1, 2020
0db2b40
Merged tpe_lib_citadel into tpe_plugin_citadel
chapulina Apr 1, 2020
388d862
correct target to tpelib and set engine_name
Apr 1, 2020
c801d40
Merged tpe_lib_citadel into tpe_plugin_citadel
chapulina Apr 3, 2020
2c36aa2
merge tpe_lib_citadel
Apr 3, 2020
81be74a
merge tpe_lib_citadel
Apr 3, 2020
48e8eaf
update GetChildByName and add dbg msg for framedata
Apr 3, 2020
d136d57
Merged ign-physics2 into tpe_plugin_citadel
Apr 4, 2020
15c567d
include path
iche033 Apr 6, 2020
3539a70
make entity shared ptrs
Apr 8, 2020
25de259
Close branch tpe_plugin_citadel_cmake
Apr 8, 2020
a506935
Merged tpe_plugin_citadel_cmake into tpe_plugin_citadel
Apr 8, 2020
bbeb861
merge changes
Apr 8, 2020
2a37bf1
update model and link to shared_ptrs
Apr 9, 2020
15df3c5
remove .orig files
Apr 9, 2020
2c31772
fix EntityManagement_TEST
Apr 17, 2020
b9d9a3e
add this->, clean up code, to be continued
Apr 17, 2020
7db0b22
clean up EntityManagementFeatures
Apr 17, 2020
7080930
update simulationfeature
Apr 17, 2020
724ad0f
Merge branch 'ign-physics2' into tpe_plugin_citadel
Apr 20, 2020
c6e0d97
get framedata from model pose
Apr 23, 2020
344f7f4
get framedata from model by linkID
Apr 23, 2020
c4972c2
add dummy GetContactsFromLastStepFeature
Apr 23, 2020
01bf3de
overload ConstructSdfCollision feature to include mesh
Apr 24, 2020
ad101d0
implement shape.GetSize()
Apr 24, 2020
870c640
overrideconstructsdfcollision
Apr 24, 2020
7ef3baf
Merge branch 'ign-physics2' into tpe_plugin_citadel
Apr 24, 2020
fe5c179
fix homebrew CI test failure
Apr 24, 2020
28cc7f1
fix windows CI
Apr 24, 2020
420e4df
continue attempt to fix windows CI
Apr 24, 2020
2fafd21
revert cmake changes
Apr 24, 2020
58ac8c0
add file(COPY) to cmake
Apr 24, 2020
409de4e
use configure_file to copy
Apr 24, 2020
feb09bf
copy file to unversioned_folder
Apr 24, 2020
2b5f42e
test copy
iche033 Apr 24, 2020
77586ff
Merge branch 'ign-physics2' into tpe_plugin_citadel
Apr 28, 2020
ad391b3
add canonical link for models to move
Apr 28, 2020
9c80c9d
Add Base.hh to plugin, move all features to different PR
Apr 29, 2020
e48074b
move changes to new PR, revert tpelib to ign-physics2
Apr 29, 2020
938641e
add EntityManagementFeatures
Apr 29, 2020
82f1be4
implement missing Shape::GetSize(), add Model::GetCanonicalLink()
Apr 29, 2020
bcd66ae
add features to tpeplugin
Apr 29, 2020
d8155b7
add doxygen doc and GetSize() test case
Apr 29, 2020
0fda051
suppress C4250 inherit via dominance warning
Apr 29, 2020
c9b9f69
Merge branch 'claire/tpelib_add_fns' into claire/tpeplugin_features
Apr 29, 2020
3e6fd55
Merge branch 'tpe_plugin_citadel' into claire/tpeplugin_features
Apr 29, 2020
dcdeac5
remove FreeGroupInfo, use link directly
Apr 29, 2020
2a0cf7c
Merge branch 'ign-physics2' into tpe_plugin_citadel
Apr 30, 2020
374d064
address chapulina's comments
May 6, 2020
50401da
add test world for simulation features
May 6, 2020
1742809
update to the correct test file
May 6, 2020
e76277f
disable world frame test, update boundingbox feature
May 7, 2020
2d9fe2b
couple entity index and id
May 7, 2020
c9fb279
update doc & remove commented code
May 7, 2020
2a03256
Merge branch 'ign-physics2' into tpe_plugin_citadel
May 7, 2020
a393504
Merge branch 'tpe_plugin_citadel' into claire/tpeplugin_features
claireyywang May 7, 2020
a2257be
add Base_TEST
claireyywang May 12, 2020
e87e3bd
add more test cases to EntityManagementFeatures
claireyywang May 12, 2020
d805a6f
fix warnings
claireyywang May 12, 2020
2ceb387
address more review comments
claireyywang May 12, 2020
143c1eb
remove worldframe bb test
claireyywang May 12, 2020
d221a44
add test cases for kinematics, simulation and shape features
claireyywang May 12, 2020
9968b6f
add test cases for FreeGroupFeatures
claireyywang May 13, 2020
5596d14
update to ReferenceInterface
claireyywang May 13, 2020
5ce5f7a
Merge branch 'ign-physics2' into tpe_plugin_citadel
May 13, 2020
377aaa7
Merge branch 'tpe_plugin_citadel' into claire/tpeplugin_features
claireyywang May 13, 2020
554b22e
Merge branch 'ign-physics2' into claire/tpeplugin_features
May 13, 2020
a903dcc
address Ian's review comments
claireyywang May 15, 2020
692c5dc
add )
claireyywang May 15, 2020
319fa83
use it to reduce lookup, clean up code
claireyywang May 20, 2020
f952393
minor changes
iche033 May 21, 2020
5485648
remove igndbg in sdffeatures
claireyywang May 26, 2020
5f745cc
alphabetize
claireyywang May 26, 2020
8db4c8f
remove include string
claireyywang May 26, 2020
ceb5bc6
update simulation_test
claireyywang May 26, 2020
e914855
use ASSERT_NE
claireyywang May 26, 2020
4729d5f
add world to framedata
claireyywang May 27, 2020
8f58c69
ignore mesh
claireyywang May 27, 2020
5215a74
add link offset todo
claireyywang May 28, 2020
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
8 changes: 8 additions & 0 deletions tpe/lib/src/Model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Entity &Model::AddLink()
return *it->second.get();
}

//////////////////////////////////////////////////
Entity &Model::GetCanonicalLink()
{
// return first link as canonical link
return *this->GetChildren().begin()->second;
claireyywang marked this conversation as resolved.
Show resolved Hide resolved
}


//////////////////////////////////////////////////
void Model::SetLinearVelocity(const math::Vector3d _velocity)
{
Expand Down
4 changes: 4 additions & 0 deletions tpe/lib/src/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class IGNITION_PHYSICS_TPELIB_VISIBLE Model : public Entity
/// \return Newly created Link
public: Entity &AddLink();

/// \brief Get the canonical link of model
/// \return Entity the canonical (first) link
public: Entity &GetCanonicalLink();

/// \brief Set the linear velocity of model
/// \param[in] _velocity linear velocity
public: void SetLinearVelocity(const math::Vector3d _velocity);
Expand Down
6 changes: 6 additions & 0 deletions tpe/lib/src/Shape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ void BoxShape::SetSize(const math::Vector3d &_size)
this->dirty = true;
}

//////////////////////////////////////////////////
math::Vector3d BoxShape::GetSize()
{
return this->size;
}

//////////////////////////////////////////////////
void BoxShape::UpdateBoundingBox()
{
Expand Down
1 change: 1 addition & 0 deletions tpe/lib/src/Shape_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ TEST(Shape, BoxShape)

math::Vector3d size(1.2, 3.6, 5.8);
shape.SetSize(size);
EXPECT_EQ(size, shape.GetSize());
math::AxisAlignedBox bbox = shape.GetBoundingBox();
EXPECT_EQ(math::Vector3d::Zero, bbox.Center());
EXPECT_EQ(size, bbox.Size());
Expand Down
38 changes: 29 additions & 9 deletions tpe/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,52 @@ ign_add_component(tpe INTERFACE
DEPENDS_ON_COMPONENTS sdf mesh
GET_TARGET_NAME features)

target_link_libraries(${features} INTERFACE ${PROJECT_LIBRARY_TARGET_NAME}-tpe)
target_link_libraries(${features} INTERFACE ${PROJECT_LIBRARY_TARGET_NAME}-tpelib)
target_include_directories(${features} SYSTEM INTERFACE)

ign_get_libsources_and_unittests(sources test_sources)

# TODO(MXG): Think about an ign_add_plugin(~) macro for ign-cmake
ign_add_component(tpe-plugin
set(engine_name tpe-plugin)
ign_add_component(${engine_name}
SOURCES ${sources}
DEPENDS_ON_COMPONENTS tpe
GET_TARGET_NAME tpe_plugin)

set(tpelib_dir ${PROJECT_SOURCE_DIR}/tpe)
target_include_directories(${tpe_plugin} PRIVATE ${tpelib_dir})

target_link_libraries(${tpe_plugin}
PUBLIC
${features}
${PROJECT_LIBRARY_TARGET_NAME}-sdf
${PROJECT_LIBRARY_TARGET_NAME}-mesh
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
ignition-math${IGN_MATH_VER}::eigen3)

# We need to link this, even when the profiler isn't used to get headers.
target_link_libraries(${tpe_plugin}
ignition-math${IGN_MATH_VER}::eigen3
PRIVATE
ignition-common${IGN_COMMON_VER}::profiler
# We need to link this, even when the profiler isn't used to get headers.
ignition-common${IGN_COMMON_VER}::profiler
)

# Note that plugins are currently being installed in 2 places: /lib and the engine-plugins dir
install(TARGETS ${tpe_plugin} DESTINATION ${IGNITION_PHYSICS_ENGINE_INSTALL_DIR})

# The library created by `ign_add_component` includes the ign-physics version
# (i.e. libignition-physics1-name-plugin.so), but for portability,
# we also install an unversioned symlink into the same versioned folder.
set(versioned ${CMAKE_SHARED_LIBRARY_PREFIX}${tpe_plugin}${CMAKE_SHARED_LIBRARY_SUFFIX})
set(unversioned ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME_NO_VERSION_LOWER}-${engine_name}${CMAKE_SHARED_LIBRARY_SUFFIX})
if (WIN32)
# disable MSVC inherit via dominance warning
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy
${IGNITION_PHYSICS_ENGINE_INSTALL_DIR}\/${versioned}
${IGNITION_PHYSICS_ENGINE_INSTALL_DIR}\/${unversioned})")
else()
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${versioned} ${unversioned})
INSTALL(FILES ${PROJECT_BINARY_DIR}/${unversioned} DESTINATION ${IGNITION_PHYSICS_ENGINE_INSTALL_DIR})
endif()

ign_build_tests(
TYPE UNIT_tpe
SOURCES ${test_sources}
Expand All @@ -42,11 +63,10 @@ ign_build_tests(

foreach(test ${tests})

target_include_directories(${test} PRIVATE ${tpelib_dir})
target_compile_definitions(${test} PRIVATE
"tpe_plugin_LIB=\"$<TARGET_FILE:${tpe_plugin}>\""
"TEST_WORLD_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/worlds/\""
"IGNITION_PHYSICS_RESOURCE_DIR=\"${IGNITION_PHYSICS_RESOURCE_DIR}\"")

endforeach()


133 changes: 133 additions & 0 deletions tpe/plugin/src/Base.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef IGNITION_PHYSICS_TPE_PLUGIN_SRC_BASE_HH_
#define IGNITION_PHYSICS_TPE_PLUGIN_SRC_BASE_HH_

#include <ignition/physics/Implements.hh>

#include <map>
#include <memory>
#include <string>

#include "lib/src/World.hh"
#include "lib/src/Engine.hh"
#include "lib/src/Model.hh"
#include "lib/src/Link.hh"
#include "lib/src/Collision.hh"
#include "lib/src/Shape.hh"

namespace ignition {
namespace physics {
namespace tpeplugin {

/// \brief The structs tpelib::ModelInfo,
/// tpelib::LinkInfo, JointInfo, and ShapeInfo are used
/// for two reasons:
/// 1) Holding extra information such as the name or offset
/// that will be different from the underlying engine
/// 2) Wrap shared pointers to DART entities. Since these shared pointers (eg.
/// dart::dynamics::BodyNodePtr) are different from std::shared_ptr, we
/// cannot use them directly as parameters to GenerateIdentity. Instead we
/// create a std::shared_ptr of the struct that wraps the corresponding DART
/// shared pointer.

struct WorldInfo
{
std::shared_ptr<tpelib::World> world;
};

struct ModelInfo
{
tpelib::Model *model;
};

struct LinkInfo
{
tpelib::Link *link;
};

struct CollisionInfo
{
tpelib::Collision *collision;
};

class Base : public Implements3d<FeatureList<Feature>>
{
public: inline Identity InitiateEngine(std::size_t /*_engineID*/) override
{
return this->GenerateIdentity(0);
}

public: inline Identity AddWorld(std::shared_ptr<tpelib::World> _world)
{
size_t worldId = _world->GetId();
auto worldPtr = std::make_shared<WorldInfo>();
worldPtr->world = _world;
this->worlds.insert({worldId, worldPtr});
return this->GenerateIdentity(worldId, worldPtr);
}

public: inline Identity AddModel(std::size_t _worldId, tpelib::Model &_model)
{
auto modelPtr = std::make_shared<ModelInfo>();
modelPtr->model = &_model;
size_t modelId = _model.GetId();
this->models.insert({modelId, modelPtr});
// keep track of model's corresponding world
this->childIdToParentId.insert({modelId, _worldId});

return this->GenerateIdentity(modelId, modelPtr);
}

public: inline Identity AddLink(std::size_t _modelId, tpelib::Link &_link)
{
auto linkPtr = std::make_shared<LinkInfo>();
linkPtr->link = &_link;
size_t linkId = _link.GetId();
this->links.insert({linkId, linkPtr});
// keep track of link's corresponding model
this->childIdToParentId.insert({linkId, _modelId});

return this->GenerateIdentity(linkId, linkPtr);
}

public: inline Identity AddCollision(std::size_t _linkId,
tpelib::Collision &_collision)
{
auto collisionPtr = std::make_shared<CollisionInfo>();
collisionPtr->collision = &_collision;
size_t collisionId = _collision.GetId();
this->collisions.insert({collisionId, collisionPtr});
// keep track of collision's corresponding link
this->childIdToParentId.insert({collisionId, _linkId});

return this->GenerateIdentity(collisionId, collisionPtr);
}

public: std::map<std::size_t, std::shared_ptr<WorldInfo>> worlds;
public: std::map<std::size_t, std::shared_ptr<ModelInfo>> models;
public: std::map<std::size_t, std::shared_ptr<LinkInfo>> links;
public: std::map<std::size_t, std::shared_ptr<CollisionInfo>> collisions;
public: std::map<std::size_t, std::size_t> childIdToParentId;
};

}
}
}

#endif
29 changes: 29 additions & 0 deletions tpe/plugin/src/CustomFeatures.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "CustomFeatures.hh"

using namespace ignition;
using namespace physics;
using namespace tpeplugin;

/////////////////////////////////////////////////
std::shared_ptr<tpelib::World> CustomFeatures::GetTpeLibWorld(
const Identity &_worldID)
{
return this->worlds.at(_worldID)->world;
claireyywang marked this conversation as resolved.
Show resolved Hide resolved
claireyywang marked this conversation as resolved.
Show resolved Hide resolved
}
48 changes: 48 additions & 0 deletions tpe/plugin/src/CustomFeatures.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef IGNITION_PHYSICS_TPE_PLUGIN_SRC_CUSTOMFEATURES_HH
#define IGNITION_PHYSICS_TPE_PLUGIN_SRC_CUSTOMFEATURES_HH

#include <memory>

#include <ignition/physics/Implements.hh>

#include "Base.hh"
#include "World.hh"

namespace ignition {
namespace physics {
namespace tpeplugin {

using CustomFeatureList = FeatureList<
RetrieveWorld
>;

class CustomFeatures :
public virtual Base,
public virtual Implements3d<CustomFeatureList>
{
public: std::shared_ptr<tpelib::World> GetTpeLibWorld(
const Identity &_worldID) override;
};

}
}
}

#endif
Loading