Visible to the public Publish a message if the vehicle has stoppedConflict Detection Enabled

If you're running behind on your Task 3 work, consider adapting this Simulink-based node to work with your design.

Models

This tutorial uses a model contained in the catvehicle_simulink github repository:

git clone https://github.com/sprinkjm/catvehicle_simulink.git

Overview

If you examine the details of Task 3 from the challenge website, you can see the below:

Task 3 (deadline): Teams submit models and software to the CPS-VO that consume sensor and localization data to produce a desired velocity (while traveling along the trajectory), and within 60 seconds of stopping at the end of the trajectory, should generate a Gazebo world file centered at the origin point of the trajectory.

Here we have the broad strokes that define a node that:

  • is paying attention as to whether the vehicle is moving or not
  • when the vehicle stops, publishes a message that the Gazebo-production node can use to trigger the synthesis of the Gazebo world file.

To define this node, we prescribe that we should be listening to the velocity of the car (/catvehicle/vel), and that we should publish a new message on a topic (we assume we can choose that topic and message type, since no one says otherwise) once we've stopped.

How do we know that we've stopped?

A naive solution is we could say "Stopped!" if velocity is 0 (or close to 0). However, this is true even if we've never started moving! Alternatively, consider a state model that allows us to be either in "startup", "moving" or "stopped" states:

uCanDoIt!

Open up the uCanDoIt.slx Simulink model from catvehicle_simulink/tutorials. As you can see from the model's overview, it has a state chart within: this chart does exactly what the image above says.

 

This model (roughly) does the following:

  • subscribe to the velocity of the catvehicle (/catvehicle/vel)
  • Pass the velocity along to the state chart, which outputs either "true" or "false" to the parent model
  • Publish the std_msgs/Bool representation of "stopped" to the /doIt topic

How do we use this model?

Since your Task 3 solution should be generating a Gazebo world file (note: this is an XML file that is representative of Gazebo's world), all that solution needs to know is, "Should I generate now?" By subscribing to /doIt (or whatever you'd like to call that topic), you can have your Task 3 solution subscribe to the polygon messages it sees from /detections, and whenever /doIt is true, to generate the output worldfile.

What's next?

Try integrating the output code from this model (use the code generation feature of Simulink) into a launch file you create for your Task 3 solution, and see whether it works!