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

Migrate to Garden #92

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 35 additions & 35 deletions rmf_building_sim_gz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

find_package(ignition-cmake2 REQUIRED)

ign_find_package(ignition-gazebo6 REQUIRED)
set(IGN_GAZEBO_VER 6)
ign_find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(IGN_PLUGIN_VER 1)
ign_find_package(ignition-common4 REQUIRED)
set(IGN_COMMON_VER 4)
ign_find_package(ignition-math6 REQUIRED)
set(IGN_MATH_VER 6)
ign_find_package(ignition-gui6 REQUIRED)
set(IGN_GUI_VER 6)
ign_find_package(ignition-msgs8 REQUIRED)
set(IGN_MSGS_VER 8)
ign_find_package(ignition-transport11 REQUIRED)
set(IGN_TRANSPORT_VER 11)
ign_find_package(ignition-rendering6 REQUIRED)
set(IGN_RENDERING_VER 6)
ign_find_package(sdformat12 REQUIRED)
find_package(gz-cmake3 REQUIRED)

gz_find_package(gz-sim7 REQUIRED)
set(GZ_SIM_VER 7)
gz_find_package(gz-plugin2 REQUIRED COMPONENTS register)
set(GZ_PLUGIN_VER 2)
gz_find_package(gz-common5 REQUIRED)
set(GZ_COMMON_VER 5)
gz_find_package(gz-math7 REQUIRED)
set(GZ_MATH_VER 7)
gz_find_package(gz-gui7 REQUIRED)
set(GZ_GUI_VER 7)
gz_find_package(gz-msgs9 REQUIRED)
set(GZ_MSGS_VER 9)
gz_find_package(gz-transport12 REQUIRED)
set(GZ_TRANSPORT_VER 12)
gz_find_package(gz-rendering7 REQUIRED)
set(GZ_RENDERING_VER 7)
gz_find_package(sdformat13 REQUIRED)


find_package(rmf_building_sim_common REQUIRED)
Expand Down Expand Up @@ -71,8 +71,8 @@ target_include_directories(door
ament_target_dependencies(door
PUBLIC
rclcpp
ignition-gazebo${IGN_GAZEBO_VER}
ignition-plugin${IGN_PLUGIN_VER}
gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}
rmf_building_sim_common
)

Expand All @@ -91,8 +91,8 @@ target_include_directories(lift
ament_target_dependencies(lift
PUBLIC
rclcpp
ignition-gazebo${IGN_GAZEBO_VER}
ignition-plugin${IGN_PLUGIN_VER}
gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}
rmf_building_sim_common
)

Expand All @@ -110,12 +110,12 @@ target_include_directories(crowd_simulator
${rmf_building_sim_common_INCLUDE_DIRS}
${rclcpp_INCLUDE_DIRS}
${menge_vendor_INCLUDE_DIRS}
${IGNITION-COMMON_INCLUDE_DIRS}
${gz-COMMON_INCLUDE_DIRS}
)

ament_target_dependencies(crowd_simulator
ignition-gazebo${IGN_GAZEBO_VER}
ignition-plugin${IGN_PLUGIN_VER}
gz-sim${GZ_SIM_VER}
gz-plugin${GZ_PLUGIN_VER}
rclcpp
rmf_building_sim_common
menge_vendor
Expand All @@ -133,9 +133,9 @@ add_library(toggle_charging SHARED ${headers_MOC}
)

ament_target_dependencies(toggle_charging
ignition-gui${IGN_GUI_VER}
ignition-msgs${IGN_MSGS_VER}
ignition-transport${IGN_TRANSPORT_VER}
gz-gui${GZ_GUI_VER}
gz-msgs${GZ_MSGS_VER}
gz-transport${GZ_TRANSPORT_VER}
Qt5Core
Qt5Qml
Qt5Quick
Expand All @@ -161,12 +161,12 @@ add_library(toggle_floors SHARED ${headers_MOC}
)

ament_target_dependencies(toggle_floors
ignition-gazebo${IGN_GAZEBO_VER}
ignition-gui${IGN_GUI_VER}
ignition-msgs${IGN_MSGS_VER}
ignition-plugin${IGN_PLUGIN_VER}
ignition-rendering${IGN_RENDERING_VER}
ignition-transport${IGN_TRANSPORT_VER}
gz-sim${GZ_SIM_VER}
gz-gui${GZ_GUI_VER}
gz-msgs${GZ_MSGS_VER}
gz-plugin${GZ_PLUGIN_VER}
gz-rendering${GZ_RENDERING_VER}
gz-transport${GZ_TRANSPORT_VER}
Qt5Core
Qt5Qml
Qt5Quick
Expand Down
36 changes: 18 additions & 18 deletions rmf_building_sim_gz_plugins/src/crowd_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

#include <ignition/math/Pose3.hh>

#include <ignition/gazebo/Util.hh>
#include <ignition/gazebo/components/Name.hh>
#include <ignition/gazebo/components/Model.hh>
#include <ignition/gazebo/components/Actor.hh>
#include <ignition/gazebo/components/Pose.hh>
#include <ignition/gazebo/components/Static.hh>
#include <gz/sim/Util.hh>
#include <gz/sim/components/Name.hh>
#include <gz/sim/components/Model.hh>
#include <gz/sim/components/Actor.hh>
#include <gz/sim/components/Pose.hh>
#include <gz/sim/components/Static.hh>

#include "crowd_simulator.hpp"

using namespace ignition::gazebo;
using namespace gz::sim;

namespace crowd_simulation_ign {

Expand Down Expand Up @@ -228,12 +228,12 @@ bool CrowdSimulatorPlugin::_create_entity(
// check the service available
assert(model_type_ptr);
std::string service = "/world/" + this->_world_name + "/create";
ignition::msgs::EntityFactory request;
gz::msgs::EntityFactory request;
request.set_sdf_filename(model_type_ptr->file_name);
request.set_name(model_name);
ignition::math::Pose3d pose(0, 0, 0, 0, 0, 0);
gz::math::Pose3d pose(0, 0, 0, 0, 0, 0);

ignition::msgs::Boolean response;
gz::msgs::Boolean response;
bool result;
uint32_t timeout = 5000;
bool executed = this->_transport_node_ptr->Request(service, request, timeout,
Expand Down Expand Up @@ -275,7 +275,7 @@ void CrowdSimulatorPlugin::_config_spawned_agents(
auto model_type = _crowd_sim_interface->_model_type_db_ptr->get(
obj_ptr->type_name);
// different from gazebo plugin, the pose component is the origin of the trajPose
ignition::math::Pose3d actor_pose(
gz::math::Pose3d actor_pose(
static_cast<double>(agent_ptr->_pos.x()),
static_cast<double>(agent_ptr->_pos.y()), 0.0,
0, 0, 0
Expand Down Expand Up @@ -353,11 +353,11 @@ void CrowdSimulatorPlugin::_update_internal_object(
{
double animation_speed = _crowd_sim_interface->_model_type_db_ptr->get(
obj_ptr->type_name)->animation_speed;
ignition::math::Pose3d initial_pose =
gz::math::Pose3d initial_pose =
_crowd_sim_interface->_model_type_db_ptr->get(obj_ptr->type_name)->pose.
convert_to_ign_math_pose_3d<ignition::math::Pose3d>();
ignition::math::Pose3d agent_pose =
_crowd_sim_interface->get_agent_pose<ignition::math::Pose3d>(
convert_to_ign_math_pose_3d<gz::math::Pose3d>();
gz::math::Pose3d agent_pose =
_crowd_sim_interface->get_agent_pose<gz::math::Pose3d>(
obj_ptr->agent_ptr, delta_sim_time);
agent_pose += initial_pose;

Expand All @@ -368,7 +368,7 @@ void CrowdSimulatorPlugin::_update_internal_object(
ecm.Component<components::AnimationName>(entity);
auto anim_time_comp =
ecm.Component<components::AnimationTime>(entity);
ignition::math::Pose3d current_pose = traj_pose_comp->Data();
gz::math::Pose3d current_pose = traj_pose_comp->Data();
auto distance_traveled_vector = agent_pose.Pos() - current_pose.Pos();
// might need future work on 3D case
// the center of human has a z_elevation, which will make the human keep walking even if he reached the target
Expand Down Expand Up @@ -415,13 +415,13 @@ void CrowdSimulatorPlugin::_update_internal_object(
ComponentState::PeriodicChange);
}

IGNITION_ADD_PLUGIN(
GZ_ADD_PLUGIN(
CrowdSimulatorPlugin,
System,
CrowdSimulatorPlugin::ISystemConfigure,
CrowdSimulatorPlugin::ISystemPreUpdate)

IGNITION_ADD_PLUGIN_ALIAS(CrowdSimulatorPlugin,
GZ_ADD_PLUGIN_ALIAS(CrowdSimulatorPlugin,
"crowd_simulation")

} //namespace crowd_simulation_ign
44 changes: 22 additions & 22 deletions rmf_building_sim_gz_plugins/src/crowd_simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

#include <rclcpp/rclcpp.hpp>

#include <ignition/plugin/Register.hh>
#include <ignition/gazebo/System.hh>
#include <ignition/gazebo/Model.hh>
#include <gz/plugin/Register.hh>
#include <gz/sim/System.hh>
#include <gz/sim/Model.hh>

#include <ignition/transport/Node.hh>

Expand All @@ -30,60 +30,60 @@

namespace crowd_simulation_ign {

class IGNITION_GAZEBO_VISIBLE CrowdSimulatorPlugin
: public ignition::gazebo::System,
public ignition::gazebo::ISystemConfigure,
public ignition::gazebo::ISystemPreUpdate
class GZ_SIM_VISIBLE CrowdSimulatorPlugin
: public gz::sim::System,
public gz::sim::ISystemConfigure,
public gz::sim::ISystemPreUpdate
{
using AnimState = crowd_simulator::CrowdSimInterface::AnimState;
public:
CrowdSimulatorPlugin()
: _transport_node_ptr(std::make_shared<ignition::transport::Node>()),
: _transport_node_ptr(std::make_shared<gz::transport::Node>()),
_crowd_sim_interface(std::make_shared<crowd_simulator::CrowdSimInterface>()),
_initialized(false)
{}

// inherit from ISystemConfigure
void Configure(const ignition::gazebo::Entity& entity,
void Configure(const gz::sim::Entity& entity,
const std::shared_ptr<const sdf::Element>& sdf,
ignition::gazebo::EntityComponentManager& ecm,
ignition::gazebo::EventManager& event_mgr) override;
gz::sim::EntityComponentManager& ecm,
gz::sim::EventManager& event_mgr) override;

// inherit from ISystemPreUpdate
void PreUpdate(const ignition::gazebo::UpdateInfo& info,
ignition::gazebo::EntityComponentManager& ecm) override;
void PreUpdate(const gz::sim::UpdateInfo& info,
gz::sim::EntityComponentManager& ecm) override;

private:
std::shared_ptr<ignition::transport::Node> _transport_node_ptr;
std::shared_ptr<gz::transport::Node> _transport_node_ptr;
std::shared_ptr<crowd_simulator::CrowdSimInterface> _crowd_sim_interface;
bool _initialized;
std::chrono::steady_clock::duration _last_sim_time{0};

std::shared_ptr<ignition::gazebo::Model> _world;
std::shared_ptr<gz::sim::Model> _world;
std::string _world_name;

// map for <model_name, object_id>, contains both external (models) and internal agents (actors)
std::unordered_map<std::string, size_t> _object_dic;
// map for <model_name, entity_id> contains external and internal agents
std::unordered_map<std::string, ignition::gazebo::Entity> _entity_dic;
std::unordered_map<std::string, gz::sim::Entity> _entity_dic;

bool _spawn_agents_in_world();
void _init_spawned_agents(ignition::gazebo::EntityComponentManager& ecm);
void _init_spawned_agents(gz::sim::EntityComponentManager& ecm);
void _config_spawned_agents(
const crowd_simulator::CrowdSimInterface::ObjectPtr obj_ptr,
const ignition::gazebo::Entity& enity,
ignition::gazebo::EntityComponentManager& ecm) const;
const gz::sim::Entity& enity,
gz::sim::EntityComponentManager& ecm) const;
bool _create_entity(
const std::string& model_name,
const crowd_simulator::ModelTypeDatabase::RecordPtr model_type_ptr) const;
void _update_all_objects(
double delta_sim_time,
ignition::gazebo::EntityComponentManager& ecm) const;
gz::sim::EntityComponentManager& ecm) const;
void _update_internal_object(
double delta_sim_time,
const crowd_simulator::CrowdSimInterface::ObjectPtr obj_ptr,
const ignition::gazebo::Entity& enity,
ignition::gazebo::EntityComponentManager& ecm) const;
const gz::sim::Entity& enity,
gz::sim::EntityComponentManager& ecm) const;
};

} //namespace crowd_simulation_ign
24 changes: 12 additions & 12 deletions rmf_building_sim_gz_plugins/src/door.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#include <ignition/plugin/Register.hh>
#include <gz/plugin/Register.hh>

#include <ignition/gazebo/System.hh>
#include <ignition/gazebo/Model.hh>
#include <ignition/gazebo/Util.hh>
#include <ignition/gazebo/components/JointAxis.hh>
#include <ignition/gazebo/components/JointPosition.hh>
#include <ignition/gazebo/components/JointVelocity.hh>
#include <ignition/gazebo/components/JointVelocityCmd.hh>
#include <gz/sim/System.hh>
#include <gz/sim/Model.hh>
#include <gz/sim/Util.hh>
#include <gz/sim/components/JointAxis.hh>
#include <gz/sim/components/JointPosition.hh>
#include <gz/sim/components/JointVelocity.hh>
#include <gz/sim/components/JointVelocityCmd.hh>

#include <rclcpp/rclcpp.hpp>

#include <rmf_building_sim_common/utils.hpp>
#include <rmf_building_sim_common/door_common.hpp>

using namespace ignition::gazebo;
using namespace gz::sim;

using namespace rmf_building_sim_common;

namespace rmf_building_sim_gz_plugins {

//==============================================================================

class IGNITION_GAZEBO_VISIBLE DoorPlugin
class GZ_SIM_VISIBLE DoorPlugin
: public System,
public ISystemConfigure,
public ISystemPreUpdate
Expand Down Expand Up @@ -235,12 +235,12 @@ class IGNITION_GAZEBO_VISIBLE DoorPlugin

};

IGNITION_ADD_PLUGIN(
GZ_ADD_PLUGIN(
DoorPlugin,
System,
DoorPlugin::ISystemConfigure,
DoorPlugin::ISystemPreUpdate)

IGNITION_ADD_PLUGIN_ALIAS(DoorPlugin, "door")
GZ_ADD_PLUGIN_ALIAS(DoorPlugin, "door")

} // namespace rmf_building_sim_gz_plugins
Loading