8000 New docs · ev3dev-lang-java/docs@82a11ae · GitHub
[go: up one dir, main page]

Skip to content

Commit 82a11ae

Browse files
committed
New docs
1 parent 7500431 commit 82a11ae

27 files changed

+221
-30
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ To generate in local the documentation, execute the following commands:
66

77
```
88
./gradlew -t asciidoctor
9+
```
10+
11+
```
912
./gradlew livereload &
13+
```
1014
python -m SimpleHTTPServer 8000 &
1115
```
1216

src/main/asciidoc/actuators/index.adoc

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ev3dev.sensors;
2+
3+
import lejos.utility.Delay;
4+
5+
public class BatteryDemo {
6+
7+
public static void main(String[] args) {
8+
9+
final Battery battery = Battery.getInstance();
10+
11+
for(int x = 0; x < 20; x++){
12+
System.out.println("Battery Voltage: " + battery.getVoltage());
13+
14+
Delay.msDelay(1000);
15+
}
16+
}
17+
18+
}
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Battery
2+
3+
# Introduction
4+
5+
Every Brick has a way to detect the voltage of the Battery.
6+
7+
image:ev3-battery.jpg[image]
8+
9+
## How to use the sensor
10+
11+
### Read the voltage
12+
13+
[source,java]
14+
----
15+
include::BatteryDemo.java[]
16+
----

src/main/asciidoc/sensors/ev3-gyro-sensor/ev3_gyro_sensor.adoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# EV3 Gyro sensor
22

3+
## Introduction
4+
35
The digital EV3 Gyro Sensor measures the robot’s rotational motion and changes in its orientation.
46

57
image:ev3_gyro_sensor.png[image]
@@ -11,20 +13,24 @@ Gyroscope Features:
1113
. Dual-mass, vibratory MEMS gyroscope offers superior vibration rejection over a wide frequency range. The dual-mass design inherently rejects any signal caused by linear acceleration.
1214
. 10,000 g shock tolerance The Rate-Out of the gyro is not ratiometric to the supply voltage. The scale factor is calibrated at the chip foundry and is nominally independent of supply voltage.
1315

14-
Example1: Turn your robot using a EV3 Gyro sensor.
16+
## How to use the sensor
1517

16-
image:ev3_gyro_sensor_example1.png[image]
18+
### Read the angle
1719

1820
[source,java]
1921
----
2022
include::./GyroSensorDemo.java[]
2123
----
2224

25+
### Use the rate mode
26+
2327
[source,java]
2428
----
2529
include::./GyroSensorDemo2.java[]
2630
----
2731

32+
### Detect that your robot turn 90 degrees
33+
2834
[source,java]
2935
----
3036
include::./GyroSensorDemo3.java[]

src/main/asciidoc/sensors/ev3-light-sensor/ev3_light_sensor.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
= EV3 Light sensor
1+
# EV3 Light sensor
22

3+
## Introduction
34
The digital EV3 Color Sensor distinguishes between eight different colors.
45
It also serves as a light sensor by detecting light intensities.
56
Students can build color sorting and line-following robots, experiment with light reflection of different colors,
@@ -15,10 +16,9 @@ The range of values for a light sensor measuring the reflected light intensity a
1516
* Minimum: 0, Black
1617
* Maximum: 100, White
1718
18-
*How to use the sensor*
19-
Example 1: Measure the reflected light intensity from the EV3 light sensor.
19+
## How to use the sensor
2020

21-
image:./ev3_light_sensor_example1.png[image]
21+
### Measure the reflected light intensity from the EV3 light sensor.
2222

2323
[source,java]
2424
----
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# EV3 Motor sensor features
2+
3+
## Introduction
4+
5+
A EV3 large motor has an internal encoder to know in what state is the motor.
6+
7+
image:ev3_large_motor.png[image]
8+
9+
## How to use the sensor
10+
11+
### Read the state of the motor
12+
13+
image:ev3_large_motor_example1.png[image]
14+
15+
++++
16+
17+
<script>
18+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
19+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
20+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
21+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
22+
23+
ga('create', 'UA-343143-18', 'auto');
24+
ga('send', 'pageview');
25+
</script>
26+
++++
< F438 div class="DiffFileHeader-module__diff-file-header--TjXyn flex-wrap flex-sm-nowrap">
File renamed without changes.

src/main/asciidoc/sensors/index.adoc

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
A human being receives signals continuously from his 5 senses (sight, hearing, taste, smell and touch)
66
and that stream of data are processed or discarded by the Brain.
77

8-
image:./humanSenses.png[image]
8+
image:images//humanSenses.png[image]
99

1010
With a Robot occurs the same, when you plug a sensor in the brick, your program is able to process
1111
a new kind of data from the environment.
@@ -29,7 +29,7 @@ The following sensors are designed to measure the internal state of the robot.
2929

3030
* link:ev3-gyro-sensor/ev3_gyro_sensor.html[EV3 Gyro sensor]
3131
* link:ev3_large_motor.html[EV3 Lego Large Motor state]
32-
* link:battery.html[Battery Sensor]
32+
* link:battery/index.html[Battery Sensor]
3333
3434
## Source of sensors
3535

@@ -42,11 +42,11 @@ This Lego Mindstorms Kit include the following sensors to play with them:
4242
* link:ev3-ir-sensor/ev3_ir_sensor.html[EV3 Infrared sensor] x1
4343
* link:ev3-touch-sensor/ev3_touch_sensor.html[EV3 Touch sensor] x1
4444
* link:ev3-light-sensor/ev3_light_sensor.html[EV3 Light sensor] x1
45-
* link:ev3_large_motor.html[EV3 Large Motor state] x2
46-
* link:ev3_medium_motor.html[EV3 Medium Motor state] x1
47-
* link:battery.html[Battery Sensor]
45+
* link:ev3-motors/ev3_large_motor.html[EV3 Lego Large Motor state] x2
46+
* link:ev3-motors/ev3_medium_motor.html[EV3 Medium Motor state] x1
47+
* link:battery/index.html[Battery Sensor]
4848
49-
image:./31313.png[image]
49+
image:images/31313.png[image]
5050

5151
### LEGO 45544 Kit
5252

@@ -56,28 +56,28 @@ This Lego Mindstorms Kit include the following sensors to play with them:
5656
* link:ev3-touch-sensor/ev3_touch_sensor.html[EV3 Touch sensor] x2
5757
* link:ev3-light-sensor/ev3_light_sensor.html[EV3 Light sensor] x1
5858
* link:ev3-gyro-sensor/ev3_gyro_sensor.html[EV3 Gyro sensor] x1
59-
* link:ev3_large_motor.html[EV3 Lego Large Motor state] x2
60-
* link:ev3_medium_motor.html[EV3 Medium Motor state] x1
61-
* link:battery.html[Battery Sensor]
59+
* link:ev3-motors/ev3_large_motor.html[EV3 Lego Large Motor state] x2
60+
* link:ev3-motors/ev3_medium_motor.html[EV3 Medium Motor state] x1
61+
* link:battery/index.html[Battery Sensor]
6262
63-
image:./45544.png[image]
63+
image:images//45544.png[image]
6464

65-
### Dexter Industries BrickPi3/BrickPi+
65+
### Dexter Industries BrickPi
6666

6767
The Kit includes the following sensors:
6868

69-
* link:battery.html[Battery Sensor]
69+
* link:battery/index.html[Battery Sensor]
7070
* Grove Adapter (Only for BrickPi3)
7171
72-
image:./brickpi3.jpg[image]
72+
image:images//brickpi3.jpg[image]
7373

7474
### Mindsensors PiStorms
7575

7676
The Kit includes the following sensors:
7777

78-
* link:battery.html[Battery Sensor]
78+
* link:battery/index.html[Battery Sensor]
7979
80-
image:./pistorms-v2.jpg[image]
80+
image:images//pistorms-v2.jpg[image]
8181

8282
### Mindsensors Sensors
8383

@@ -91,14 +91,17 @@ TIP: In the future, the list will grow.
9191
### USB Webcams
9292

9393
USB Cameras is another way to measure the world.
94+
Using OpenCV, it is possible to manage a webcam with Java.
9495

95-
image:./logitech-webcam.png[image]
96+
* link:usb-webcam/index.html[OpenCV & Webcams]
97+
98+
image:images/logitech-webcam.png[image]
9699

97100
### Grove Sensors
98101

99102
Grove System, offer a rich set of sensors to measure the environment.
100103

101-
image:./grove-system.jpg[image]
104+
image:images/grove-system.jpg[image]
102105

103106
The sensors are possible to connect with your brick in the following ways:
104107

@@ -107,17 +110,14 @@ The sensors are possible to connect with your brick in the following ways:
107110
* PiStorms V2: Using the Mindsensors Grove Sensor Adapter for EV3
108111
* BrickPi 3: It is possible to connect a sensor directly.
109112
113+
image:images/ev3-grove-sensor-adapter.jpg[image]
114+
110115
### Slamtec Sensors
111116

112-
* 2D LIDAR RPlidar A1
117+
* link:usb-rplidar/index.html[2D LIDAR RPlidar A1]
113118
* 2D LIDAR RPlidar A2
114119
115-
RPLIDAR is a low cost 360 degree 2D laser scanner (LIDAR) solution
116-
developed by RoboPeak. The system can perform 360 degree scan within
117-
6 meter range. The produced 2D point cloud data can be used in mapping,
118-
localization and object/environment modeling.
119-
120-
image:./slamtec-rplidar-a2.png[image]
120+
image:images/slamtec-rplidar-a2.png[image]
121121

122122
++++
123123
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package examples;
2+
3+
import ev3dev.sensors.slamtec.RPLidarA1;
4+
import ev3dev.sensors.slamtec.RPLidarProviderListener;
5+
import ev3dev.sensors.slamtec.model.Scan;
6+
7+
public class Demo3 {
8+
9+
public static void main(String[] args) throws Exception {
10+
11+
System.out.println("Testing RPLidar");
12+
final String USBPort = "/dev/ttyUSB0";
13+
final RPLidarA1 lidar = new RPLidarA1(USBPort);
14+
lidar.init();
15+
lidar.addListener(new RPLidarProviderListener() {
16+
@Override
17+
public void scanFinished(Scan scan) {
18+
System.out.println("Measures: " + scan.getDistances().size());
19+
scan.getDistances()
20+
.stream()
21+
.filter((measure) -> measure.getQuality() > 10)
22+
.filter((measure) -> (measure.getAngle() >= 345 || measure.getAngle() <= 15))
23+
.filter((measure) -> measure.getDistance() <= 50)
24+
.forEach(System.out::println);
25+
}
26+
});
27+
for(int x = 0; x <= 10; x++) {
28+
lidar.scan();
29+
}
30+
lidar.close();
31+
System.out.println("End");
32+
System.exit(0);
33+
}
34+
35+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 2D LIDAR RPLIDAR
2+
3+
## Introduction
4+
5+
RPLIDAR is a low cost 360 degree 2D laser scanner (LIDAR) solution
6+
developed by RoboPeak. The system can perform 360 degree scan within
7+
6 meter range. The produced 2D point cloud data can be used in mapping,
8+
localization and object/environment modeling.
9+
10+
image:slamtec-rplidar-a2.png[image]
11+
12+
## How to use the sensor
13+
14+
### Detect obstacles in the range 345º to 15º
15+
16+
[source,java]
17+
----
18+
include::Demo3.java[]
19+
----
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package opencv;
2+
3+
import org.opencv.core.Core;
4+
import org.opencv.core.Mat;
5+
import org.opencv.core.MatOfByte;
6+
import org.opencv.highgui.Highgui;
7+
import org.opencv.highgui.VideoCapture;
8+
9+
public class OpenCVTest {
10+
static final int READ_IMAGE_CNT = 1000;
11+
static final int ENCODE_IMAGE_CNT = 1000;
12+
VideoCapture vid;
13+
Mat camImage = new Mat();
14+
15+
void init()
16+
{
17+
vid = new VideoCapture(0);
18+
//vid.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 160);
19+
//vid.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 120);
20+
//vid.open(0);
21+
vid.read(camImage);
22+
System.out.println("Image size is: " + camImage.cols() + "x" + camImage.rows());
23+
}
24+
25+
void captureTest()
26+
{
27+
System.out.println("capture test read " + READ_IMAGE_CNT + " images");
28+
long start = System.currentTimeMillis();
29+
for(int i = 0; i < READ_IMAGE_CNT; i++)
30+
vid.read(camImage);
31+
double time = (double)(System.currentTimeMillis() - start)/1000;
32+
System.out.println("Time is " + time + " = " + (READ_IMAGE_CNT/time) + "fps");
33+
}
34+
35+
void encodeTest()
36+
{
37+
System.out.println("Encoding image as jpeg " + ENCODE_IMAGE_CNT + " images");
38+
MatOfByte buf = new MatOfByte();
39+
long start = System.currentTimeMillis();
40+
for(int i = 0; i < READ_IMAGE_CNT; i++)
41+
Highgui.imencode(".jpg", camImage, buf);
42+
double time = (double)(System.currentTimeMillis() - start)/1000;
43+
System.out.println("Time is " + time + " = " + (READ_IMAGE_CNT/time) + "fps");
44+
}
45+
46+
47+
public static void main(String[] args) {
48+
// Load the native library.
49+
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
50+
OpenCVTest test = new OpenCVTest();
51+
test.init();
52+
test.captureTest();
53+
test.encodeTest();
54+
}
55+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# USB Webcam
2+
3+
## Introduction
4+
5+
image:logitech-webcam.png[image]
6+
7+
## How to use the sensor
8+
9+
[source,java]
10+
----
11+
include::OpenCVTest.java[]
12+
----
Loading

0 commit comments

Comments
 (0)
0