Ask Your Question
0

Evaluating ROS param in Launch file

asked 2017-11-07 11:09:30 -0500

Venkatachalam gravatar image

Hello All,

I am writing a program for controlling a robot. The robot has to make different motions based on the information of where it is. For accomplishing this, I have written different number of nodes inside the same launch file. For example, let us say that there are two locations the robot moves, for this I have two nodes in the same launch file. The robot has to achieve the goal in sequential order. That is once it reaches first goal, the information is required to be given to second node and the same sort of motion will happen with different node name and different goal point.

For transferring the information between nodes, I tried to set a boolean as rosparam and wanted to evaluate the param in launch file before running the second node. The problem is evaluating the parameter in the launch file, I tried to evaluate the param similar to args, it didnt work. And I am not sure if we can use args similar to params to set them inside function (similar to rospy.get_param()/ rospy.set_param()). I know that the args can be passed to the node, but not sure how to return them to launch file for further evaluation.

I hope I have not made my statements complicated, if so my apologies.

Thank you, Venkatachalam

edit retag flag offensive close merge delete

Comments

Welcome! What exactly is your question? It's a little hard to pick it out of all the text. Also, please post any relevant code (such as the launch files that you're referring to).

jayess gravatar imagejayess ( 2017-11-07 13:22:23 -0500 )edit

Wouldn't simple publisher/subscriber work for this?

l4ncelot gravatar imagel4ncelot ( 2017-11-08 00:52:07 -0500 )edit

If you want for some reason to evaluate ros parameters (e.g. if some certain parameter is set, run different node etc.) you can do that in bash script. I can provide you with some code, but right now I'm little confused what your real question is.

l4ncelot gravatar imagel4ncelot ( 2017-11-08 00:54:16 -0500 )edit

<launch> <arg name="forwardComplete" default="false"/> <node pkg="robo type=" motion.py"="" name="forward_exec"> </node> <group if="$(eval forward_complete == 'true')"> <node pkg="robo" type="motion.py" name="reverse_exec"> </group> </launch>

Venkatachalam gravatar imageVenkatachalam ( 2017-11-08 04:01:54 -0500 )edit

@jayess I have pasted the sample launch file. The idea is there are two nodes calling the same function, one to move the robot in forward direction and another to move in reverse direction. Goal (param) is changing. Once forward is complete, it has to be detected in other node and reverse starts.

Venkatachalam gravatar imageVenkatachalam ( 2017-11-08 04:08:42 -0500 )edit

@l4ncelot Yes, I need to evaluate parameters in launch file as I dont want two nodes to start at same time. One node moves robot forward and another reverse. Both calls the same function with different goals. They have to be sequential, so I am looking for a communication mechanism between nodes.

Venkatachalam gravatar imageVenkatachalam ( 2017-11-08 04:11:11 -0500 )edit

@l4ncelot Publisher subscriber may work, but I am looking to control starting the node from launch file based on some evaluation. I am not sure, if I can use publisher/subscriber in launch file.

Venkatachalam gravatar imageVenkatachalam ( 2017-11-08 04:15:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-11-08 04:36:17 -0500

l4ncelot gravatar image

For this you can use bash script. Here's an example:

#!/bin/bash

while true
    do
        forward_completed="$(rosparam get /forward_completed)"
        if [ "${forward_completed}" = true ]
        then
            rosrun you_package your_node
        fi
    done

It should give you a hint what to do.

edit flag offensive delete link more

Comments

Thank you very much. That works fine, and I have one more question. I dont know if it is possible to evaluate rosparam in launch file. I know to set the value of param in launch file, but I dont know how can the param be evaluated there. Online solutions suggested to use arg, not rosparam eval.

Venkatachalam gravatar imageVenkatachalam ( 2017-11-08 08:14:15 -0500 )edit

I don't know if it is even possible somehow. I've been always using arguments for that.

l4ncelot gravatar imagel4ncelot ( 2017-11-08 09:04:51 -0500 )edit

Oh ok. Thanks.

Venkatachalam gravatar imageVenkatachalam ( 2017-11-08 09:06:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-11-07 11:09:30 -0500

Seen: 332 times

Last updated: Nov 08 '17