ros node as publisher and action client error

asked 2021-04-28 23:49:13 -0500

Eman.m gravatar image

updated 2021-04-29 19:31:13 -0500

Hi

I implemented a ros node that is a publisher (to publish initial pose of robot), and action client to send the goal to move_base

I have two text file: one contains start positions ( one x,y coord in each line), the other file contains goal positions ( one x,y coord in each line), for simlicity, each file contains only 2 lines.

Terminal commands:

New Terminal:

roslaunch rosbot_navigation move_my_rosbot.launch

This lanuch file contains the move_base, and it was working perfectly if I publish start and goal using the terminal. It launches Gazebo and Rviz, and every thing is ok.

New Terminal:

cd ~/Desktop/Eman/ros_workspace

source devel/setup.bash

rosrun ros_navigation_experiment ros_navigation_experiment_node

This is my launch file:

<launch>
    <arg name="use_rosbot" default="false"/>
    <arg name="use_gazebo" default="true"/>
    <param if="$(arg use_gazebo)" name="use_sim_time" value="true"/>
<!-- Bring the ROSbot model and show it in Gazebo and in Rviz  -->
    <include file="$(find rosbot_description)/launch/rosbot_rviz.launch"/>
<!-- Map server -->
    <arg name="map_file" default="$(find rosbot_navigation)/maps/willowgarage-refined.yaml"/>
    <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />
<!--- tf -->
    <node unless="$(arg use_rosbot)" pkg="tf" type="static_transform_publisher" name="map_odom_tf" args="0 0 0 0 0 0 map odom 100" /> 
    <node if="$(arg use_rosbot)" pkg="tf" type="static_transform_publisher" name="base_link_to_laser" args="0 0 0 3.14 0 0 base_link laser 100" />

    <node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher">
    <param name="publish_frequency" type="double" value="30.0" />
    </node>
<!--- Localization: Run AMCL -->
  <node pkg="amcl" type="amcl" name="amcl" output="screen">
        <remap from="scan" to="/scan"/>
        <rosparam file="$(find rosbot_navigation)/config/amcl.yaml" command="load" />

    </node>
<!-- Move base -->
    <node pkg="move_base" type="move_base" name="move_base" output="screen">
        <param name="base_global_planner" value="navfn/NavfnROS"/>
        <param name="base_local_planner" value="teb_local_planner/TebLocalPlannerROS" /> 
        <param name="controller_frequency" value="30.0"/> <!-- default is 20.0 -->
        <rosparam file="$(find rosbot_navigation)/config/costmap_common_params.yaml" command="load" ns="global_costmap" />
        <rosparam file="$(find rosbot_navigation)/config/costmap_common_params.yaml" command="load" ns="local_costmap" />
        <rosparam file="$(find rosbot_navigation)/config/local_costmap_params.yaml" command="load" />
        <rosparam file="$(find rosbot_navigation)/config/global_costmap_params.yaml" command="load" />
        <rosparam file="$(find rosbot_navigation)/config/teb_local_planner_params.yaml" command="load" />
    </node>
</launch>

This is my amcl.yaml

use_map_topic: true

odom_frame_id: "odom"
base_frame_id: "base_link"
global_frame_id: "map"

initial_pose_x : 0
initial_pose_y : 0

## Publish scans from best pose at a max of 10 Hz
odom_model_type: "diff"
odom_alpha5: 0.1
gui_publish_rate: 10.0
laser_max_beams: 60
laser_max_range: 12.0
min_particles: 500
max_particles: 2000
kld_err: 0.05
kld_z: 0.99
odom_alpha1: 0.2
odom_alpha2: 0.2
## translation std dev, m 
odom_alpha3: 0.2
odom_alpha4: 0.2
laser_z_hit: 0.5
aser_z_short: 0.05
laser_z_max: 0.05
laser_z_rand: 0.5
laser_sigma_hit: 0.2
laser_lambda_short: 0.1
laser_model_type: "likelihood_field" # "likelihood_field" or "beam"
laser_likelihood_max_dist: 2.0
update_min_d: 0.25
update_min_a: 0.2

resample_interval: 1

## Increase tolerance because the computer can get quite busy 
transform_tolerance: 1.0
recovery_alpha_slow: 0.001 ...
(more)
edit retag flag offensive close merge delete

Comments

1

Have you turned on move_base node as well? when you do 'rosnode list', what do you get?

So Young gravatar image So Young  ( 2021-04-29 00:04:54 -0500 )edit

Thanks So Young, I appreciate your help. I have edited my question above, and I used a launch file that contains move_base , but still there a problem that start position is not published.

Eman.m gravatar image Eman.m  ( 2021-04-29 17:49:28 -0500 )edit

I'm not quite sure, but I believe /initialpose is subscribed by amcl and amcl will be responsible for publishing map to odom tf. In your launch file, map_odom_tf static_transform_publisher seems to be doing the same thing, and maybe this could overwrite the tf that amcl was publishing? this is just a guess though.

So Young gravatar image So Young  ( 2021-04-29 19:19:34 -0500 )edit

I added the content of my amcl.yaml above. Do you mean that I need to remove

initial_pose_x : 0

initial_pose_y : 0

from amcl.yaml

Eman.m gravatar image Eman.m  ( 2021-04-29 19:32:19 -0500 )edit

<node unless="$(arg use_rosbot)" pkg="tf" type="static_transform_publisher" name="map_odom_tf" args="0 0 0 0 0 0 map odom 100"/> I meant this line, and I think those initial_pose_x and _y are default values anyways so it won't matter.

So Young gravatar image So Young  ( 2021-04-29 19:39:55 -0500 )edit

also, is your robot localizing in the map well? if it's localized from AMCL, I'm not sure if it can take /initialpose and suddenly jump to another starting position for navigation. the robot's position should be the starting point and you'll be able to send different goal positions (move_base goals).

So Young gravatar image So Young  ( 2021-04-29 19:47:07 -0500 )edit

yes, you are right. amcl is subscribed to initialpose.

I can change the initialpose successfully using terminal, then send goal using terminal. After reaching the goal. I can set new start pose.

I am not sure if I can comment out this line.

I followed the node here:

https://answers.ros.org/question/3134...

Eman.m gravatar image Eman.m  ( 2021-04-29 20:03:56 -0500 )edit

I see, but when you said you successfully change the initial pose of the robot, did you use the topic /initialpose? if your robot is localised properly, AMCL node will publish /amcl_pose. I believe you are meant to send /initiapose just one time at the beginning of AMCL, when you want to give 'hint' to the AMCL so it can localize quickly, and I'm not sure if that topic is meant for setting start point of the move_base navigation.

So Young gravatar image So Young  ( 2021-04-29 20:21:20 -0500 )edit