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

Akitoshi's profile - activity

2019-03-01 12:33:19 -0500 marked best answer Output of colored point clouds

Hello. I think that it is pretty rudimentary, but I will ask you a question because I can not solve it by trial and error. I am writing a program that outputs colored point clouds. So, I wrote the program as below, but on rviz a white point clouds is output. I changed the rgb value to various values, but there was no change. What should I do? Thank you.

#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl_conversions/pcl_conversions.h>

typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloud;

int main(int argc, char** argv)
{
    ros::init (argc, argv, "pub_pcl");
    ros::NodeHandle nh;
    ros::Publisher pub = nh.advertise<PointCloud> ("points2", 1);

    ros::Rate loop_rate(1);
    while (nh.ok())
    {
        PointCloud::Ptr msg (new PointCloud);
        msg->header.frame_id = "/my_frame";
        pcl_conversions::toPCL(ros::Time::now(), msg->header.stamp);
        msg->height = 480;
        msg->width = 640;
        msg->points.resize(480*640);


        for(int n=0; n<480; ++n) {
            for(int m=0; m<640; ++m) {
                msg->points[n*480+m].x = 1.0;
                msg->points[n*480+m].y = 0.01*(m-320);
                msg->points[n*480+m].z = 0.01*n;
                msg->points[n*480+m].r = 200;
                msg->points[n*480+m].g = 0;
                msg->points[n*480+m].b = 0;
                msg->points.push_back (msg->points[n*480+m]);
            }
        }

        pcl_conversions::toPCL(ros::Time::now(), msg->header.stamp);
        pub.publish (msg);
        ros::spinOnce ();
        loop_rate.sleep ();
    }
}
2018-02-14 02:09:29 -0500 received badge  Student (source)
2018-02-13 20:19:24 -0500 received badge  Famous Question (source)
2017-11-20 06:12:45 -0500 received badge  Notable Question (source)
2017-10-16 17:37:15 -0500 marked best answer Call multiple subscriber periodically at the same time

Hello. I would like to write a program that calls multiple subscribers periodically at the same time. Therefore, at the beginning, I wrote the program as shown in program1, but only rewritten main() like program2. In the program of program1, ros::spin() called three subscribers separately. So I decided to call them periodically using while. However, even in program2, they were called differently. Moreover, in program1, the publisher written in depthCb which was being executed also is not executed. How can I write the program to call multiple subscribers periodically at the same time? Thank you.

program1

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

void messageCallback(const sensor_msgs::JointState::ConstPtr& msg3)
{
   ...
}

void imageCb(const sensor_msgs::ImageConstPtr& msg2)
{
   ...
}

void depthCb( const sensor_msgs::ImageConstPtr& msg1)
{
   ...
   ros::Publisher pub = n.advertise<PointCloud> ("points2", 1);
   PointCloud::Ptr cloud (new PointCloud);
   cloud->header.frame_id = "/base";
   pcl_conversions::toPCL(ros::Time::now(), cloud->header.stamp);
   ...
   cloud->points.push_back (cloud->points[0]);
   pcl_conversions::toPCL(ros::Time::now(), cloud->header.stamp);
   pub.publish (cloud);
}

int main( int argc, char* argv[])
{
   ros::init( argc, argv, "depth_viewer" );
   ros::NodeHandle n;

   ros::Subscriber joint = n.subscribe("/hp3j/joint_states", 1000, messageCallback);
   ros::Subscriber color = n.subscribe("/pico_flexx_link_ir/image_raw", 1000, imageCb);
   ros::Subscriber depth = n.subscribe("/pico_flexx_link/depth_registered/image_raw", 3, &depthCb);

   ros::spin();
   return 0;
}

program2

int main(argc, char* argv[])
{
   ros::init( argc, argv, "depth_viewer" );
   ros::NodeHandle n;

   ros::Subscriber joint = n.subscribe("/hp3j/joint_states", 1000, messageCallback);
   ros::Subscriber color = n.subscribe("/pico_flexx_link_ir/image_raw", 1000, imageCb);
   ros::Subscriber depth = n.subscribe("/pico_flexx_link/depth_registered/image_raw", 3, &depthCb);

   ros::Rate loop_rate(0.1);
   while (ros::ok()) {
      ros::spinOnce();
      loop_rate.sleep();
   }

   return 0;
}
2017-08-14 14:10:24 -0500 commented question Output of colored point clouds

I'm using indigo on 14.04. Today, once again I tried running the same code, somehow the display on the left of the rviz

2017-08-13 09:20:25 -0500 received badge  Popular Question (source)
2017-08-12 02:31:42 -0500 commented question Output of colored point clouds

Thank @lucasw. As you say, I have duplicated every points. However, erasing this one line did not solve the problem.

2017-08-11 07:39:10 -0500 received badge  Famous Question (source)
2017-08-11 07:37:29 -0500 asked a question Output of colored point clouds

Output of colored point clouds Hello. I think that it is pretty rudimentary, but I will ask you a question because I can

2017-08-08 10:04:39 -0500 commented answer Call multiple subscriber periodically at the same time

Thank @NEngelhard! As you said, adding using namespace message_filters; has solved it!

2017-08-08 08:54:37 -0500 received badge  Famous Question (source)
2017-08-08 05:50:10 -0500 commented question Call multiple subscriber periodically at the same time

Thank @naveedhd for your early reply. In addition to the two data I would like to acquire the joint angle of the manipul

2017-08-08 05:44:32 -0500 commented answer Call multiple subscriber periodically at the same time

Thank @NEngelhard. I'm sorry for the late reply. As you say, I programmed while watching 4.2 Example (C ++) of wiki. How

2017-08-08 04:57:16 -0500 commented question Call multiple subscriber periodically at the same time

Thank @naveedhd. I'm sorry for the late reply. I understood what I was misunderstanding as you said. However, neverthele

2017-08-04 13:47:16 -0500 received badge  Notable Question (source)
2017-08-04 09:28:02 -0500 received badge  Popular Question (source)
2017-08-04 04:48:07 -0500 asked a question Call multiple subscriber periodically at the same time

Call multiple subscriber periodically at the same time Hello. I would like to write a program that calls multiple subscr

2017-08-03 02:53:40 -0500 received badge  Enthusiast
2017-07-28 04:33:09 -0500 received badge  Notable Question (source)
2017-07-28 02:20:01 -0500 commented question Program combining publisher and subscriber

@ahendrix I'm sorry, because I had a missing entry in http://answers.ros.org/question/267540/publisher-and-subscriber-in

2017-07-28 01:21:05 -0500 asked a question Program combining publisher and subscriber

Program combining publisher and subscriber Hello. I want to write publisher and subscriber in the same node. So I wrote

2017-07-28 01:09:25 -0500 received badge  Popular Question (source)
2017-07-28 01:05:32 -0500 commented answer publisher and subscriber in the same node

@jayess Ok, I will.

2017-07-28 00:04:56 -0500 answered a question publisher and subscriber in the same node

Thank @jayess. As you said pulisher was missing. The real program is as follows. In my program I subscribe depth values

2017-07-27 12:44:26 -0500 asked a question publisher and subscriber in the same node

publisher and subscriber in the same node Hello. I want to write publisher and subscriber in the same node. So I wrote t