rctoris / jrosbridge

A Native Java EE rosbridge Client
http://robotwebtools.org/
Other
71 stars 46 forks source link

How to publish a message "sensor_msgs/LaserScan"? #21

Open jabrena opened 7 years ago

jabrena commented 7 years ago

Hi, I would like to send a message "sensor_msgs/LaserScan" but I don´t see the object in the package: https://github.com/rctoris/jrosbridge/tree/develop/src/main/java/edu/wpi/rail/jrosbridge/messages How to solve the problem?

In ROSJava exist this message but here, I didn´t find it:

package sensor_msgs;

import org.ros.internal.message.Message;
import std_msgs.Header;

public interface LaserScan extends Message {
    String _TYPE = "sensor_msgs/LaserScan";
    String _DEFINITION = "# Single scan from a planar laser range-finder\n#\n# If you have another ranging device with different behavior (e.g. a sonar\n# array), please find or create a different message, since applications\n# will make fairly laser-specific assumptions about this data\n\nHeader header            # timestamp in the header is the acquisition time of \n                         # the first ray in the scan.\n                         #\n                         # in frame frame_id, angles are measured around \n                         # the positive Z axis (counterclockwise, if Z is up)\n                         # with zero angle being forward along the x axis\n                         \nfloat32 angle_min        # start angle of the scan [rad]\nfloat32 angle_max        # end angle of the scan [rad]\nfloat32 angle_increment  # angular distance between measurements [rad]\n\nfloat32 time_increment   # time between measurements [seconds] - if your scanner\n                         # is moving, this will be used in interpolating position\n                         # of 3d points\nfloat32 scan_time        # time between scans [seconds]\n\nfloat32 range_min        # minimum range value [m]\nfloat32 range_max        # maximum range value [m]\n\nfloat32[] ranges         # range data [m] (Note: values < range_min or > range_max should be discarded)\nfloat32[] intensities    # intensity data [device-specific units].  If your\n                         # device does not provide intensities, please leave\n                         # the array empty.\n";

    Header getHeader();

    void setHeader(Header var1);

    float getAngleMin();

    void setAngleMin(float var1);

    float getAngleMax();

    void setAngleMax(float var1);

    float getAngleIncrement();

    void setAngleIncrement(float var1);

    float getTimeIncrement();

    void setTimeIncrement(float var1);

    float getScanTime();

    void setScanTime(float var1);

    float getRangeMin();

    void setRangeMin(float var1);

    float getRangeMax();

    void setRangeMax(float var1);

    float[] getRanges();

    void setRanges(float[] var1);

    float[] getIntensities();

    void setIntensities(float[] var1);
}

Many thanks in advance.

Juan Antonio

rctoris commented 7 years ago

This package implements a few example message packages for reference but not all of them. You would need to implement an additional messages that you need or just a generic JSON approach from the Message class itself.

jabrena commented 7 years ago

Many thanks @rctoris,

Tomorrow using the idea from ROSJava Interface, I will try to publish a message from a LaserScan

If the POC goes well, do you like a PR?

Cheers

Juan Antonio

jabrena commented 7 years ago

Hi @rctoris,

Finally, I could migrate the message to ROSBridge.

Here is the class: https://github.com/ev3dev-lang-java/ros/blob/develop/src/main/java/edu/wpi/rail/jrosbridge/messages/sensor_msgs/LaserScan.java

Now, I can publish LIDAR data from a RPLidar on ROS using ROSBridge.

Cheers

Juan Antonio