Skip to content

ezrassor_controller_server

Tiger Sachse edited this page Jun 26, 2019 · 14 revisions

Summary

The ezrassor_controller_server listens for robot instructions on the local area network. Instructions are parsed and routed to the appropriate ROS topics as they are received. The instructions detected by the controller server typically originate from the mobile controller application, and may include commands to move the robot forward, backward, or to rotate the robot's drums (among other things).

Inputs/Outputs

The controller server listens on a port for HTTP JSON requests that contain instructions. The format of one of these JSON requests is as follows:

{
    "autonomous_toggles" : int [0, 1, 2, 4, 8],
    "target_coordinate" : {
        "x" : float [any],
        "y" : float [any]
    },
    "wheel_instruction" : string [forward, backward, left, right],
    "front_arm_instruction" : float [-1.0 to 1.0],
    "back_arm_instruction" : float [-1.0 to 1.0],
    "front_drum_instruction" : float [-1.0 to 1.0],
    "back_drum_instruction" : float [-1.0 to 1.0]
}

The domain of each field is shown in brackets. All of these fields are optional (partial instructions are valid).

The following is a list of inputs and outputs, with each input/output's type shown in brackets:

INPUTS
node <- HTTP POST requests on port configured at launch [JSON]

OUTPUTS
node -> /autonomous_toggles [std_msgs/Int8]
node -> /target_coordinates [geometry_msgs/Point]
node -> wheel instructions topic configured at launch [geometry_msgs/Twist]
node -> front arm instructions topic configured at launch [std_msgs/Float32]
node -> back arm instructions topic configured at launch [std_msgs/Float32]
node -> front drum instructions topic configured at launch [std_msgs/Float32]
node -> back drum instructions topic configured at launch [std_msgs/Float32]

Launch Files

controller_server.launch

This launch file spins up a single controller server node. This node is configured via arguments at launch which are passed to the node as namespaced ROS parameters. All possible arguments are listed below:

port
The port that the server listens on. Defaults to 8080.
wheel_instructions_topic
The topic that wheel instructions are published to.
front_arm_instructions_topic
The topic that front arm instructions are published to.
back_arm_instructions_topic
The topic that back arm instructions are published to.
front_drum_instructions_topic
The topic that front drum instructions are published to.
back_drum_instructions_topic
The topic that back drum instructions are published to.

Examples

Launch the controller server and publish directly to the topics that the simulation typically reads from:

roslaunch ezrassor_controller_server controller_server.launch \
    wheel_instructions_topic:=wheel_instructions \
    front_arm_instructions_topic:=front_arm_instructions \
    back_arm_instructions_topic:=back_arm_instructions \
    front_drum_instructions_topic:=front_drum_instructions \
    back_drum_instructions_topic:=back_drum_instructions

Launch a controller server on port 9001 that publishes to non-standard topics, send a POST request to the controller server using curl, and observe the result (requires four open terminals):

# Launch the controller server in terminal one.
roslaunch ezrassor_controller_server controller_server.launch \
    port:=9001 \
    wheel_instructions_topic:=wi \
    front_arm_instructions_topic:=fai \
    back_arm_instructions_topic:=bai \
    front_drum_instructions_topic:=fdi \
    back_drum_instructions_topic:=bdi

# Echo the /wi topic in terminal two.
rostopic echo /wi

# Echo the /fdi topic in terminal three.
rostopic echo /fdi

# Send a post request from terminal four.
curl localhost:9001 \
    -d '{"wheel_instruction" : "forward", "front_drum_instruction" : -1}'