ryuichiueda / emcl2

GNU Lesser General Public License v3.0
34 stars 15 forks source link

how to receive map for localization #1

Closed kdhRGT closed 2 years ago

kdhRGT commented 2 years ago

Hello sir

thank you so much to share your great work.

I have two questions.

I publish the map by map server for subscribing map

is it worked in your pkg?

    <node pkg="map_server" type="map_server" name="map_server_localization" args="$(arg map_config_loc)">
    <remap from="map" to="map_localization" />
    </node>

also

I think your emcl2.launch file has a mistyping

  <!-- EMCL -->
  <node pkg="emcl" type="emcl2_node" name="emcl2_node" output="screen">

    <param name="odom_freq"                 value="20"/>
    <param name="num_particles"             value="500"/>

    <param name="odom_frame_id"             value="seromo_1/odom"/>
    <param name="footprint_frame_id"        value="seromo_1/base_footprint"/>
    <param name="base_frame_id"    

this should be changed as...

  <!-- EMCL -->
  <node pkg="emcl2" type="emcl2_node" name="emcl2_node" output="screen">

    <param name="odom_freq"                 value="20"/>
    <param name="num_particles"             value="500"/>

    <param name="odom_frame_id"             value="seromo_1/odom"/>
    <param name="footprint_frame_id"        value="seromo_1/base_footprint"/>
    <param name="base_frame_id"             value="seromo_1/base_link"/>

can you help me a little bit?

I wanna experiment with your great work.

thank you so much

best regards

ryuichiueda commented 2 years ago

Thank you very much for your inquiry.

is it worked in your pkg?

I think it works. In emcl2nav.launch, a map server is launched. Please tell me when I should add some code for your demand. I can modify my code as everyone can conveniently use this package.

I think your emcl2.launch file has a mistyping

Oh I must fix it. Thank you!

kdhRGT commented 2 years ago

Thank you so much for your fast reply!

This pkg used wheel odometry to guess the pose before correcting pose by LiDAR?

kdhRGT commented 2 years ago

Oh, now I found the odometry receiving part.

bool EMcl2Node::getOdomPose(double& x, double& y, double& yaw)
{
    geometry_msgs::PoseStamped ident;
    ident.header.frame_id = footprint_frame_id_;
    ident.header.stamp = ros::Time(0);
    tf2::toMsg(tf2::Transform::getIdentity(), ident.pose);

    geometry_msgs::PoseStamped odom_pose;
    try{
        this->tf_->transform(ident, odom_pose, odom_frame_id_);

    }catch(tf2::TransformException e){
            ROS_WARN("Failed to compute odom pose, skipping scan (%s)", e.what());
        return false;
    }
    x = odom_pose.pose.position.x;
    y = odom_pose.pose.position.y;
    yaw = tf2::getYaw(odom_pose.pose.orientation);

    return true;
}

But there is not working in my system so I am trying to change this part as subscribing ROS odometry topic.

ryuichiueda commented 2 years ago

I remember that I have implemented this part as the odometry information not from /odom topic but from tf. Did you check the tf information on your system?

kdhRGT commented 2 years ago

Thank you so much, sir. I understand.

i am focusing on other projects sorry late!

I will write meaningful results if I have.

plz, wait for me hmm I will come soon~~~!!

kdhRGT commented 2 years ago

Hello sir!

now i am doing experiments about emcl2

I have a simple question.

void LikelihoodFieldMap::setLikelihood(int x, int y, double range)
{
    int cell_num = (int)ceil(range/resolution_);
    std::vector<double> weights;
    for(int i=0;i<=cell_num;i++)
        weights.push_back(1.0 - (double)i/cell_num);

    for(int i=-cell_num; i<=cell_num; i++)
    for(int j=-cell_num; j<=cell_num; j++){
      std::cout << "x y i j " << x << " " << y << " " << i << " " << j << std::endl;
      double checkx = i+x;
      double checky = j+y;

      if(checkx > -1 && checky >-1){

        likelihoods_[i+x][j+y] = std::max(likelihoods_[i+x][j+y],
                                 std::min(weights[abs(i)], weights[abs(j)]));
        std::cout << "likelihoods_[i+x][j+y]" << likelihoods_[i+x][j+y] << std::endl;

      }
    }
}

in this code, in my map, sometimes "i+x" and "j+y" are (-) minus

so I made the program die.

Can I ignore the likelihoods_initialization based on my own map like this?

ryuichiueda commented 2 years ago

I’m sorry I’m late.

When a map has free cells at its edge, they will be minus. I think that i+x and i+y must be checked.

I will add the check. Thank you very much.

ryuichiueda commented 2 years ago

I fixed it (but it has never been tested). Please update your repo.