Skip to content

Commit 6bb0845

Browse files
authored
Syntax highlighting in README.md (#180)
Added language tags to the code blocks to get syntax highlighting.
1 parent edf87af commit 6bb0845

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
`npm install rosnodejs`
55

66
## Start a node
7-
```
7+
```js
88
const rosnodejs = require('rosnodejs');
99
rosnodejs.initNode('/my_node')
1010
.then(() => {
@@ -13,7 +13,7 @@ rosnodejs.initNode('/my_node')
1313
```
1414

1515
## Publish/Subscribe
16-
```
16+
```js
1717
const nh = rosnodejs.nh;
1818
const sub = nh.subscribe('/chatter', 'std_msgs/String', (msg) => {
1919
console.log('Got msg on chatter: %j', msg);
@@ -24,7 +24,7 @@ pub.publish({ data: "hi" });
2424
```
2525
### Udp transport (Experimental)
2626

27-
```
27+
```js
2828
const nh = rosnodejs.nh;
2929
const sub = nh.subscribe('/chatter', 'std_msgs/String', (msg) => {
3030
console.log('Got msg on chatter: %j', msg);
@@ -37,7 +37,7 @@ const pub = nh.advertise('/chatter', 'std_msgs/String');
3737
pub.publish({ data: "hi" });
3838
```
3939
## Services
40-
```
40+
```js
4141
const service = nh.advertiseService('/add_two_ints', 'beginner_tutorials/AddTwoInts', (req, res) => {
4242
res.sum = req.a + req.b;
4343
return true;
@@ -48,7 +48,7 @@ client.call({a: 1, b: 2});
4848
```
4949

5050
## Params
51-
```
51+
```js
5252
nh.setParam('val', 2);
5353
nh.getParam('val')
5454
.then((val) => {
@@ -59,18 +59,18 @@ nh.getParam('val')
5959

6060
Messages can be generated in a number of ways depending on the versions of ROS and Node.js you're using.
6161
- catkin - works in ROS Kinetic and later for Node.js v6+.
62-
```
62+
```sh
6363
$ catkin_make
6464
OR
6565
$ catkin build
6666
```
6767
- `loadAllPackages()` - One-time "build" call available through `rosnodejs` for versions of ROS before Kinetic and Node.js v6+. Should be called separately and in advance of processes attempting to use messages.
68-
```
68+
```js
6969
const rosnodejs = require('rosnodejs');
7070
rosnodejs.loadAllPackages();
7171
```
7272
- On the fly - all versions of ROS and Node.js 4.5+. When generating on the fly, messages can not be required until the node has initialized.
73-
```
73+
```js
7474
const rosnodejs = require('rosnodejs');
7575
rosnodejs.initNode('my_node', { onTheFly: true }).then(() => {
7676
const stdMsgs = rosnodejs.require('std_msgs');
@@ -84,7 +84,7 @@ rosnodejs.initNode('my_node', { onTheFly: true }).then(() => {
8484
|Node.js < v6|on the fly|on the fly|
8585
8686
## Using Messages
87-
```
87+
```js
8888
const sensorMsgs = rosnodejs.require('sensor_msgs');
8989

9090
const image = new sensorMsgs.msg.Image();
@@ -104,7 +104,7 @@ const service = nh.advertiseService('/add_two_ints', AddTwoInts, (req, res) => {
104104
const client = nh.serviceClient('/add_two_ints', AddTwoInts);
105105
```
106106
## Actions (Experimental)
107-
```
107+
```js
108108
const nh = rosnodejs.nh;
109109
const as = new rosnodejs.ActionServer({
110110
nh,
@@ -130,20 +130,20 @@ ac.sendGoal({edges: 3, radius: 1});
130130
131131
Start:
132132
133-
```
133+
```sh
134134
roscore
135135
rosrun turtlesim turtlesim_node
136136
rosrun turtle_actionlib shape_server
137137
```
138138
139139
Then run
140-
```
140+
```sh
141141
node src/examples/turtle.js
142142
```
143143
144144
or, if you are running an older version of node:
145145
146-
```
146+
```sh
147147
npm run compile
148148
node dist/examples/turtle.js
149149
```

0 commit comments

Comments
 (0)