Field-Robotics-Lab / glider_hybrid_whoi

(Hybrid-) AUG Simulator
8 stars 9 forks source link

Kinematics only #16

Closed woensug-choi closed 3 years ago

woensug-choi commented 3 years ago

New kinematics only PR

woensug-choi commented 3 years ago

Kinematics plugin for WHOI hybrid gliders

Kinematics control plugin for WHOI hybrid gliders

How-to

Installation

Features

Thruster control

Voltage Power
:heavy_check_mark: :heavy_check_mark:

Rudder control

Heading Angle (Center, Port, Stbd) Angle (Direct)
:heavy_check_mark: :heavy_check_mark: :heavy_check_mark:

Buoyancy engine control

Flight model
:heavy_check_mark:

Glider status

Lat/Lon Roll-Pitch-Yaw Heading Depth Altitude Power Rudder angle Battery position Pumped Volume nav_sat_fix
:heavy_check_mark:* :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:* :heavy_multiplication_x: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:

Code Structure Diagram

image

woensug-choi commented 3 years ago

To-dos for First half of December

woensug-choi commented 3 years ago

@daewok Dockerfile is at docker folder :+1: It takes quite some time to build. Check installation with Docker section how to use build.bash, run.bash, join.bash

woensug-choi commented 3 years ago

@daewok I've referenced as much as I can from your GitLab Dockefile. I've made it through catkin_make compile. But was not able to play the plugin.

  1. Gazebo doesn't launch with complaints of GUI driver fail. I tried to add nvidia/opengl:base-ubuntu18.04 at runtime image but without success. (Maybe run.bash issue?) https://github.com/Field-Robotics-Lab/glider_hybrid_whoi/blob/c1b3aff1b45be5935b931e32933af7dec21f5b8d/docker/Dockerfile#L95-L96
  2. I thought the method with install-script would install dependent packages (e.g. ros-melodic-xacro) but it did not. Had to add apt-get installs later again. (https://github.com/Field-Robotics-Lab/glider_hybrid_whoi/blob/c1b3aff1b45be5935b931e32933af7dec21f5b8d/docker/Dockerfile#L160-L182)
  3. Can you provide more details about sourcing environment scripts other than writing it at .bashrc

Could you give it a look? It's at a new branch Kinematics_only_newdockerfile https://github.com/Field-Robotics-Lab/glider_hybrid_whoi/blob/c1b3aff1b45be5935b931e32933af7dec21f5b8d/docker/Dockerfile#L1-L201

daewok commented 3 years ago

I just pushed some commits to the new branch. With them, I'm able to do ./build.bash and ./run.bash -w glider_kinematics and get the simulator to run. (note that I'm not using my GPU and I haven't tried with a GPU yet).

The reason so many deps were missed is that the rosdep ... install command was actually failing, but it was masked since it was in a pipe and -o pipefail was not set. I changed that so it should now complain if rosdep fails for some reason.

woensug-choi commented 3 years ago

I just pushed some commits to the new branch. With them, I'm able to do ./build.bash and ./run.bash -w glider_kinematics and get the simulator to run. (note that I'm not using my GPU and I haven't tried with a GPU yet).

The reason so many deps were missed is that the rosdep ... install command was actually failing, but it was masked since it was in a pipe and -o pipefail was not set. I changed that so it should now complain if rosdep fails for some reason.

Can't launch anything from my side. I am getting X error for gazebo at ./run.bash -w glider_kinematics. Any suggestions on how to solve this issue?

woensug-choi commented 3 years ago

@mabelzhang Isn't this a magic line to set model paths? I am trying to reference the models newly included in this PR.

  <export>
    <gazebo_ros gazebo_model_path="${prefix}/models"/>
    <gazebo_ros gazebo_media_path="${prefix}"/>
  </export>

I am trying to upload a Buzzard Bay heightmap. But I can't locate it using model://. It shouldn't be difficult. What else do I have to do to add a path for models in this PR?

mabelzhang commented 3 years ago

That looks correct. Adding the path usually takes me a few rounds of back and forth testing... Are you installing the packages when you compile? Try rospack find to see where ROS thinks the package is, whether in src or in devel or install. It could be that the models are only in src but rospack find is locating a compiled directory. In that case, you would want to install the models directory in CMakeLists.txt. You could run Gazebo with --verbose to see if it prints anything about the path.

woensug-choi commented 3 years ago

Added buzzards bay partially (Quicks Hole area) Near with automatic bathymetry respawning plugin.


Problmes to be solved

woensug-choi commented 3 years ago

Added FULL Buzzards bay bathymetry

Issue on GPS accuracy

The vehicle's position and GPS value do not match exactly.

This is also the case of Dave repo's rexrov tutorial case https://github.com/Field-Robotics-Lab/dave/issues/77#issuecomment-748878031. It seems it's a problem with the GPS sensor since the bathymetry is spawning correctly.

woensug-choi commented 3 years ago

I think the PR is ready to review for merge. @daewok could you review this from the kinematics functionality point of view?

Future Todo

Future issues

daewok commented 3 years ago

I'm just getting back online after moving and xmas. I also have my desktop with GPU finally set up. So I think I'm going to tackle the Docker stuff first, since having it Dockerized will make my workflow easier.

woensug-choi commented 3 years ago

Happy new year! Were you able to get the dockerfile working? Did you review this PR? I only see the Merge button.

daewok commented 3 years ago

Just pushed my work. I tried to update the docker/README.MD file well enough to document how it works now.

I also added a docker-compose.yml file that launches both the Gazebo simulator and the simulated glider control system. You should just need to run docker-compose build and docker-compose up to have the simulator start up. In the absence of any other input, the glider control system just tries to make the glider safe by surfacing.

The docker-compose file currently assumes that if you want to use a GPU the nvidia runtime is set as your default Docker runtime. If that's not the case, you'll need to create a local docker-compose.override.yml file setting the runtime to use.

To get a glider console, you can run:

docker-compose exec glider_control_sim /ros_entrypoint.sh rosrun slocum_glider_sim_driver slocum_glider_sim_console

You can then run any of the subset of Glider commands that the simulated control system supports. You can run the simple one dive mission with run ini0.mi. You can run a simple box mission with run inibox01.mi. After the missions complete, you'll need to hit Ctrl-C to tell it to finish. If you want to quit the console hit Ctrl-D.

I did notice two oddities:

  1. Sometimes Gazebo just hangs on me. Time stops progressing in the GUI and no more messages are sent from the plugins. I noticed this occasionally outside of Docker as well. Have you seen this?
  2. The messages sent by the plugins have a time stamp of over 1600000000 seconds. That makes me wonder if the /use_sim_time parameter is being set early enough. I don't remember if this happened to me earlier or not.

Take a look at the commit message for 92fac83. It'd be nice if we could get those PRs mentioned in it merged before this is merged.

woensug-choi commented 3 years ago

Lots of commits! I am starting to understand why we need this. I've dealt with all PRs on this and dave repository.

The last commit includes,

For two oddities,

daewok commented 3 years ago

Weird. It worked on my desktop with an nvidia GPU and I just tested it on the computer in Caryn House mostly successfully (docker-compose build doesn't work on that computer... I'm guesing it's because the version of docker-compose on there is ancient and has a bug. I had to build with build.bash and then use docker-compose up).

Is the nvidia runtime set as the default on the computer you were using?

woensug-choi commented 3 years ago

@daewok How do I check if the Nvidia runtime is set as the default?

Brian has suggested that we merge this PR if the kinematics functionality is working before we diverge too much in one PR. I think it is very reasonable to do so. This PR already includes Kinematics, Bathymetry, and Docker. What do you think?

daewok commented 3 years ago

Run docker info and it should be in the output. If it's not the default, you can typically add "default-runtime": "nvidia" to /etc/docker/daemon.json (or however your OS configures Docker). You should also be able to use a docker-compose override file to tell docker-compose to use nvidia instead of the default, but I'm not sure what the contents of that should be. (And I don't think there's any issue with making nvidia the default over runc).

I wholeheartedly agree about merging this soon. It's already a beast.

woensug-choi commented 3 years ago

I messed up my system. Now back online. The workstation at WHOI has nvidia runtime as default. I'll double check on my local machine.

woensug-choi commented 3 years ago

Docker

Docker-compose

During the tests, I have not seen any Gazebo hang-ups. Currently, building on another machine without Nvidia runtime. Will see what happens. (Update: with runc docker runtime, it works perfectly 👍 ).

I think this PR is ready to merge now.

daewok commented 3 years ago

Is there join.bash functionality for docker-compose? I wanted to check whether use_sim_time works correctly.

Something like this is probably what you want:

docker-compose exec gazebo bash
woensug-choi commented 3 years ago

I was able to call up a new window using docker-compose exec glider_control_sim /ros_entrypoint.sh bash The use_sim_time was correctly working in the docker-compose environment too.