Gmapping overlap

asked 2021-02-13 08:40:35 -0500

rajasj99 gravatar image

I am using YDlidar X4 with wheel encoder to perform gmapping on a two pc master slave setup . The process initializes properly without error but when the robot moves, it keeps on overlapping the map and the robot model bounces on the rviz window

This is the map when the robot performed a stationary rotation : map

This is the tf tree :tree

And this is the video:video

This is the initial launch file: <launch>
<arg name="gui" default="True"/>

<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />

<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />

<node name="serial_node" pkg="rosserial_python" type="serial_node.py">
    <param name="port" value="/dev/ttyACM0"/>
</node>

<node name="nox_controller" pkg="nox" type="nox_controller">
    <param name="publish_tf" value="true" />
        <param name="publish_rate" value="10.0" />
        <param name="linear_scale_positive" value="1.025" />
        <param name="linear_scale_negative" value="1.025" />
        <param name="angular_scale_positive" value="1.078" />
        <param name="angular_scale_negative" value="1.078" />
    <param name="angular_scale_accel" value="0.0" />
</node> 

            <!--  ************** Sensors ***************  -->
<include file="$(find ydlidar)/launch/lidar.launch" />
<node pkg="tf" type="static_transform_publisher" name="base_link_to_laser" args="0 0.0 0.0 0.0 0.0 0.0 /base_link /laser_frame 40" />

</launch>

This is the odometry file:

include ros/ros.h>

include tf/transform_broadcaster.h>

include nav_msgs/Odometry.h>

include geometry_msgs/Vector3.h>

include stdio.h>

include cmath>

double radius = 0.04; //Wheel radius, in m double wheelbase = 0.187; //Wheelbase, in m double two_pi = 6.28319; double speed_act_left = 0.0; double speed_act_right = 0.0; double speed_req1 = 0.0; double speed_req2 = 0.0; double speed_dt = 0.0; double x_pos = 0.0; double y_pos = 0.0; double theta = 0.0; ros::Time current_time; ros::Time speed_time(0.0);

void handle_speed( const geometry_msgs::Vector3Stamped& speed) { speed_act_left = trunc(speed.vector.x100)/100; ROS_INFO("speed left : %f", speed_act_left); speed_act_right = trunc(speed.vector.y100)/100; ROS_INFO("speed right : %f", speed_act_right); speed_dt = speed.vector.z; speed_time = speed.header.stamp; }

int main(int argc, char** argv){ ros::init(argc, argv, "nox_controller");

ros::NodeHandle n; ros::NodeHandle nh_private_("~"); ros::Subscriber sub = n.subscribe("speed", 50, handle_speed); ros::Publisher odom_pub = n.advertise<nav_msgs::odometry>("odom", 50); tf::TransformBroadcaster broadcaster;

double rate = 10.0; double linear_scale_positive = 1.0; double linear_scale_negative = 1.0; double angular_scale_positive = 1.0; double angular_scale_negative = 1.0; bool publish_tf = true; double dt = 0.0; double dx = 0.0; double dy = 0.0; double dth = 0.0; double dxy = 0.0; double vx = 0.0; double vy = 0.0; double vth = 0.0; char base_link[] = "/base_link"; char odom[] = "/odom";

ros::Duration d(1.0); nh_private_.getParam("publish_rate", rate); nh_private_.getParam("publish_tf", publish_tf); nh_private_.getParam("linear_scale_positive", linear_scale_positive); nh_private_.getParam("linear_scale_negative", linear_scale_negative); nh_private_.getParam("angular_scale_positive", angular_scale_positive); nh_private_.getParam("angular_scale_negative", angular_scale_negative);

ros::Rate r(rate); while(n.ok()){ ros::spinOnce(); current_time = speed_time; dt = speed_dt; //Time in s ROS_INFO("dt : %f", dt); dxy = (speed_act_left+speed_act_right)dt/2; ROS_INFO("dxy : %f", dxy); dth = ((speed_act_right-speed_act_left)dt)/wheelbase;

if (dth > 0) dth *= angular_scale_positive;
if (dth < ...
(more)
edit retag flag offensive close merge delete

Comments

Hello were you able to solve this ? I am following the same project and have encountered gmapping overlap

Os7 gravatar image Os7  ( 2022-06-13 06:52:40 -0500 )edit