Giter Site home page Giter Site logo

ros2_idl_demo's Introduction

idl_msgs

Test package for ROS2 idl message generation.

This package demonstrates the ability to generate ROS messages directly from an IDL file. An example IDL from the rosidl repository is used as a test. The MyMessage.idl file was modified from the original to remove the long double and wchar entries. The two example includes were also removed. Finally the module names were changed to match the package name and message type. i.e. rosidl_parser -> idl_msgs and msg -> idl.

module idl_msgs{. // matches package name
  module idl {. // Must be 'idl'
  // Message Contents
}
}

Building

Build the package by running:

mkdir -p idl_demo_ws/src
cd idl_demo_ws/src
git clone https://github.com/davidhodo/ros2_idl_demo.git
cd ../
colcon build

Running

Run the ROS2 publisher:

ros2 run idl_pub idl_pub

Run the ROS2 subscriber:

ros2 run idl_sub idl_sub

Run the eProsima publisher:

./install/rtps_string/lib/rtps_string/StringMsg publisher

Run the eProsima subscriber:

./install/rtps_string/lib/rtps_string/StringMsg subscriber

eProsima Code Modifications

The example code in the fastrtps_string folder was generated using eProsima's fastrtps gen by running:

fastrtpsgen -example CMake ../idl_msgs/idl/StringMsg.idl

In order to interoperate with the ROS2 publisher/subscriber the following changes must be made to the generated code.

  • Change the topic name to "rt/chatter"
  • Change the type name to idl_msgs::idl::dds_::StringMsg_

ros2_idl_demo's People

Contributors

davidhodo avatar

Stargazers

SunShine avatar  avatar Evan Flynn avatar Philipp Huth avatar Eddie Massey III avatar Ayoub Raji avatar Roald Ong avatar Jiaqiao Zhang avatar Rock Chen avatar yottayuan avatar Gean Johnson avatar

Watchers

Gean Johnson avatar  avatar Philipp Huth avatar

ros2_idl_demo's Issues

Subscriber can't receive data when msg data is bigger than 64K.

hi, I have gen a sensor_msgs::msg::PointCloud2 type msg from ROS2 PointCloud2.idl. When i fill msg.data beyong about 64Kb, the subscirber can't call the function onNewDataMessage even matched.

Publisher from ROS2 node:

auto message = sensor_msgs::msg::PointCloud2();
message.header.stamp.nanosec = 637346029;
message.header.stamp.sec = 1599623990;
message.header.frame_id = "lidar";
message.point_step = 32;
message.row_step = 57600;
message.is_dense = false;
int size = message.height * message.width ;
int k=64;
message.data.resize(k*1024);
for(int i=0; i<k*1024; i++)
{
  message.data[i] = i;
}
RCLCPP_INFO(this->get_logger(), "Publishing points");
publisher_->publish(message);

Subscriber from fastrtps:

ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0; //MUST BE THE SAME AS IN THE PUBLISHER
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.listenSocketBufferSize = 4194304;
PParam.rtps.sendSocketBufferSize = 1048576;
PParam.rtps.setName("point_subscriber"); //You can put the name you want
mp_participant = Domain::createParticipant(PParam);

Domain::registerType(mp_participant, static_cast<TopicDataType*>(&myType));

SubscriberAttributes Rparam;
Rparam.topic.topicKind = NO_KEY;
Rparam.topic.topicDataType = myType.getName(); //Must be registered before the creation of the subscriber
Rparam.topic.topicName = "rt/rslidar_points";
mp_subscriber = Domain::createSubscriber(mp_participant,Rparam, static_cast<SubscriberListener*>(&m_listener));

std::cout << "Subscriber created of type: " << Rparam.topic.topicDataType << " on topic: " 
    << Rparam.topic.topicName << std::endl;

here is the print of subscriber and publisher:

20200910172819
20200910172851

pls help! thanks a lot.

ROS2 send image to fastRTPS

Hej David,

I want to send message from ROS2 (cam2image) at the ROS2 demo exmaple to fastRTPS.

I have found IDL for this exmaple which is called Image.idl , Then I want to use fastrtpsgen to generate files for public and subscriber with IDL,
when I run
fastrtpsgen -example x64Linux2.6gcc Image.idl

It is return back me an error which is Uint is undefined.
My Image.IDL is looks like below:
// generated from rosidl_adapter/resource/msg.idl.em
// with input from sensor_msgs/msg/Image.msg

module sensor_msgs {
module msg {
/*
* This message contains an uncompressed image
* (0, 0) is at top-left corner of image
/
struct Image {
/

* Header timestamp should be acquisition time of image
* Header frame_id should be optical frame of camera
* origin of frame should be optical center of cameara
* +x should point to the right in the image
* +y should point down in the image
* +z should point into to plane of the image
* If the frame_id here and the frame_id of the CameraInfo
* message associated with the image conflict
* the behavior is undefined
*/
std_msgs::msg::Header header;

  /*
   * image height, that is, number of rows
   */
  uint32 height;

  /*
   * image width, that is, number of columns
   */
  uint32 width;

  /*
   * The legal values for encoding are in file src/image_encodings.cpp
   * If you want to standardize a new string format, join
   * [email protected] and send an email proposing a new encoding.
   * Encoding of pixels -- channel meaning, ordering, size
   * taken from the list of strings in include/sensor_msgs/image_encodings.h
   */
  string encoding;

  /*
   * is this data bigendian?
   */
  uint8 is_bigendian;

  /*
   * Full row length in bytes
   */
  uint32 step;

  /*
   * actual matrix data, size is (step * rows)
   */
  sequence<uint8> data;
};

};
};

Is there any help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.