The early stages of understanding how the UltraSonic sensor is used and how it can be used led me to experimenting with the creation of geometry (a sphere) and the modification of geometry (cone heights). This Instructable will look at both of these as an early stage in the understanding of the sensor.
What you need:
- Rhino 5
- Grasshopper 3D Version 0.9.0075
- Firefly Version 220.127.116.11
- Firefly Firmata
- Arduino Uno
- USB A to B
- 3 Jumper wires
- Ultra Sonic Sensor (I used RadioShack® Ultrasonic Range Sensor but any will work)
Step 1: Connecting the Arduino and Getting Grasshopper to Read Values From the Ultra Sonic Sensor
For this step please refer to a previous Instructable that I posted "Reading Ultrasonic Sensor Data to FireFly"
This will walk you through the process of setting up firefly to read data from the Arduino Uno.
Step 2: Sphere Creation
Creating a Sphere from the point that we left off includes adding two nodes to the sketch.
- Insert the XY Plane node
- Insert the Sphere node from the Surface tab
- Connect the XY Plane to the B input on the Sphere
- right click on the XY Plane and click on Preview to shut it off
- Connect the Panel which is reading the sensor data to the "Radius" input on the sphere
- As you change the distance in front of the object the sphere will change its radius
Step 3: Variable Cone Creation
The remainder of this Instructable will go over the creation of a line of cones that heights change based off of the distance that the ultra sonic sensor is supplying.
For this we will start with the original tutorial on Reading Ultrasonic Sensor Data to FireFly and expand to create the final definition.
Step 4: Creating a Series of Points
The first step to expanding on the definition is to create a series of points.
- Create a point using the "Construct Point" command and leave all its inputs as default.
- Create a "Move" node and connect the output of the Point you just created and tie it into the "Geometry" input
- Create a "Unit X" node and tie it into the "Motion" input on the Move node
- Create a "Series" node and tie it into the input on the "Unit X" node
- Attach a "Number Slider" to the "Count" input on the Series node.
By adjusting the number slider you will be adjusting the number of cones that will be created
Step 5: Creating Your Floating Point & Finding Distances
A Floating point is what will determine the heights of the cones.
- Construct another point by bringing another "Construct Point" node into the sketch
- Connect the panel coming from your unit conversion into the "X" input on the newly constructed point
- You now have a point that will move corresponding with the distance that the Ultra Sonic sensor is giving you
- Insert a "Distance" node to the sketch and attach a new panel to its output.
- Use the two points that you have constructed for the inputs to compute the distance
Step 6: Remapping the Cone Heights
Remapping the heights of the cones allows you to create a domain that the numbers will fall into so you aren't creating heights that you don't intend to.
- Insert a "Sort List" node and attach the distance panel into the "K" input
- Create two "List Items" and connect the "K" output from the sort list to the "List" inputs of both
- Set the index of both of the List Items
- one should be set to 9
- the second to 0
- to do this without adding a new component right click on the "Index" (i) input and select set integer then type the number you want the item to list
- Insert the "Construct Domain" node
- Attach the output of the List Item with the index of 0 to the A input
- Attach the output of the List Item with the index of 9 to thee B input
- Create a second "Construct Domain" node
- Attach a "Number Slider" with its value being the minimum you want into the A input
- Attach a "Number Slider" with its value being the maximum you want into the A input
- Attach the distance panel you created before into the "Value" input
- Attach the first domain you created into the "Source" input
- Attach the second domain you created to the "Target" input
- Attach the "Geometry" output from the move node you used before into the "Base" input
- Attach the "Mapped" output from the ReMap to the "Length" input