roslib 0.0.2 copy "roslib: ^0.0.2" to clipboard
roslib: ^0.0.2 copied to clipboard

outdated

Interface with a ROS node over websockets with rosbridge, heavily influenced by roslibjs and follows the same structure.

example/main.dart

import 'package:flutter/material.dart';
import 'package:roslib/roslib.dart';

void main() {
  runApp(ExampleApp());
}

class ExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Roslib Example',
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  Ros ros = Ros(url: 'ws://localhost:9090');

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Roslib Example'),
      ),
      body: StreamBuilder<Object>(
          stream: ros.statusStream,
          builder: (context, snapshot) {
            return Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                ActionChip(
                  label: Text(snapshot.data == Status.CONNECTED
                      ? 'DISCONNECT'
                      : 'CONNECT'),
                  onPressed: () {
                    if (snapshot.data == Status.CONNECTED)
                      ros.close();
                    else
                      ros.connect();
                  },
                ),
              ],
            );
          }),
    );
  }
}
9
likes
40
pub points
67%
popularity

Publisher

unverified uploader

Interface with a ROS node over websockets with rosbridge, heavily influenced by roslibjs and follows the same structure.

Repository (GitHub)
View/report issues

License

GPL-3.0 (LICENSE)

Dependencies

flutter, web_socket_channel

More

Packages that depend on roslib