@@ -46,11 +46,6 @@ void ElevationMappingWrapper::initialize(const std::shared_ptr<rclcpp::Node>& no
4646 auto threading = py::module::import (" threading" );
4747 py::gil_scoped_acquire acquire;
4848
49- auto sys = py::module::import (" sys" );
50- auto path = sys.attr (" path" );
51- std::string module_path = ament_index_cpp::get_package_share_directory (" elevation_mapping_cupy" );
52- module_path = module_path + " /script" ;
53- path.attr (" insert" )(0 , module_path);
5449
5550 auto elevation_mapping = py::module::import (" elevation_mapping_cupy.elevation_mapping" );
5651 auto parameter = py::module::import (" elevation_mapping_cupy.parameter" );
@@ -117,45 +112,45 @@ void ElevationMappingWrapper::setParameters() {
117112 }
118113
119114 }
115+
116+ py::dict sub_dict;
117+ // rclcpp::Parameter subscribers;
118+ std::vector<std::string> parameter_prefixes;
119+ auto parameters = node_->list_parameters (parameter_prefixes, 2 ); // List all parameters with a maximum depth of 10
120120
121- py::dict sub_dict;
122- // rclcpp::Parameter subscribers;
123- std::vector<std::string> parameter_prefixes;
124- auto parameters = node_->list_parameters (parameter_prefixes, 2 ); // List all parameters with a maximum depth of 10
125-
126-
127- std::map<std::string, rclcpp::Parameter> subscriber_params;
128- if (!node_->get_parameters (" subscribers" , subscriber_params)) {
129- RCLCPP_FATAL (node_->get_logger (), " There aren't any subscribers to be configured, the elevation mapping cannot be configured. Exit" );
130- rclcpp::shutdown ();
131- }
132- auto unique_sub_names = extract_unique_names (subscriber_params);
133- for (const auto & name : unique_sub_names) {
134- const char * const name_c = name.c_str ();
135- if (!sub_dict.contains (name_c)) {
136- sub_dict[name_c] = py::dict ();
137- }
138- std::string topic_name;
139- if (node_->get_parameter (" subscribers." + name + " .topic_name" , topic_name)){
140- const char * topic_name_cstr = " topic_name" ;
141- sub_dict[name_c][topic_name_cstr] = static_cast <std::string>(topic_name);
142- std::string data_type;
143- if (node_->get_parameter (" subscribers." + name + " .data_type" , data_type)){
144- const char * data_type_cstr = " data_type" ;
145- sub_dict[name_c][data_type_cstr] = static_cast <std::string>(data_type);
146- }
147- std::string info_name;
148- if (node_->get_parameter (" subscribers." + name + " .data_type" , info_name)){
149- const char * info_name_cstr = " info_name" ;
150- sub_dict[name_c][info_name_cstr] = static_cast <std::string>(info_name);
151- }
152- std::string channel_name;
153- if (node_->get_parameter (" subscribers." + name + " .data_type" , channel_name)){
154- const char * channel_name_cstr = " channel_name" ;
155- sub_dict[name_c][channel_name_cstr] = static_cast <std::string>(channel_name);
121+
122+ std::map<std::string, rclcpp::Parameter> subscriber_params;
123+ if (!node_->get_parameters (" subscribers" , subscriber_params)) {
124+ RCLCPP_FATAL (node_->get_logger (), " There aren't any subscribers to be configured, the elevation mapping cannot be configured. Exit" );
125+ rclcpp::shutdown ();
126+ }
127+ auto unique_sub_names = extract_unique_names (subscriber_params);
128+ for (const auto & name : unique_sub_names) {
129+ const char * const name_c = name.c_str ();
130+ if (!sub_dict.contains (name_c)) {
131+ sub_dict[name_c] = py::dict ();
156132 }
157- }
133+ std::string topic_name;
134+ if (node_->get_parameter (" subscribers." + name + " .topic_name" , topic_name)){
135+ const char * topic_name_cstr = " topic_name" ;
136+ sub_dict[name_c][topic_name_cstr] = static_cast <std::string>(topic_name);
137+ std::string data_type;
138+ if (node_->get_parameter (" subscribers." + name + " .data_type" , data_type)){
139+ const char * data_type_cstr = " data_type" ;
140+ sub_dict[name_c][data_type_cstr] = static_cast <std::string>(data_type);
141+ }
142+ std::string info_name;
143+ if (node_->get_parameter (" subscribers." + name + " .data_type" , info_name)){
144+ const char * info_name_cstr = " info_name" ;
145+ sub_dict[name_c][info_name_cstr] = static_cast <std::string>(info_name);
146+ }
147+ std::string channel_name;
148+ if (node_->get_parameter (" subscribers." + name + " .data_type" , channel_name)){
149+ const char * channel_name_cstr = " channel_name" ;
150+ sub_dict[name_c][channel_name_cstr] = static_cast <std::string>(channel_name);
151+ }
158152 }
153+ }
159154
160155
161156
@@ -199,14 +194,17 @@ void ElevationMappingWrapper::setParameters() {
199194 }
200195
201196
202- param_.attr (" update" )();
203- resolution_ = py::cast<float >(param_.attr (" get_value" )(" resolution" ));
204- map_length_ = py::cast<float >(param_.attr (" get_value" )(" true_map_length" ));
205- map_n_ = py::cast<int >(param_.attr (" get_value" )(" true_cell_n" ));
206-
207-
208-
209- enable_normal_color_ = node_->get_parameter (" enable_normal_color" ).as_bool ();
197+ // Update the cell_n parameters based on the map length and resolution
198+ RCLCPP_INFO (node_->get_logger (), " Updating cell_n parameters based on map length and resolution" );
199+ param_.attr (" update" )();
200+ resolution_ = py::cast<float >(param_.attr (" get_value" )(" resolution" ));
201+ map_length_ = py::cast<float >(param_.attr (" get_value" )(" true_map_length" ));
202+ map_n_ = py::cast<int >(param_.attr (" get_value" )(" true_cell_n" ));
203+ RCLCPP_INFO (node_->get_logger (), " cell_n: %d" , map_n_);
204+ RCLCPP_INFO (node_->get_logger (), " resolution: %f" , resolution_);
205+ RCLCPP_INFO (node_->get_logger (), " true_map_length: %f" , map_length_);
206+
207+ enable_normal_color_ = node_->get_parameter (" enable_normal_color" ).as_bool ();
210208
211209}
212210
0 commit comments