Skip to content

Commit

Permalink
🔖 hackathon version
Browse files Browse the repository at this point in the history
  • Loading branch information
Rezenders committed Jun 29, 2022
1 parent 2d369d7 commit bfb4cb8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
8 changes: 2 additions & 6 deletions PARTICIPANTS_TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ Read [this](https://github.com/remaro-network/tudelft_hackathon#installation) fi
#### Run bluerov agent

* Run the bluerov agent both in the real BlueROV2 and in Gazebo (Ignition)
* Complete the [random wall avoidance](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py) code and run it both in the real BlueROV2 and Gazebo (Ignition) (solution on [90e272a](https://github.com/remaro-network/tudelft_hackathon/blob/90e272a09d1053d0afcec1402f8cc63476f0c6cc/scripts/random_wall_avoidance.py))
* Complete the [potential_avoidance]((https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/potential_avoidance.py) code and run it both in the real BlueROV2 and Gazebo (Ignition). Issue [#36](https://github.com/remaro-network/tudelft_hackathon/issues/36).

#### Improve the system
Suggestions:
* Issues marked with `hackathon_task` label. You can find them in this [project tab](https://github.com/remaro-network/tudelft_hackathon/projects/2)
* Better avoidance algorithm
* Adjust velocity parameters and sonar "field-of-view"
* Test sonar data with SLAM algorithm ([#4](https://github.com/remaro-network/tudelft_hackathon/issues/4))
* Add visual to bluerov in ignition ([#8](https://github.com/remaro-network/tudelft_hackathon/issues/8))
* Prevent the bluerov to go over the walls ([#12](https://github.com/remaro-network/tudelft_hackathon/issues/12))
* Change Ignition initial world camera position ([#13](https://github.com/remaro-network/tudelft_hackathon/issues/13))
* Add model for bluerov2 heavy kit version ([#14](https://github.com/remaro-network/tudelft_hackathon/issues/14))
* More elaborated world
* Improve launch files
* Improve formatting
Expand Down
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ can begin to understand the challenges and differences of deploying a robot in s

The use case selected for this training is “wall avoidance”. Basically, the goal is for the robot
to navigate an environment and not crash into walls using only sonar data. An initial code for a random
avoidance mission is provided with missing parts, and the idea is for participants to complete the
code and work to develop better missions through training or improve the system in general.
avoidance mission is provided, and the idea is that participants work to develop better missions during this training and improve the system in general.

More details on instructions for participants can be found in the [PARTICIPANTS_TODO](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/PARTICIPANTS_TODO.md)

You can check the intended behavior on the video:
You can check the random wall avoidance behavior on the video:

[![Youtube video](https://user-images.githubusercontent.com/20564040/175087210-6706607d-c2db-4b25-888e-1973e3d093fb.png)](https://www.youtube.com/watch?v=Zv-int_BIJw)

Expand All @@ -29,15 +28,17 @@ You can find some slides with useful information here (**ADD SLIDES LINK**)
You can find a system architecture of the system developed here (**ADD ARCHITECTURE LINK**)

## Summary
- [Computer setup](https://github.com/remaro-network/tudelft_hackathon#computer-setup)
- [Computer setup](https://github.com/remaro-network/tudelft_hackathon#setup)
- [Bluerov setup](https://github.com/remaro-network/tudelft_hackathon#bluerov-setup)
- [Install prerequisites to run with docker](https://github.com/remaro-network/tudelft_hackathon#install-prerequisites)
- [Install locally](https://github.com/remaro-network/tudelft_hackathon#install-locally)
* [Installation](https://github.com/remaro-network/tudelft_hackathon#installation)
- [Install prerequisites to run with docker](https://github.com/remaro-network/tudelft_hackathon#install-prerequisites-to-run-with-docker)
- [Install locally](https://github.com/remaro-network/tudelft_hackathon#install-locally)
- [Run it with docker via CLI](https://github.com/remaro-network/tudelft_hackathon#run-it-with-docker-via-cli)
- [Run with docker with VSCode ](https://github.com/remaro-network/tudelft_hackathon#run-it-with-docker)
- [Run with docker with VSCode ](https://github.com/remaro-network/tudelft_hackathon#run-it-with-docker-with-vscode)
- [Run locally](https://github.com/remaro-network/tudelft_hackathon#run-it-locally)
- [Explanation](https://github.com/remaro-network/tudelft_hackathon#explanation)
- [Additional information](https://github.com/remaro-network/tudelft_hackathon#additional-information)
- [Exercises](https://github.com/remaro-network/tudelft_hackathon#exercises)
- [Additional information](https://github.com/remaro-network/tudelft_hackathon#additional-info)
- [Acknowledgments](https://github.com/remaro-network/tudelft_hackathon#acknowledgments)

## Setup
Expand Down Expand Up @@ -76,7 +77,7 @@ In those cases go for the [local installation](https://github.com/remaro-network
- Install docker on your machine. You can find instructions [here](https://docs.docker.com/engine/install/ubuntu/)
- Allow non-root users to manage docker. Instructions [here](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)
- Install VSCode. Instructions [here](https://code.visualstudio.com/download)
- Install [nvidia-docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)
- Install [nvidia-docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)(only needed if you have a nvidia GPU)

### Configure computer to connect with the BlueROV2
Follow [Bluerobotics instructions](https://bluerobotics.com/learn/bluerov2-software-setup/#software-introduction)
Expand Down Expand Up @@ -123,6 +124,12 @@ If you want to use MAC, follow [this instruction](https://ardupilot.org/dev/docs

#### Install ardusub_plugin

**IMPORTANT:** Clone into the ignition-garden instead of fortress:

```Bash
$ git clone https://github.com/ArduPilot/ardupilot_gazebo -b ignition-garden
```

Install ardupilot_gazebo plugin following the instructions in the [repo](https://github.com/ArduPilot/ardupilot_gazebo/tree/ignition-garden)

#### Install hackathon workspace
Expand Down Expand Up @@ -338,7 +345,7 @@ A `service_timer` timer is created with 2Hz rate. Then we have a while loop that
After that, we create a new timer with 0.5Hz rate. The `ardusub.toogle_rc_override(True)` method is called to make the ardusub node start publishing messages in the `/mavros/rc/override` topic. Then, we use the method `ardusub.set_rc_override_channels(forward=0.5)` to make the robot move forward with half of its thrust, this is achieved internally by the ardusub node by publishing the appropriate message in the `/mavros/rc/override` topic. Following, the program sleeps for 2 seconds and then we make the robot move again to other directions, in order to go "around" a square. And that is it.


The [random_wall_avoidance](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py) has the following behavior. The robot set its flight mode to `MANUAL`, then arms the thrusters, then starts moving forward. The agent subscribes to the sonar topic and every time it receives sonar readings it checks if there is an obstacle in its front, e.g. 180°, closer than a certain threshold, e.g. 1m, and in case there is it rotates randomly until there are no more obstacle. (This node should be completed during the hackathon, a solution can be found in [90e272a](https://github.com/remaro-network/tudelft_hackathon/blob/90e272a09d1053d0afcec1402f8cc63476f0c6cc/scripts/random_wall_avoidance.py)). For this, the agent uses the topics & services listed in the mavros section, and the `/scan` topic described in the ping360 driver section.
The [random_wall_avoidance](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py) has the following behavior. The robot set its flight mode to `ALT HOLD`, then arms the thrusters, then starts moving forward. The agent subscribes to the sonar topic and every time it receives sonar readings it checks if there is an obstacle in its front, e.g. 180°, closer than a certain threshold, e.g. 1.25m, and in case there is it rotates randomly until there are no more obstacle. For this, the agent uses the topics & services listed in the mavros section, and the `/scan` topic described in the ping360 driver section.

### Simulated BlueROV2

Expand Down Expand Up @@ -372,7 +379,9 @@ Note that the topic where the lidar data is published has the same name (`/scan`

## Exercises

Check [PARTICIPANTS_TODO](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/PARTICIPANTS_TODO.md#activities-to-be-done-during-hackathon). The main task is to complete the [random wall avoidance algorithm](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py).
The main exercise of this training is to implement an avoidance algorithm based on potential fields, you can find more info on the issue [#36](https://github.com/remaro-network/tudelft_hackathon/issues/36).

Check [PARTICIPANTS_TODO](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/PARTICIPANTS_TODO.md#activities-to-be-done-during-hackathon) for extra info.

## Additional info

Expand Down
36 changes: 20 additions & 16 deletions scripts/random_wall_avoidance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ def laser_scan_cb(msg, ardusub):
min_distance = 1.25
yaw_speed = 0.3
forward_speed = 0.12

# TODO: Do something with the sonar msg in order to make the robot not
# crash into the walls
#
# CHEAT:
# LaserScan msg definition can be found here: https://docs.ros2.org/latest/api/sensor_msgs/msg/LaserScan.html
# Before checking the solution provided, check this example:
# https://github.com/gazebosim/docs/blob/master/citadel/sensors.md#avoid-the-wall
allGreater = True
for scan in msg.ranges:
pass
if scan < min_distance:
allGreater = False
_yaw_speed = (-1)**random.choice([1, 2])*yaw_speed
ardusub.set_rc_override_channels(
forward=-forward_speed/4,
yaw=_yaw_speed)
break
if allGreater:
ardusub.set_rc_override_channels(throttle=0, pitch=0, forward=forward_speed)


if __name__ == '__main__':
Expand All @@ -36,21 +37,24 @@ def laser_scan_cb(msg, ardusub):
thread = threading.Thread(target=rclpy.spin, args=(ardusub, ), daemon=True)
thread.start()

# TODO: Set flight mode to MANUAL, STABILIZE or DEPTH HOLD
service_timer = ardusub.create_rate(2)
while ardusub.status.mode != "ALT_HOLD":
ardusub.set_mode("ALT_HOLD")
service_timer.sleep()

print("Manual mode selected")
print("ALT HOLD mode selected")

# TODO: Arm motors
while ardusub.status.armed == False:
ardusub.arm_motors(True)
service_timer.sleep()

print("Thrusters armed")

print("Initializing mission")

# TODO: start publishing on /mavros/rc/override

# TODO: start moving forward
ardusub.toogle_rc_override(True)
ardusub.set_rc_override_channels(throttle=0.0, pitch=0.0, forward=0.12)

# Sonar subscriber
laser_subscriber = ardusub.create_subscription(
LaserScan, '/scan', (lambda msg: laser_scan_cb(msg, ardusub)), 10)

Expand Down

0 comments on commit bfb4cb8

Please sign in to comment.