Coder Social home page Coder Social logo

blueos-ros2's Introduction

BlueOS ROS extension

This extension makes possible to communicate with the vehicle via ROS

To connect, you just need to run the following commands:

export ROS_MASTER_URI=http://blueos.local:11311
# or export ROS_MASTER_URI=http://<vehicle-ip>:11311
rostopic list # Done, you already have access to it!

You can also access the data via roslibjs.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/roslibjs/1.1.0/roslib.min.js"></script>

<script type="text/javascript" type="text/javascript">
  var ros = new ROSLIB.Ros({
    url : 'ws://blueos.local:8889' // Change if necessary for your vehicle ip
  });

  ros.on('connection', function() {
    document.getElementById("status").innerHTML = "Connected";
  });

  ros.on('error', function(error) {
    document.getElementById("status").innerHTML = "Error";
  });

  ros.on('close', function() {
    document.getElementById("status").innerHTML = "Closed";
  });

  var txt_listener = new ROSLIB.Topic({
    ros : ros,
    name : '/mavros/vfr_hud',
    messageType : 'mavros_msgs/VFR_HUD'
  });

  txt_listener.subscribe(function(m) {
    document.getElementById("msg").innerHTML = JSON.stringify(m);
  });
</script>
</head>

<body>
  <h1>Simple ROS User Interface</h1>
  <p>Connection status: <span id="status"></span></p>
  <p>Last /mavros/vfr_hud received: <span id="msg"></span></p>
</body>
</html>

Use a different ROS master origin

It's possible to change ROS master for the extension using BlueOS on pirate mode and configuring ROS environments variables under the extension configuration menu.

A valid configurtion wouyld look like this:

{
  "NetworkMode": "host",
  "HostConfig": {
  "Binds": [
    "/dev:/dev:rw"
  ],
    "Privileged": true,
    "NetworkMode": "host"
  },
  "Env": [
    "ROS_HOSTNAME=192.168.2.2",
    "ROS_MASTER_URI=http://192.168.2.3:11311",
    "ROS_IP=192.168.2.2"
  ]
}

For more information about it, check BlueOS documentation.

blueos-ros2's People

Contributors

patrickelectric avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.