Crafting ROS simple message packets with scapy?

0

I'm writing a controller software for my robot and i need to send feedback states back to ROS, otherwise it will not send joint data out. I'm trying to send it packets with just dummy data and I'm a little lost in how I should be definging a custom message that I can use to send and receive joint position data to and from ROS.

http://wiki.ros.org/Industrial/Tutorials/create_joint_position_streaming_interface_using_tcp_socket_libraries

Here is the construction of the feedback message.

http://wiki.ros.org/simple_message

The message has a structure like this:

- PREFIX

  (not considered part of the message)
  int LENGTH (HEADER + DATA) in bytes

- HEADER

int MSG_TYPE identifies type of message (standard and robot specific values)

int COMM_TYPE identified communications type

int REPLY CODE reply code (only valid in service replies)

- BODY

ByteArray DATA variable length data determined by message type and and communications type.

This is what I've got so far:

class simpleMessage_feedback(Packet):
name = "joint feedback"
fields_desc = [ByteEnumField("message_ID", 10),
               ByteEnumField("comm_type",1),
               ByteEnumField("reply",0 ),
               ]

And this is how a proper packet looks:

Protocol Length Info
 20 0.126020       192.168.245.156       10.116.249.229        SIMPLEMESSAGE 202    Joint Feedback (0x0f)

Frame 20: 202 bytes on wire (1616 bits), 202 bytes captured (1616 bits) on interface 0

Ethernet II, Src: YaskawaE_a7:58:cc (00:20:b5:a7:58:cc), Dst: WistronI_e6:1b:88 (3c:97:0e:e6:1b:88)

Internet Protocol Version 4, Src: 192.168.245.156, Dst: 10.116.249.229

Transmission Control Protocol, Src Port: 50241, Dst Port: 55753, Seq: 961, Ack: 1, Len: 148

ROS-Industrial SimpleMessage, Joint Feedback (0x0f), 148 bytes, big-endian

Prefix
    Packet Length: 144

Header
    Message Type: Joint Feedback (0x0000000f)
    Communications Type: Topic (1)
    Reply Code: Unused / Invalid (0)

Body
    Robot ID: 0
    Valid Fields: 0x02 (Position)
    Time: 0
    Positions
        J1:    1.627860546
        J2:    1.557143927
        J3:   -1.281998992
        J4:   -0.000045564
        J5:   -0.925309300
        J6:   -0.943217814
    Velocities
        J1:    0.000000000
        J2:    0.000000000
        J3:    0.000000000
        J4:    0.000000000
        J5:    0.000000000
        J6:    0.000000000
    Accelerations
        J1:    0.000000000
        J2:    0.000000000
        J3:    0.000000000
        J4:    0.000000000
        J5:    0.000000000
        J6:    0.000000000
python
ros
scapy
asked on Stack Overflow Jul 9, 2019 by Roiki437 • edited Jul 9, 2019 by Roiki437

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0