dartros icon indicating copy to clipboard operation
dartros copied to clipboard

Add documentation on msg generation

Open TimWhiting opened this issue 4 years ago • 6 comments

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 avatar Nov 12 '20 18:11 TimWhiting

@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.

TimWhiting avatar Nov 18 '20 19:11 TimWhiting

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

knuesel avatar Nov 18 '20 19:11 knuesel

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.

TimWhiting avatar Nov 18 '20 19:11 TimWhiting

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.

knuesel avatar Dec 17 '20 17:12 knuesel

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

TimWhiting avatar Dec 17 '20 23:12 TimWhiting

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

knuesel avatar Dec 18 '20 10:12 knuesel