ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

NOVA1323's profile - activity

2023-04-24 10:03:06 -0500 received badge  Famous Question (source)
2022-05-27 08:14:06 -0500 received badge  Notable Question (source)
2022-05-27 08:14:06 -0500 received badge  Popular Question (source)
2022-02-12 04:38:27 -0500 asked a question Passing values to a node via GUI

Passing values to a node via GUI I am using a GTKMM GUI to launch a file for an autonomous robot. The system() function

2022-02-12 00:16:03 -0500 marked best answer Taking arguments via command line for launch files.

I am trying to pass a value to a parameter in a node via the launch file.

I created a basic node that would print the parameter it read or it would give an error saying no parameter.

even though I pass a parameter the node is not able to read it.

I have added the code of the launch file and node below.

Launch File:

<launch>

<arg name="station" />

<node pkg="param_from_launch" type="trial" name="trial">
  <param name="param_1" value="$(arg station)"/>
</node>

</launch>

C++ Node:

#include "ros/ros.h"
#include <iostream>

int main(int argc, char **argv)
{
  // Set up ROS.
    ros::init(argc, argv, "trial");
    ros::NodeHandle n("~");   // private namespace

    int param_1;

    n.param<int>("param_from_launch", param_1, 0);
    if(n.param("param_from_launch", param_1)){
        ROS_INFO("param_from_launch: %d", param_1);
    }
    else{
        ROS_ERROR("NO PARAM");
    }
    // Let ROS handle all callbacks.
    ros::spin();

    return 0;
}  // end main()

running the node separately gives me the expected output: param_from_launch: 0. but when running the launch file I get [ERROR] [1644580954.583154879]: NO PARAM

2022-02-12 00:16:03 -0500 received badge  Scholar (source)
2022-02-12 00:16:01 -0500 commented answer Taking arguments via command line for launch files.

Thanks, I always thought that the first string was just a placeholder or message.

2022-02-12 00:13:03 -0500 commented answer Taking arguments via command line for launch files.

as @jarvisschultz said you can set integer parameters infact you can also define what kind of parameter you would like u

2022-02-11 07:36:21 -0500 marked best answer roslaunch exit code 2 error

I am implementing a simple roslaunch file but I am getting an exit code 2 status I have pasted the exact log below any idea what would cause this and how I can rectify it. I can run it perfectly using rosrun

kshitij@Kshitij:~/catkin_ws$ roslaunch apriltag_ros apriltag.launch 
... logging to /home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/roslaunch-Kshitij-20782.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt 
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://Kshitij:38583/

SUMMARY
========

PARAMETERS
* /rosdistro: noetic
* /rosversion: 1.15.13

NODES
/
apriltag_ros (apriltag_ros/tagdetector.py)

auto-starting new master
process[master]: started with pid [20790]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to c7672d6c-479d-11ec-bd02-c56b9aa24743
process[rosout-1]: started with pid [20800]
started core service [/rosout] 
process[apriltag_ros-2]: started with pid [20803]
usage: tagdetector.py [-h] [-f FAMILIES] [-B N] [-t N] [-x SCALE] [-b SIGMA] [-0] [-1] [-2] [-c]
tagdetector.py: error: unrecognized arguments: __name:=apriltag_ros __log:=/home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/apriltag_ros-2.log
[apriltag_ros-2] process has died [pid 20803, exit code 2, cmd /home/kshitij/catkin_ws/src/apriltag_ros/scripts/tagdetector.py __name:=apriltag_ros __log:=/home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/apriltag_ros-2.log].
log file: /home/kshitij/.ros/log/c7672d6c-479d-11ec-bd02-c56b9aa24743/apriltag_ros-2*.log

The launch file code is as below

<?xml version = "1.0"?>

<launch>
    <node name = "apriltag_ros" pkg = "apriltag_ros" type = "tagdetector.py"  output="screen" />
</launch>

As per my understanding I should add an extra line in my publisher that is rospy.myargv(argv=sys.argv) but it doesn't seem to work. Please let me know if I am missing something.

The function I am using to publish the data is as below

def location_publisher():
    """
    ROS Publisher: Publishes X, Y and Yaw values
    """
    pub = rospy.Publisher('apriltag_pose', tag, queue_size=10)
    rospy.init_node('apriltag_ros', anonymous=False)
    msg = tag()
    msg.location.x = z # z in camera frame of reference is the distance from the tag i.e. x in general frame of reference
    msg.location.y = y
    msg.location.theta = yaw
    msg.status.data = status_tag
    msg.tagid.data = tag_id
    rospy.loginfo(msg)
    pub.publish(msg)

Any help is appreciated.

Thanks

2022-02-11 06:13:18 -0500 asked a question Taking arguments via command line for launch files.

Taking arguments via command line for launch files. I am trying to pass a value to a parameter in a node via the launch

2021-11-29 02:43:49 -0500 answered a question roslaunch exit code 2 error

The script I was using used parser from the Apriltag library and could not Parse other arguments given changing the pars

2021-11-29 02:40:58 -0500 received badge  Famous Question (source)
2021-11-23 11:17:37 -0500 received badge  Autobiographer
2021-11-23 11:13:43 -0500 edited question roslaunch exit code 2 error

roslaunch exit code 2 error I am implementing a simple roslaunch file but I am getting an exit code 2 status I have past

2021-11-19 05:53:53 -0500 received badge  Supporter (source)
2021-11-19 05:21:58 -0500 commented answer roslaunch exit code 2 error

This is the same issue since you said that adding rospy.init_node() would fix the problem hence I posted the code snippe

2021-11-19 05:21:19 -0500 commented answer roslaunch exit code 2 error

This is the same issue since you said that adding rospy.init() would fix the problem hence I posted the code snippet but

2021-11-19 05:20:54 -0500 commented answer roslaunch exit code 2 error

This is the same issue since you said that adding rospy.init() would fix the problem I posted the code snippet but as yo

2021-11-19 05:17:38 -0500 received badge  Notable Question (source)
2021-11-19 00:49:33 -0500 edited answer roslaunch exit code 2 error

answered 6 hours ago tfoote gravatar image tfoote flag of United States of America 56543 ●118 ●493 ●498 http

2021-11-19 00:49:33 -0500 received badge  Editor (source)
2021-11-19 00:38:43 -0500 answered a question roslaunch exit code 2 error

answered 6 hours ago tfoote gravatar image tfoote flag of United States of America 56543 ●118 ●493 ●498 http

2021-11-19 00:38:43 -0500 received badge  Rapid Responder (source)
2021-11-18 17:30:50 -0500 received badge  Popular Question (source)
2021-11-18 00:12:01 -0500 edited question roslaunch exit code 2 error

roslaunch exit code 2 error I am implementing a simple roslaunch file but I am getting an exit code 2 status I have past

2021-11-17 11:38:47 -0500 asked a question roslaunch exit code 2 error

roslaunch exit code 2 error kshitij@Kshitij:~/catkin_ws$ roslaunch apriltag_ros apriltag.launch ... logging to /home/ks