ros2dart / dartros1

A ROS1 client library for dart
Apache License 2.0
20 stars 11 forks source link

Add documentation on msg generation #5

Open TimWhiting opened 4 years ago

TimWhiting commented 4 years ago

https://github.com/TimWhiting/gendart is a message generation package for dartros. I need to more fully document how to use it.

Essentially the basics are to clone the gendart repository into your catkin workspace, and then run catkin_make. As long as some catkin package depends on message generation it should generate messages. I'm trying to remember if there was anything else I needed to make it work.

The generated messages will be in the devel folder of your workspace more specifically: devel/share/gendart/ros/{name_of_msg_package}.

You can depend on this in your dart node via a path dependency. Assuming your dart node is in the src folder this would look like this:

# pubspec.yaml
dependencies:
  sensor_msgs:
    path: ../../devel/share/gendart/ros/sensor_msgs

Then to use it to publish an image you might do something like this:

import 'package:dartros/dartros.dart';
import 'package:dartx/dartx.dart';
import 'package:sensor_msgs/msgs.dart';

Future<void> main(List<String> args) async {
  final node = await initNode('test_node', args);
  final img_msg = Image(
      header: null,
      height: 600,
      width: 1024,
      encoding: 'rgba8',
      is_bigendian: 0,
      step: 1024 * 4,
      data: List.generate(600 * 1024 * 4, (_) => 255));
  final pub = node.advertise<Image>('/robot/head_display', Image.$prototype);
  await Future.delayed(2.seconds);
  while (true) {
    pub.publish(img_msg, 1);
    await Future.delayed(2.seconds);
  }
}
TimWhiting commented 4 years ago

@knuesel, can you update the documentation if anything changes when you add the action messages / rework message generation. I've put the above information on pub.dev now.

knuesel commented 4 years ago

OK! Not sure if I'll have time to work on it this week, but I'll keep it in mind anyway.

TimWhiting commented 4 years ago

Yeah, no hurries. I was just putting some basic documentation on the README, and wanted to link you into this issue so that we can make sure the documentation stays up to date if anything changes.

knuesel commented 3 years ago

I've left the "big changes" on the side for now since it works, might revisit in the future. I didn't notice anything to change in the documentation.

TimWhiting commented 3 years ago

Thats fine, at some point an example or something for Actions would be great.

knuesel commented 3 years ago

Then in might make sense to move the Coffee test to the dartros repository (in example/, with the generated message files in a subdirectory)?