Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision avoidance pos ctrl #10710

Closed
wants to merge 10 commits into from

Conversation

baumanta
Copy link
Contributor

@baumanta baumanta commented Oct 17, 2018

Use range sensor measurements to avoid collisions in position control mode.
Range sensor data is read in and transformed into velocity constraints which prevent the vehicle from approaching any obstacle closer than a specified distance. Only the velocity component towards the obstacles is limited all other velocity components of the stick input are preserved and executed.

SITL tested, flight tests pending

@baumanta baumanta requested review from mhkabir, bresch and mrivi October 17, 2018 14:34
* @boolean
* @group Multicopter Position Control
*/
PARAM_DEFINE_INT32(MPC_USE_OBS_SENS, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to move the OBS forward so that the relevant parameters are grouped together when viewed in the param tree.

MPC_OBS_SENS_EN - enable use of obstacle avoidance sensors
MPC_OBS_MIN_DIST - obstacle avoidance sensors min distance

@@ -10,6 +10,7 @@ float32 speed_down # in meters/sec
float32 tilt # in radians [0, PI]
float32 min_distance_to_ground # in meters
float32 max_distance_to_ground # in meters
float32[4] velocity_limits # maximum velocities determined by range sensor measurements [x positive, y positive, x negative, y negative] direction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion - consider splitting this into separate arrays for velocity min (x & y) and velocity max (x & y). Then in the code you can directly create a Vector2f.

Copy link
Member

@dagar dagar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace error, check CI output.

//apply the velocity reductions to form velocity limits
_constraints.velocity_limits[0] = v_max_x - _constraints.velocity_limits[0];
_constraints.velocity_limits[1] = v_max_y - _constraints.velocity_limits[1];
_constraints.velocity_limits[2] = v_max_x - _constraints.velocity_limits[2];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace error, check CI output.

@mhkabir
Copy link
Member

mhkabir commented Oct 17, 2018

This is awesome! Do we want this directly in the position controller though? Can't we split this same functionality into a separate low-level avoidance module like I did in my branch?

This also allows slightly more advanced behaviour in the future if we decide to implement it. (e.g reciprocal velocity avoidance).

@mhkabir
Copy link
Member

mhkabir commented Oct 17, 2018

Link to branch : mhkabir@883ed61

@AlexKlimaj
Copy link
Member

I've been wanting to create an automotive radar based distance sensor. This would be a great combo.

Copy link
Contributor

@mrivi mrivi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Why don't we put this new feature in a library so that it can be called from any flight task, for example auto?
I think it would also be useful to directly use the distance_sensor along with obstacle_distance for vehicles that only have one sonar/time of flight sensor.

MulticopterPositionControl::update_range_constraints(const obstacle_distance_s &obstacle_distance,
vehicle_constraints_s &constraints)
{
constraints.velocity_limits_x[0] = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.0 -> 0.0f there are a couple spread in the code

@mhkabir
Copy link
Member

mhkabir commented Oct 18, 2018

I still don't understand why this needs to live within the multicopter position controller, as a library or otherwise.

Can't obstacle avoidance be it's own module, which in the future is extended, for example, with a more complex algorithm, or avoidance for geofences, or even with strategies for fixedwings sharing airspace with manned aviation. Building the avoidance module with a similar module structure as land detector at this stage would future proof it and avoid adding crud to the position controller, most of which was cleaned up thanks to FlightTasks.

Fundamentally, I think avoidance has no place inside the controller.

@dagar @LorenzMeier @bkueng thoughts?

@ndepal
Copy link
Contributor

ndepal commented Oct 18, 2018

Can't obstacle avoidance be it's own module, which in the future is extended, for example, with a more complex algorithm

I thought that was one of the main intentions with FlightTasks, to provide a clean interface for things like obstacle avoidance?

@dagar
Copy link
Member

dagar commented Oct 18, 2018

As a start simply keeping the avoidance logic in a separate library could help work towards being a full module applicable to all vehicle types.

@baumanta
Copy link
Contributor Author

baumanta commented Oct 18, 2018

we flew some tests today, it behaved reasonable. It was a bit wobbly, and also it sometimes approached a bit closer than the specified distance if the throttle was kept towards the obstacle. This might also be due to the sensor measurements. We used the local_planner to generate range data form 3 realsense cameras. I did not have time yet to look at the logs but I put them here for anyone who is interested:

Here a video, where the drone was commanded to go forward at full throttle towards the tree, max velocity was set to 5m/s.

Here some flight logs:
https://logs.px4.io/plot_app?log=f2e4d86f-46cc-462b-b01f-9d4c021cd4ec
https://logs.px4.io/plot_app?log=2c38ece0-2038-4b5f-a8d4-b96cd5db8d60
https://logs.px4.io/plot_app?log=f3cfbff0-ea89-4c36-841d-52071d1e3e90

for(int i = 0; i<72; i++){

//determine if distance bin is valid and contains a valid distance measurement
if(obstacle_distance.distances[i] < obstacle_distance.max_distance &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a check on the obstacle_distance timestamp to make sure you're not using stale data

@mhkabir
Copy link
Member

mhkabir commented Oct 18, 2018

and also it sometimes approached a bit closer than the specified distance if the throttle was kept towards the obstacle.

I observe this with my approach as well. We might need to pursue some kind of "reciprocal velocity" approach to combat this.

@baumanta
Copy link
Contributor Author

and also it sometimes approached a bit closer than the specified distance if the throttle was kept towards the obstacle.

I observe this with my approach as well. We might need to pursue some kind of "reciprocal velocity" approach to combat this.

I'm already doing that. The velocity goes negative if you get ranges, which state that you are too close to an obstacle.

@AuterionWrikeBot
Copy link

➤ Wrike Bot commented:

@tanja Baumann All subtasks have been completed or deferred, you might want to complete this task as well.

@mrivi
Copy link
Contributor

mrivi commented Nov 5, 2018

closing this because got replaced by #10785

@mrivi mrivi closed this Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants