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

Sergey Kravchenko's profile - activity

2019-07-18 11:21:33 -0500 received badge  Famous Question (source)
2019-01-08 05:35:24 -0500 received badge  Famous Question (source)
2019-01-08 05:35:24 -0500 received badge  Notable Question (source)
2019-01-08 05:35:24 -0500 received badge  Popular Question (source)
2018-07-18 11:00:51 -0500 received badge  Famous Question (source)
2018-07-18 11:00:51 -0500 received badge  Notable Question (source)
2018-07-18 11:00:51 -0500 received badge  Popular Question (source)
2018-05-31 15:50:15 -0500 received badge  Famous Question (source)
2017-10-27 02:38:57 -0500 received badge  Notable Question (source)
2017-09-08 12:33:41 -0500 received badge  Notable Question (source)
2017-08-19 01:53:36 -0500 marked best answer How to pull a message from queue with time interval?

When I subscribe my node, I set messages queue size and callback function:

int main(int argc, char **argv) {

    ros::init(argc, argv, "scs_drive");

    ros::NodeHandle n;

    ros::Subscriber sub = n.subscribe("scs", 1000, writePosCallback);

    ros::spin();
    return 0;
}

The incoming messages are being processed as soon as previous callback function operations are finished. But I want to process incoming messages from queue not ASAP but each millisecond.

So maybe it is possible to pull messages here:

int main(int argc, char **argv) {

    ros::init(argc, argv, "scs_drive");

    ros::NodeHandle n;

    ros::Subscriber sub = n.subscribe("scs", 1000, writePosCallback);

    ros::Rate loop_rate(1000);

    while (ros::ok()) {

        //some code here that pulls message from queue and process incoming data

        ros::spinOnce();
        loop_rate.sleep();
    }

    return 0;
}

Or I need to set pause in callback function and it is the one choice to process messages with a certain time interval?

2017-08-19 01:52:31 -0500 received badge  Enthusiast
2017-08-16 17:32:14 -0500 received badge  Popular Question (source)
2017-08-16 04:16:20 -0500 asked a question How to pull a message from queue with time interval?

How to pull a message from queue with time interval? When I subscribe my node, I set messages queue size and callback fu

2017-08-15 09:38:38 -0500 edited question rqt_publisher does not work

rqt_publisher does not work I use ROS Kinetic under Ubuntu 16.04 I run rqt_publisher. Then I add a message of any type,

2017-08-15 09:36:32 -0500 edited question rqt_publisher does not work

rqt_publisher does not work I use ROS Kinetic under Ubuntu 16.04 I run rqt_publisher. Then I add a message of any type,

2017-08-15 09:35:31 -0500 asked a question rqt_publisher does not work

rqt_publisher does not work I use ROS Kinetic under Ubuntu 16.04 I run rqt_publisher. Then I add a message of any type,

2017-08-15 04:28:36 -0500 marked best answer Compiler error when trying to read message values

Here is my SWrite.msg file

int16 id
int16 pos
int16 time

Here is my CMakeLists.txt

set (CMAKE_CXX_STANDARD 11)

# %Tag(FULLTEXT)%
cmake_minimum_required(VERSION 2.8.3)
project(scs_servo_control)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)

add_message_files(FILES SWrite.msg)

generate_messages(DEPENDENCIES std_msgs)

catkin_package()

include_directories(include ${catkin_INCLUDE_DIRS} )

add_executable(scs_listener src/scs_listener.cpp)
add_library(hardwareserial src/HardwareSerial.cpp)
add_library(scservo src/SCServo.cpp)
add_library(scsprotocol src/SCSProtocol.cpp)
target_link_libraries(scs_listener ${catkin_LIBRARIES} hardwareserial scservo scsprotocol)
add_dependencies(scs_listener beginner_tutorials_generate_messages_cpp)

# %EndTag(FULLTEXT)%

And here is my callback function:

void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
  int id = msg->id;
}

I get compiler error with this:

/home/serge/NetBeansProjects/ROS_beginner_tutorials/ros_ws/src/scs_servo_control/src/scs_listener.cpp: In function ‘void chatterCallback(const ConstPtr&)’:
/home/serge/NetBeansProjects/ROS_beginner_tutorials/ros_ws/src/scs_servo_control/src/scs_listener.cpp:26:19: error: ‘const struct std_msgs::String_<std::allocator<void> >’ has no member named ‘id’
     int id = msg->id;
                   ^
scs_servo_control/CMakeFiles/scs_listener.dir/build.make:62: recipe for target 'scs_servo_control/CMakeFiles/scs_listener.dir/src/scs_listener.cpp.o' failed

It seems to be logical, because id (and also pos and time) is nowhere defined as member.

But I read this https://answers.ros.org/question/5458...

and this

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

and it confuses me.

So how can I read values from a message in my callback function? What I missed?

2017-08-15 03:36:22 -0500 received badge  Editor (source)
2017-08-15 03:36:22 -0500 edited question Compiler error when trying to read message values

Compiler error when trying to read message values Here is my SWrite.msg file int16 id int16 pos int16 time Here is my

2017-08-15 03:35:44 -0500 asked a question Compiler error when trying to read message values

Compiler error when trying to read message values Here is my SWrite.msg file int16 id int16 pos int16 time Here is my

2017-08-11 16:56:40 -0500 received badge  Popular Question (source)
2017-08-11 09:25:44 -0500 edited question How to add includes?

How to add includes? I want to add some classes to my node. The classes are stored in separate files. So now I add heade

2017-08-11 09:25:07 -0500 asked a question How to add includes?

How to add includes? I want to add some classes to my node. The classes are stored in separate files. So now I add heade

2017-08-08 22:49:27 -0500 commented answer Problem with robot_upstart

sorry, my bad:)

2017-08-08 22:49:05 -0500 received badge  Supporter (source)
2017-08-08 22:49:02 -0500 received badge  Popular Question (source)
2017-08-06 13:12:28 -0500 marked best answer Problem with robot_upstart

I am trying to install robot_upstart for my package

serge@media:~/NetBeansProjects/ROS_beginner_tutorials/ros_ws$ rosrun robot_upstart install beginner_tutrorials/launch/m1.launch

But I get the error

Unable to locate path launch/m1.launch in package beginner_tutrorials. Installation aborted.

I already entered the command

source ./devel/setup.bash

And am definitely sure that it it works, because

rosrun beginner_tutorials talker

works properly. And if I do not enter source command I can't run the talker, so the source is added

Also when I enter

rospack find beginner_tutorials

the package can be found.

So what can be a cause of the problem? And maybe I understand something wrong about robot_upstart. Does it creates a new launch file or can only write/overwrite data in existing launchfile or maybe it require a ready launchfile?

2017-08-06 13:12:28 -0500 received badge  Scholar (source)
2017-08-06 10:18:59 -0500 asked a question Problem with robot_upstart

Problem with robot_upstart I am trying to install robot_upstart for my package serge@media:~/NetBeansProjects/ROS_begin