augcog / ISAACS_Server

Apache License 2.0
5 stars 0 forks source link

isaacs_server

ROS package that acts as a server for the Immersive Semi-Autonomous Aerial Command System (ISAACS) platform.

Setup

  1. Please install ROS by following this link
  2. Install rosbridgelib by following this link. You don't need to run it yet.
  3. Create a catkin workspace. (read more about catkin workspaces here)
    • mkdir catkin_ws
    • mkdir catkin_ws/src
    • cd catkin_ws/src
    • catkin_init_workspace (this should create a "build" and "devel" directory in catkin_ws)
  4. from within catkin_ws/src, run git clone -b operator https://github.com/immersive-command-system/isaacs_server.git (Or you can use the ssh uri). The "-b operator" argument ensures you clone the operator branch, which contains our most up-to-date (and probably buggy) code.
  5. cd ..
  6. catkin_make
  7. source devel/setup.bash (this needs to be run every time)
    • Alternatively for this to be done automatically, you can add the following line into ~/.bashrc: source ~/catkin_ws/devel/setup.bash
    • source ~/.bashrc

You are now all set and can run the server node.

  1. To start the server, run roslaunch rosbridge_server rosbridge_websocket.launch. To edit the parameters, run roslaunch rosbridge_server rosbridge_websocket.launch {arg}:={value} (for example, roslaunch rosbridge_server rosbridge_websocket.launch unregister_timeout:= 600). To test locally, you should
  2. To run the operator node, run python3 operator.py from isaacs_server/src in a new terminal window.
  3. You can now make service calls. These will eventually be made from the VR interface, but you can also test our services by running python3 service_test/[test_name].py from isaacs_server/src in a new terminal window.

Note that for roslibpy to work, the host IP should be the ROS master that is running rosbridge (multi-network) or roscore (local network). All ros connections are currently made to a static IP address (that probably isn't yours), so you will have to change all IP addresses to 'localhost' to run it locally, or to your static IP if you set up port forwarding. If you're confused about port forwarding, ask Kyle for more info.

Host IP can be set in either constants.py or with the --ip [ip] argument via command line.

Getting Started

Make sure you git pull to ensure you have the latest code before you make any changes.

Message Definitions

Don't forget to run catkin_make and source devel/setup.bash from catkin_ws/ to compile the package with the new service types. This must be done before you can use these new service types.

Testing

Setup

  1. roslaunch rosbridge_server rosbridge_websocket.launch unregister_timeout:= 600
  2. python3 operator.py
  3. python3 dji_sim.py this fakes the physical DJI drone / the DJI SDK.
  4. Start up Mavros endpoints.

Test Suites

Run make working to test currently available features. Note that this set tends to lag behind the actual codebase.

Using Roslipby

You'll need to pip install roslibpy before you can use it. Make sure you're using python3, as python2 will run into errors. You might have to pip3 install roslibpy if python2 is your default python version, and python3 file_name.py to run it with python3.

import roslibpy at the top of the python file.

Create a connection to ROS master:
client = roslibpy.Ros(host='ip', port=9090) #where ip is either 'localhost' or the static IP of the ROS master you are trying to connect to.
client.run().

Creating a service:
service = roslibpy.Service(client, '/add_drone', 'isaacs_server/add_drone') #where /add_drone is the name of the service, and isaacs_server/add_drone is the service type defined by add_drone.srv in the isaacs_server package.
service.advertise(handler) #where handler is a function that is run upon the service being called.

Calling a service:
service = roslibpy.Service(client, '/add_drone', 'isaacs_server/add_drone') #where /add_drone is the name of the service, and isaacs_server/add_drone is the service type defined by add_drone.srv in the isaacs_server package.
request = roslibpy.ServiceRequest({'ip': "some ip", "port": 9090, "drone_type":"DjiMatrice"}) #a dictionary of field names (defined in the service type) to inputs.
result = service.call(request) #calls the service, with inputs defined by request, and sets result to the callback.

Setup Port Forwarding

  1. Find your router ip address.
  2. Type in ip address as url of browser
  3. Enter router credentials (most likely user: admin and pass: admin if it has not been setup previously)
  4. Search for Virtual Server or Port Forwarding tab. Will probably be located under advanced settings.
  5. Add a port forwarding service with the local port you plan to use.