Please modify or guide me to where I can learn to modify the talker.cpp and listener.cpp given in the beginner_tutorials to send the message Num.msg defined in the same series of tutorials. This is to help understand how to use complex msgs later on.
I replaced the example code by the following lines wherever I felt was necessary but this is not getting compiled.
**talker.cpp**
#include "beginner_tutorials/Num.h"
ros::Publisher chatter_pub = n.advertise("chatter", 1000);
beginner_tutorials::Num num;
// std::stringstream ss;
// ss <<"hello world" << count;
num = 123456789;
ROS_INFO("%d",num);
chatter_pub.publish(num);
**listener.cpp**
#include "beginner_tutorials/Num.h"
void chatterCallback(const beginner_tutorials::ConstPtr &num)
{
ROS_INFO("I heard: [%d]", num->data);
}
Also please suggest a way to understand the Num.h, std_msgs/String.h file generated by ROS, if it is to be understood at the first place to use ROS.
↧
Using Num.msg from Beginner tutorial
↧
yaml serialization for messages
Is it possible to serialize ROS messages to and from YAML files directly? I want to save some config data and a piece of this data is a geometry_msgs/Pose data type. I realized that you can publish to a node using YAML syntax in the command line and so I know they are serializable I just don't know of an API for doing so in C++.
↧
↧
Echoing custom messages over SSH error
I have a node running on an embedded platform publishing a custom message (just a `float32[]`). I have a ros master running on a different machine, and both `ROS_MASTER_URI`s and `ROS_IP`s are set correctly. On the master machine, if I run `rostopic echo `, I get:
ERROR: Cannot load message class for [/]. Are your messages built?
If I ssh into the embedded platform and run a `rostopic echo `, I get the data printed out.
I think I understand why it's not working - I haven't sourced the workspace on the embedded platform from the master - but I don't know the solution to this problem, since I want to be able to run nodes on multiple platforms, including the master.
↧
How to ROS messages via bluetooth? (arduino)
Hi everyone, maybe this could be a novice question:
As the title suggests, i would like to know if it's possible to do that.
Specifically, my aim is to send messages from an **arduino** to the master computer via bluetooth, as i want to build the typical object avoiding robot, but sending custom messages (encoder's data, distance to an object,...) via bluetooth instead of doing it via serial (USB) to that master.
Maybe i could use a BLE module like the HM-06 to do that, but i'm not sure (with the laptops own bluetooth as a receiver?).
Maybe there's a bluetooth methodology that i don't know.
As you see, i am a little bit lost.
I would appreciate a detailed answer (if it's possible) of the steps to do.
Thank you in advance!
↧
rosserial connection not working with custom messages! [SOLVED]
Hi community!
I've got a problem, as the title suggests, with my custom messages used in arduino.
I publish here the arduino code and explain later:
#include
#include
#include
ros::NodeHandle nh;
pkg1::Num type_Num;
std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);
ros::Publisher PUB2("newmessage", &type_Num);
char hello[20]= "hello world";
int counter=0;
void setup()
{
nh.initNode();
nh.advertise(chatter);
}
void loop()
{
type_Num.first_name = "danielooow";
type_Num.last_name = "gonsaleeesss";
type_Num.score = counter;
PUB2.publish( &type_Num );
str_msg.data = hello;
chatter.publish( &str_msg );
nh.spinOnce();
counter++;
delay(100);
}
As you see, the code is only an expansion of the HelloWorld example of ros_lib.
It compiles perfectly.
Once uploaded to my Arduino UNO, I call the rosserial connection:
~/catkin_ws$ rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0
And i get this error:
[INFO] [WallTime: 1458399926.066204] ROS Serial Python Node
[INFO] [WallTime: 1458399926.072844] Connecting to /dev/ttyACM0 at 57600 baud
[ERROR] [WallTime: 1458399943.176784] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
The thing is, **when I upload the HelloWorld example, the connection works!!** and the chatter topic is properly registered in the ROS master, **but when I use the new code, it doesn't** .
I just don't know what's going on here.
Thoughts:
+ I thought it could be a `delay` problem but removing the delay in the code hasn't made anything.
+ I also thought that maybe in the creation of the custom message there's a problem (something related with the CMakeLists.txt or the pakage.xml) but the message can be used in a normal non-arduino code, registering successfully in the ROS master and all that stuff, so that makes me doubt about it.
+ It's maybe that i have to use a second Node Handle??
For possible answers regarding using `#define USE_USBCON` -> i've already tried that and then the compiler says something about it requires the `iostream` library --> i just don't think that is the way to go for solving this (maybe i'm wrong i don't know..).
Thanks to everyone in advance. I would appreciate a detailed answer.
_____________________________________
**SOLVED!!! LOOK AT THE ANSWERS!**
________________________________
↧
↧
publish c structs
Hey guys,
I'm searching for a way to publish my own c struct. In my code I use a struct like:
struct test {
int a;
int b;
int c;
float d;
} ;
and I want a message that uses two integers and one "test". Of course I could use a message that uses five integers and one float to solve the problem but this is not a very well solution. I also tried [MessagesSerializationAndAdaptingTypes](http://wiki.ros.org/roscpp/Overview/MessagesSerializationAndAdaptingTypes) of the roswiki, but either I did something wrong or it does not help with this problem.
If there is already a post with this topic I'm sorry to ask this again, but I was not able to find it.
Best
ElTonno
ElTonno
↧
Using Synchronizer to batch up image messages
Given the code [on this page](http://wiki.ros.org/message_filters#Example_.28C.2B-.2B-.29-1), if I have a message file `batched_image.msg` that looks like:
sensor_msgs/Image image
sensor_msgs/CameraInfo info
And code that looks like:
void callback(const ImageConstPtr& image, const CameraInfoConstPtr& cam_info)
{
batched_image batch;
batch.image = *image;
batch.info = *cam_info;
}
This works, of course, but it involves a copy of Image, if I understand correctly. How can I avoid this copy, as in my use case I have four 1280x960 images? Ideally I would like:
sensor_msgs/ImageConstPtr image
sensor_msgs/CameraInfoConstPtr info
But that obviously doesn't work.
↧
rospy sensor_msgs.msg.BatteryState is not found
For some reason I'm not able to import the BatteryState message with rospy. This is the only message I've encountered that seems to be missing. http://docs.ros.org/indigo/api/sensor_msgs/html/msg/BatteryState.html
I'm using ros-indigo. Anyone else have this problem?
zac@nuc-2:~$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sensor_msgs.msg import Imu>>> from sensor_msgs.msg import BatteryState
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name BatteryState>>>
↧
Can you override a C++ message callback
I have a `Parent()` class that subscribes to a message `/foo` with a method `messageCallback`.
Can a derived class `Child : public Parent` override the `messageCallback` method to get notified each time a new `/foo` message arrives?
The alternative I've come up with is to have both `Parent` and `Child` subscribe to the `/foo` message and do separate things in their separate callbacks.
↧
↧
Unreliable subscribers based on launch order
How do you ensure your node subscribes to a topic? I'm finding launch order effects if a node is able to successfully subscribe.
For example, say node A publishes /A/topic, and node B consumes it.
I found that if I launch A, then B...B never receives any messages from A even though I can see A's messages with `rostopic echo /A/topic`. If I kill A and restart it, or launch it after B, then B receives the messages.
Is this a bug in ROS or am I misunderstanding how ROS messages work? I would expect a node to subscribe and receive messages on a topic regardless of when it was launched relative to the publisher. As long as both nodes are running, the launch order shouldn't matter.
The docs say launch order shouldn't matter, but this doesn't seem to be the case. Why is this?
This even seems to effect `rostopic echo`. If you call it after the publisher, it can receive messages, but if you kill and restart the publisher, `rostopic echo` shows nothing until it too is restarted.
I've found this is causing some very obscure and difficult to diagnose bugs. The only workaround I've found is to kill every single node in my system and restart...which seems hacky and inefficient.
↧
Cannot load message class for .... Are your messages built?
I have seen the other topics about the similar error (like here http://answers.ros.org/question/108976/rostopic-could-not-get-message-class-but-rosmsg-shows-msg/), but they don't seem to fit to my problem.
I am using Ubuntu 12.04 and ROS Hydro.
I have a robotino_node which is publishing several things. They show up if I use rostopic list. i also can use rostopic type and rostopic info, here the robotino_node is listed as a publisher.
But if I use rostopic hz or rostopic echo the error form the topic line shows up, eg
Cannot load message class for [robotino_msgs/PowerReadings]. Are your messages built?
rosmsg show does also work, eg
[robotino_msgs/PowerReadings]
time stamp
float current
float voltage
Now interestingly if I try rostopic echo with "bumper", which is the only std_msg published by the robotino_node it shows one time
data: False
---
but that's it.
I suspect that my cmake file for the messages is wrong, but I am not sure; it looks like this
# CATKIN_MIGRATION: removed during catkin migration
# cmake_minimum_required(VERSION 2.8.3)
project(robotino_msgs)
find_package(catkin REQUIRED COMPONENTS geometry_msgs std_msgs message_generation roscpp)
include_directories(include
${catkin_INCLUDE_DIRS}
)
add_message_files(
FILES
AnalogReadings.msg
BHAReadings.msg
DigitalReadings.msg
EncoderReadings.msg
GrapplerReadings.msg
GripperState.msg
MotorReadings.msg
NorthStarReadings.msg
PowerReadings.msg
SetBHAPressures.msg
SetBHAPressures.msg
SetGrapplerAxes.msg
SetGrapplerAxis.msg)
add_service_files(
FILES
ResetOdometry.srv
SetEncoderPosition.srv
SetGripperState.srv)
#add_dependencies(robotino_msgs geometry_msgs_generate_messages_cpp) #or yes?
#target_link_libraries(robotino_msgs ${catkin_LIBRARIES} ) # or yes
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES geometry_msgs std_msgs
)
# catkin_package parameters: http://ros.org/doc/groovy/api/catkin/html/dev_guide/generated_cmake_api.html#catkin-package
# TODO: fill in what other packages will need to use this package
catkin_package(
DEPENDS roscpp geometry_msgs std_msgs
CATKIN_DEPENDS # TODO
INCLUDE_DIRS # TODO include
LIBRARIES # TODO
)
My launch file looks like this
So even if just the std_msgs work, shouldn't at least the bumper published with a frequency of 20 hz?
I hope someone can helpt me out. Thanks.
↧
compile node which uses messages defined in an other machine
Hello everybody
I have a problem. I am using INDIGO.
I am using as ROS MASTER my own account on my pc in communication with ROS running in a virtual machine.
The problem is that I would like to subscribe a message which is defined in the nodes belonging to the virtual machine and not to my catkin folder. So basically when I compile trying to include such message, I get a compilation error saying that this package is not found. (Obviously, because it is defined in the virtual machine).
Is there any workaround for that?
Thank you
↧
Error "Client wants topic A to have B, but our version has C. Dropping connection."
In my custom application using custom message, publisher node show the following message only once on its running console when subscriber starts. Both nodes keep running but it seems nothing occur after that.
error msg:
[ERROR] [1319162712.616980036]: Client [/clientNodeA] wants topic /server_msgs/Swarm
to have datatype/md5sum [server_msgs/Swarm/6a727e7bfd7e4aadf9d23c4a779b268e],
but our version has [geometry_msgs/Point/4a842b65f413084dc2b10fb484ea7f17].
Dropping connection.
Content of the custom message (/server_msgs/Swarm):
uint32 clockValue
geometry_msgs/Point[] crowds
[Publisher node's code .cpp](http://pastebin.com/NCGRkbgw) (partial)
[Subscriber node's code .cpp](http://pastebin.com/uTGXLwBV)
Running environment: Ubuntu 11.04, electric
Thanks!
↧
↧
How to find list of messages published on particular topic?
I am using turtlebot in gazebo which uses "scan" message for publishing laser scan data, by using `rostopic type scan` command I can find out type of the message i.e. `sensor_msgs/LaserScan` , Is there way to find names of all the messages published on particular topic ?
For example, Is there any way to find out that message named "scan" is published by turtlebot knowing only the topic name i.e. `sensor_msgs/LaserScan` ?
Thanks in advance.
↧
Message definition namespaces
In message definition naming is the syntax always:
package/messagedef.msg
Suppose one wants to have sets of messages for different vehicles (perhaps the hardware is sufficiently different that this makes sense). Is this possible?
package/vehicle1/messagedef.msg
package/vehicle2/messagedef.msg
Or even
package/vehicle1/status/electrical/messagedef.msg
package/vehicle2/status/electrical/messagedef.msg
Or does message naming not work in this way?
Thanks,
-Val
↧
Must Compile Message and Service Several Times To Work
Folks (sorry for the upper case in advance...they just to make sure people understand those are **examples** of my code),
What is the proper way to create a CMakeList.txt file that includes messages and services? Every time I create a new group of messages or services and include them in my code, for **EXAMPLE**,
"my_package_msgs/MessageOrService.h"
it always takes a few "catkin_makes" for my system to recognize the library. Here is my CMakeList file:
cmake_minimum_required(VERSION 2.8.3)
project(message_package_msgs)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
geometry_msgs
sensor_msgs
)
add_message_files(
DIRECTORY
msg
FILES
Message_EXAMPLE.msg
)
add_service_files(
DIRECTORY
srv
FILES
Service_EXAMPLE.srv
)
generate_messages(
DEPENDENCIES
std_msgs
geometry_msgs
sensor_msgs
)
catkin_package(
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime geometry_msgs sensor_msgs
include_directories(
${catkin_INCLUDE_DIRS}
)
And my package.xml with the build/run only:
catkin roscpp rospy std_msgs message_generation geometry_msgs sensor_msgs roscpp rospy std_msgs sensor_msgs message_runtime geometry_msgs
What am I missing?
↧
Get (remote) node name(-space) when receiving a message
Hi all,
when I subscribe to a topic, is there a way to get the name / namespace of the publishing node on reception of a message?
I know about `ros::this_node::getName()` and the like [[Ref]](http://docs.ros.org/kinetic/api/roscpp/html/namespaceros_1_1this__node.html) but that only yields the name/-space of the *current* node. For example, assume I (manually) subscribe to `/rosout` and I am receiving a message send from the node `/foo/bar/node1`. Is there a way to get this information (`/foo/bar/node1`) in the callback?
Please note that I prefer a way to do this in **roscpp**.
Thanks in advance!
EDIT: Since I am dealing with custom messages here, I've simply added the namespace of the sender to my message definition. However, I thought there's probably some smarter way to do this (and I was hoping that the sender is already contained somewhere in the received message data).
↧
↧
Can message name end in Request?
I defined a message ConfirmRequest.msg and that did not work properly. Catkin did not generate the message automatically and when I forced it by explicitly listing the message I got problem with linking.
So is "Request" a forbidden ending of a message name? If so is that documented somewhere?
↧
Change frame_id in messages
I use kitti_player and robot_localization. kitti_player publich messages with framed_id "/kitti_player" but in robot_localization I get an error "frame_ids cannot start with a '/' ". How solve this problem?
↧
How to profile message activity?
Are there any tools for profiling or collecting statistics on the types of message activity per node?
I'm trying to troubleshoot some nodes consuming excessive amounts of CPU, and to help diagnose the problem, I'd like to get a histogram of the types of messages they publish over a given time range.
e.g. If I find something like:
topic messages/min
/mynode/encoders 23
/mynode/button 1
/mynode/imu 239423847887
/mynode/gps 56
then I'll immediately know it's publish rate for IMU messages is too high.
Obviously, I could do this manually by checking every single topic, but it's be nice to have a tool to automate this, and I don't want to reinvent the wheel.
↧