Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all 40 articles
Browse latest View live

Best way of sharing parameters/flags among nodes which donot change much?

$
0
0
i have to share some flags which do not change much among 4-5 nodes .A node named SERVER is changing the flags and thats very rarely. I have to check the value of flags at the rate of 10hz in other nodes . So which is the best way of implementing it. I already thought about some options like :
1. Publishing of flags on a topic by SERVER at a frequency of 2-3 Hz.
2. Using service call to update the value of flags in the nodes which have their own copy of flags.
3. Using parameter server.
4 Shared memory.
I do not think 1st option is the good one.

I have some doubts regarding this:
a). If i used the second option,will cpu`s time be wasted in looking for queue for the message arrival?
b). Is third option good for getting the value of parameter frequently ?
c). What about shared memory? I have read that shared memory is the fastest mode of interprocess communication.

retrieve ros param in launch file

$
0
0
I would like to set a parameter in a launch file but only if the respective parameter is not yet set. (The parameter value I would like to set in the launch file is kind of default but maybe the user has already set it to something smarter before the launch so i do not want to override the user value.) Is that possible? Or is it possible to retrieve a ros param inside a launch file in order of checking if it exists?

Sensor Camera on Gazebo: Could not find parameter robot_description on parameter server

$
0
0
hi all, i'm trying to create a sensor camera on [gazebo](http://www.ros.org/wiki/gazebo), but i have this message on the terminal when i run the launch file: [ERROR] [1323711066.531080823]: Could not find parameter robot_description on parameter server [ERROR] [1323711066.531205567]: Could not generate robot model [ERROR] [1323711066.531238167]: Failed to extract kdl tree from xml robot description [robot_state_publisher-4] process has died [pid 2161, exit code 255]. log files: /home/mauro/.ros/log/0edc0fb2-24e7-11e1-ba97-0016ea548718/robot_state_publisher-4*.log i created a launch file: the file my_camera.lauch is: the file my_camera.urdf .xacro is: true640 480R8G8B8900.0110020.0true20.0finger_tip_cam/imagefinger_tip_cam/camera_infofinger_tip_camera_linktrueGazebo/BlueErratic/YellowErratic/YellowErratic/Yellow

In Roscpp, can I access parameters from different nodes?

$
0
0
Example: I have always the same node type, lets say with a parameter named "shape" I make one node (node A) with shape = "square" I make a second node (node B) with shape = "circle" in the console if i did rosparam list i would see /nodeA/shape /nodeB/shape and if i did rosparam get /nodeA/shape i would see "Square", but is it possible in my test file, my cpp file, to use some form of get parameter when creating a node, so that I can see that node A shape is "Square"? pseudocode: if(&newNode/shape == &nodeA/shape) kill(newNode, SIGINT) Overall, i want to be able to test and see if a value of the parameter exists, and then if it exists, i will do a kill(pid, SIGINT). But i am having a hard time accessing the parameter value of the other nodes.

Append parameters to parameter server using YAML files

$
0
0
Hi, Is there a way to avoid overwriting parameters when being loaded from a launchfile using a YAML file? For example, I have two YAML files like the following: config1.yaml topics: - topic: topic1 type: geometry_msgs/Twist - topic: topic2 type: std_msgs/Empty config2.yaml topics: - topic: topic3 type: geometry_msgs/Twist - topic: topic4 type: std_msgs/Empty and want to have the 4 topics loaded under the `topics` parameter. I know that namespacing is the way it's normally done to separate parameters with the same name, but I'm looking for some other way. Thanks!

equivalent of rosparam get or rosparam list in launch file

$
0
0
Does anyone know if there is an equivalent of the console command "rosparam get 'parameter'" or "rosparam list" that can be written in to a .launch file. Wanting to check if a parameter is set or exists. So i was thinking that I could use an unless or if check but I don't know how to tell it to check if it exists in the parameter server... Please someone help hahaha

dump rosparam at program exit

$
0
0
Is it possible to dump rosparam when the node stops using roslaunch? On the [wiki](http://wiki.ros.org/roslaunch/XML/param) it is stated, that "dump" and "delete" commands run *before* load, which is exactly opposite from what I want. Currently I do it manually like this: void dumpRooms(std::string yamlFile) { system("rosparam dump -v "+yamlFile.c_str()+" my_namespace"); }

reading parameter in c

$
0
0
Hello, I am trying to read parameters in my program based on this example http://wiki.ros.org/Parameter%20Server Here is code snippet std::string my_number; nh_.getParam("my_number",my_number); ROS_INFO("\n My Number %s",my_number.c_str()); And I am calling like this rosrun mypkg my_node my_number:=5 This value is not getting read. Please help, how can I read in my C program. Thanks, Hemant

change reconfiguration gui content during runtime

$
0
0
Hello, is there a way to generate the content of the reconfiguration GUI during runtime? For instance a drop down list where it's content is decided after program start. I know the variables are declared in the .cfg and I need to compile the package in order to get the according header files. But is it possible to assign a created parameter on the parameter server to, for instance a drop down list? Thanks in advance, Chris

How to see all parameters in the parameter server ?

$
0
0
Hello everyone ! I use the eband_local_planner for the navigation of my robot in simulation.
The problem is that when I type the command `rosparam list`, I can't see the parameters of my planner.
It is the same if I type `rosparam get parameter_name`, I get a message which says that the requested parameter does not exist.
However, if I load these invisible parameters from a YAML file, I can see their effects but they doesn't appear in the parameter server through the previously indicated commands.
They doesn't appear neither using the `rosrun rqt_reconfigure rqt_reconfigure` command.
My question is: How to have this visibility ?
I ask that because I want to be able to access these parameters in the parameter server in order to modify the behaviour of my robot from a C++ node. If anyone can help me, I will be grateful,
lfr

How to get/set a "system state" in ROS?

$
0
0
I'm porting a system to ROS that will be composed of several nodes linked by topics in a chain-like structure, in a way that each node produces some data to be consumed by the callback of the next node. The problem I'm facing is that some of the nodes set variables that represent "system states" that influence the behavior of other nodes later in the chain (not the next imediate one). I'm wondering what is the best way to implement such thing on ROS. I though about using the parameter server with getParam() and setParam() for that, but I read in the [Parameter Server page](http://wiki.ros.org/Parameter%20Server) that: > As it is not designed for high-performance, it is best used for static, non-binary data such as configuration parameters. So I'm not sure if I should use it for these state variables. I also read about getCachedParam(), but I think the same doubt about the performance applies. I also saw [dynamic_reconfigure](http://wiki.ros.org/dynamic_reconfigure), but I don't know if it was developed for this kind of scenario. Could anyone tell me what would be the best way to implement this in ROS?

Synchronized data between multiple robots

$
0
0
Hi, I implemented an application in which I have three robots, each one running it's own control node, and the ROS master running on a notebook. The control node is the same, however each robot runs its own instance of it, with a different namespace. There are some parameters that are used by the control algorithm. The nodes subscribe to a specific topic and I am able to change the value of these parameters by publishing messages to this topic: when the robots receive the message they change the variable to its new value. The idea is that, although each robot has its own copy of the variable representing the parameter, all robots always use the same values, so the variables must be synchronized. Is there a best way or good practice to implement something like that? I thought maybe using the parameter server to store the current value of each parameter, but I am not sure if this is the best idea.

Can rosserial set parameters?

$
0
0
The [rosserial parameter](http://wiki.ros.org/rosserial/Overview/Parameters) documentation shows getting parameters from the parameter server, but not setting parameters. Is there a way to set parameters from rosserial? I'm guessing not, since the [`NodeHandle` class](https://github.com/ros-drivers/rosserial/blob/46a7d8be2af4a5fae0f9c324369eab31394c0d4e/rosserial_client/src/ros_lib/ros/node_handle.h) only has parameter getters, not setters, but I'm wondering if anything's in the works or why this hasn't been a priority yet.

high-performance status checking

$
0
0
Each time I read and write from and to the servos in my symmetric robot, I want to check a mode that determines which servos to talk to (the frames of this robot can change while it's running). Because the reading and writing happens continuously through topics, I want to make sure this checking adds as little overhead as possible. I considered two solutions: services and a parameter server. From what I understand, [services](http://wiki.ros.org/Services) seem to be able to do this quickly, but it looks like they can't deliver a different response, as when the mode changes. A [Parameter Server](http://wiki.ros.org/Parameter%20Server) can do the trick, but the wiki explicitly states that it's not meant for high-performance and dynamic data. Are there any other solutions or am I overestimating the overhead with the parameter server?

How to pass a parameter of type double as an input to a roscpp node?

$
0
0
I'm trying to pass a variable of type "double" to a roscpp node as a command-line variable. E.g. $ rosrun package_name node_name parameter:=0.1 And then access the parameter within the node like so: ros::NodeHandle nh; double parameter; nh.param("parameter", parameter, 0.5); However this doesn't work, and instead I get the following error: terminate called after throwing an instance of 'ros::InvalidNameException' what(): Character [0] is not valid as the first character in Graph Resource Name [0.1]. Valid characters are a-z, A-Z, / and in some cases ~. I'm sure I've just got the wrong syntax, either within the node or when entering the parameter. I've thoroughly read the wiki pages on [NodeHandle](http://wiki.ros.org/roscpp/Overview/NodeHandles) and the [Parameter Server](http://wiki.ros.org/roscpp/Overview/Parameter%20Server), but I haven't found a solution. Everything I've tried either produces the error above, or my ignores the input and sets the parameter to it's default value (0.5). Is anyone able to correct my syntax? Thanks in advance.

Where does the parameter server store data?

$
0
0
Where on disk does the [parameter server](http://wiki.ros.org/Parameter%20Server) store data to when it's not running?

best practices: when to use parameter server and when not?

$
0
0
Hi, I was wondering what experiences people have had from using the parameter server... 1. What cases must you use the parameter server? What types of data would you not read through the parameter server? 2. What cases should you use some other methods, like a shared memory file? 3. When should you use command line arguments? 4. What other options do you have in addition to these? Thank you

Tell me how to use parameter server with rosjava

$
0
0
I want to make parameter server with rosjava. But I can not. As far as I've looked up, I can not find the latest information on parameter server anywhere. That's why I want you to help me I want to use AddTwoInts. However, when executing catkin_make, it says that the package of AddTwolnts can not be found. I guessed I had to edit build.gradle. But I do not know how to edit it che License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.github.rosjava.test; import org.apache.commons.logging.Log; import org.ros.node.Node; import org.ros.node.NodeMain; import org.ros.node.service.ServiceClient; import org.ros.node.service.ServiceResponseListener; import org.ros.exception.RemoteException; import org.ros.service.test_ros.AddTwoInts; import org.ros.namespace.GraphName; // add for parameter import org.ros.node.parameter.ParameterTree; /* * @author OTL */ public class Parameters implements NodeMain { @Override public GraphName getDefaultNodeName() { return new GraphName("rosjava_tutorial_service/client"); } @Override public void onStart(Node node) { try { ServiceClient client = node.newServiceClient("/add_two_ints", "test_ros/AddTwoInts"); Thread.sleep(100); AddTwoInts.Request srv = new AddTwoInts.Request(); // add for parameter ParameterTree params = node.newParameterTree(); srv.a = params.getInteger("/a", 1); srv.b = params.getInteger("/b", 5); client.call(srv, new ServiceResponseListener() { @Override public void onSuccess(AddTwoInts.Response res) { log.info("call service success! " + res.sum); } @Override public void onFailure(RemoteException arg) { log.info("call service fail"); } }); } catch (Exception e) { if (node != null) { node.getLog().fatal(e); } else { e.printStackTrace(); } } } @Override public void onShutdown(Node node) { } @Override public void onShutdownComplete(Node node) { } }

run_id on parameter server does not match declared run_id

$
0
0
I have set up several `roslaunch` files to be launched at system startup using `systemd`. However at the startup they show the above error and fail. When I set the `systemd` services to be restarted on failure, launch files are relaunched when failed and work fine. What might I be doing wrong here? **Declared `run_id` for each `roslaunch` seems to be different from each other at the first launch.** The error is in the following format run_id on parameter server does not match declared run_id: 686cb5dc-01cf-11e9-ab7c-b10995016401 vs 68b27f9a-01cf-11e9-ab7c-b10995016401 Here's a sample script that runs a launch file #!/bin/bash sleep 1 source /opt/ros/kinetic/setup.bash source /my/workspace/path/devel/setup.bash roslaunch /launch/file/path/myfile.launch Here's the format of the systemd services I use [Unit] Description=Unit description Wants=roscore.service BindsTo=roscore.service [Service] User=username ExecStart=/script/that/runs/the/launch/file.sh Restart=on-failure RestartSec=1 [Install] WantedBy=multi-user.target `roscore.service` starts a roscore. I am using `kinetic` on `Ubuntu 16.04`.

Updated value in Parameter server not reflecting in real time Camera

$
0
0
Hi all, I am using two cameras and I have a .yaml file having the parameter list like fps, Width and length of the image, Pixels and few more. I have created a parameter server and have stored the parameters to access it in real time. The problem is that I am able to change the parameters in real time but is not getting reflected in the camera output feed. For example...If my camera is producing output at 30 fps and I have changed my fps to 10 in real time so there is a significant difference between the fps but this is not being reflected in the output but my paramter server is getting updated. How to update the camera parameters in real time. I am using getParam() to read the values. Below is my Publisher code. #include "ros/ros.h" #include "usb_cam/usb_cam.h" #include "image_transport/image_transport.h" #include "camera_info_manager/camera_info_manager.h" #include "sstream" #include namespace usb_cam { class UsbCamNode { public: // private ROS node handle ros::NodeHandle node_; // shared image message sensor_msgs::Image img_; image_transport::CameraPublisher image_pub_; // parameters std::string video_device_name_, io_method_name_, pixel_format_name_, camera_name_, camera_info_url_; //std::string start_service_name_, start_service_name_; bool streaming_status_; int image_width_, image_height_, framerate_, exposure_, brightness_, contrast_, saturation_, sharpness_, focus_, white_balance_, gain_; bool autofocus_, autoexposure_, auto_white_balance_; boost::shared_ptr<:camerainfomanager> cinfo_; UsbCam cam_; ros::ServiceServer service_start_, service_stop_; bool service_start_cap(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res ) { cam_.start_capturing(); return true; } bool service_stop_cap( std_srvs::Empty::Request &req, std_srvs::Empty::Response &res ) { cam_.stop_capturing(); return true; } UsbCamNode() : node_("~") { // advertise the main image topic image_transport::ImageTransport it(node_); image_pub_ = it.advertiseCamera("image_raw", 0); // grab the parameters node_.param("video_device", video_device_name_, std::string("/dev/video0")); node_.param("brightness", brightness_, -1); //0-255, -1 "leave alone" node_.param("contrast", contrast_, -1); //0-255, -1 "leave alone" node_.param("saturation", saturation_, -1); //0-255, -1 "leave alone" node_.param("sharpness", sharpness_, -1); //0-255, -1 "leave alone" // possible values: mmap, read, userptr // node_.getParam("/io_method", io_method_name_, std::string("mmap")); node_.getParam("/io_method", io_method_name_); node_.getParam("/image_width", image_width_); node_.getParam("/image_height", image_height_); //node_.param("framerate", framerate_, 20); node_.getParam("/framerate", framerate_); // possible values: yuyv, uyvy, mjpeg, yuvmono10, rgb24 // node_.param("/pixel_format", pixel_format_name_, std::string("mjpeg")); node_.getParam("/pixel_format", pixel_format_name_); // enable/disable autofocus // enable/disable autofocus node_.param("autofocus", autofocus_, false); node_.param("focus", focus_, -1); //0-255, -1 "leave alone" // enable/disable autoexposure node_.param("autoexposure", autoexposure_, true); node_.param("exposure", exposure_, 100); node_.param("gain", gain_, -1); //0-100?, -1 "leave alone" // enable/disable auto white balance temperature node_.param("auto_white_balance", auto_white_balance_, true); node_.param("white_balance", white_balance_, 4000); // load the camera info node_.param("camera_frame_id", img_.header.frame_id, std::string("head_camera")); node_.param("camera_name", camera_name_, std::string("head_camera")); node_.param("camera_info_url", camera_info_url_, std::string("")); cinfo_.reset(new camera_info_manager::CameraInfoManager(node_, camera_name_, camera_info_url_)); // create Services service_start_ = node_.advertiseService("start_capture", &UsbCamNode::service_start_cap, this); service_stop_ = node_.advertiseService("stop_capture", &UsbCamNode::service_stop_cap, this); // check for default camera info if (!cinfo_->isCalibrated()) { cinfo_->setCameraName(video_device_name_); sensor_msgs::CameraInfo camera_info; camera_info.header.frame_id = img_.header.frame_id; camera_info.width = image_width_; camera_info.height = image_height_; cinfo_->setCameraInfo(camera_info); } ROS_INFO("Starting '%s' (%s) at %dx%d via %s (%s) at %i FPS", camera_name_.c_str(), video_device_name_.c_str(), image_width_, image_height_, io_method_name_.c_str(), pixel_format_name_.c_str(), framerate_); // set the IO method UsbCam::io_method io_method = UsbCam::io_method_from_string(io_method_name_); if(io_method == UsbCam::IO_METHOD_UNKNOWN) { ROS_FATAL("Unknown IO method '%s'", io_method_name_.c_str()); node_.shutdown(); return; } // set the pixel format UsbCam::pixel_format pixel_format = UsbCam::pixel_format_from_string(pixel_format_name_); if (pixel_format == UsbCam::PIXEL_FORMAT_UNKNOWN) { ROS_FATAL("Unknown pixel format '%s'", pixel_format_name_.c_str()); node_.shutdown(); return; } // start the camera cam_.start(video_device_name_.c_str(), io_method, pixel_format, image_width_, image_height_, framerate_); // set camera parameters if (brightness_ >= 0) { cam_.set_v4l_parameter("brightness", brightness_); } if (contrast_ >= 0) { cam_.set_v4l_parameter("contrast", contrast_); } if (saturation_ >= 0) { cam_.set_v4l_parameter("saturation", saturation_); } if (sharpness_ >= 0) { cam_.set_v4l_parameter("sharpness", sharpness_); } if (gain_ >= 0) { cam_.set_v4l_parameter("gain", gain_); } // check auto white balance if (auto_white_balance_) { cam_.set_v4l_parameter("white_balance_temperature_auto", 1); } else { cam_.set_v4l_parameter("white_balance_temperature_auto", 0); cam_.set_v4l_parameter("white_balance_temperature", white_balance_); } // check auto exposure if (!autoexposure_) { // turn down exposure control (from max of 3) cam_.set_v4l_parameter("exposure_auto", 1); // change the exposure level cam_.set_v4l_parameter("exposure_absolute", exposure_); } // check auto focus if (autofocus_) { cam_.set_auto_focus(1); cam_.set_v4l_parameter("focus_auto", 1); } else { cam_.set_v4l_parameter("focus_auto", 0); if (focus_ >= 0) { cam_.set_v4l_parameter("focus_absolute", focus_); } } } virtual ~UsbCamNode() { cam_.shutdown(); } bool take_and_send_image() { node_.getParam("/framerate", framerate_); node_.getParam("/io_method", io_method_name_); node_.getParam("/pixel_format", pixel_format_name_); UsbCam::pixel_format pixel_format = UsbCam::pixel_format_from_string(pixel_format_name_); UsbCam::io_method io_method = UsbCam::io_method_from_string(io_method_name_); cam_.start_capturing(); ros::Rate loop_rate(/*this->*/framerate_); ROS_INFO("Frame Rate : %d ", framerate_); cam_.fps(framerate_); // grab the image cam_.grab_image(&img_); // grab the camera info sensor_msgs::CameraInfoPtr ci(new sensor_msgs::CameraInfo(cinfo_->getCameraInfo())); ci->header.frame_id = img_.header.frame_id; ci->header.stamp = img_.header.stamp; // publish the image image_pub_.publish(img_, *ci); return true; } bool spin() { ros::Rate loop_rate(this->framerate_); // ROS_INFO("Frame Rate : %d ", framerate_); while (node_.ok()) { if (cam_.is_capturing()) { if (!take_and_send_image()) ROS_WARN("USB camera did not respond in time."); } ros::spinOnce(); loop_rate.sleep(); } return true; } }; } int main(int argc, char **argv) { ros::init(argc, argv, "usb_cam"); usb_cam::UsbCamNode a; a.spin(); return EXIT_SUCCESS; } Kindly suggest a method or a better and simple code to update the parameters and publish the data in real time. Thanks,
Viewing all 40 articles
Browse latest View live




Latest Images