# New to Agents.jl, trouble retrieving agent velocity

**URL:** https://discourse.julialang.org/t/new-to-agents-jl-trouble-retrieving-agent-velocity/125469
**Category:** New to Julia
**Tags:** question, agents
**Created:** [February 2, 2025, 2:46am UTC](https://discourse.julialang.org/t/new-to-agents-jl-trouble-retrieving-agent-velocity/125469 "2025-02-02T02:46:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![NaixNix](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@NaixNix](https://discourse.julialang.org/u/NaixNix)
#### Post date: [February 2, 2025, 2:46am UTC](https://discourse.julialang.org/t/new-to-agents-jl-trouble-retrieving-agent-velocity/125469/1 "2025-02-02T02:46:31Z")

</div>

Is there a way to retrieve each agent’s velocity in the Agents.jl flocking model per time step of the abmvideo command? For reference, the abmvideo command goes

```julia
abmvideo(
    "flocking.mp4", model;
    agent_marker = bird_marker,
    framerate = 20, frames = 300,
    title = "Flocking"
)

```

---

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [February 3, 2025, 2:50pm UTC](https://discourse.julialang.org/t/new-to-agents-jl-trouble-retrieving-agent-velocity/125469/2 "2025-02-03T14:50:11Z")

</div>

Hi There,

yes, you can retrieve any agent data you wish for, including the velocity, if you use the `run!` function. see the main tutorial of Agents.jl for how to use the `run!` function.

I am not sure I understand what you mean to “retrieve the data during the video”? The function that creates the video does just that: makes a video. It does not return any data. Even if you did record data during the model evolution you wouldn’t access it via the video function. You would need to call `run!`. If you want to make a video as well, then call `abmvideo` independentl.

---

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [February 3, 2025, 2:51pm UTC](https://discourse.julialang.org/t/new-to-agents-jl-trouble-retrieving-agent-velocity/125469/3 "2025-02-03T14:51:34Z")

</div>

Or, you could use the `abmexploration` (also in the main tutorial) to make a video where in the left side of the figure you see the birds moving, and in the right side you see a timeseries of the agent velocity you have collected. (Explained in the visualizations tutorial how to achieve this)

---

<div class="post-metadata">

### Author: ![NaixNix](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@NaixNix](https://discourse.julialang.org/u/NaixNix)
#### Post date: [February 8, 2025, 3:26pm UTC](https://discourse.julialang.org/t/new-to-agents-jl-trouble-retrieving-agent-velocity/125469/4 "2025-02-08T15:26:39Z")

</div>

Thanks for the help! I figured out how to use `abmexploration` but I couldn’t retrieve the velocities of all birds in the model. I plan on plotting ϕ, which is defined on the `bird_marker` function on the flocking model using all the velocities.

---

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [February 8, 2025, 6:24pm UTC](https://discourse.julialang.org/t/new-to-agents-jl-trouble-retrieving-agent-velocity/125469/5 "2025-02-08T18:24:11Z")

</div>

I am assuming you want to plot the average angle from all birds ?

Then it is just

```julia
using Statistics: mean
angle(b) = atan(b.vel[2], b.vel[1]) 
adata = [(angle, mean),]
fig, abmobs = abmexploration(model;
    adata, alabels = ["mean angle",],
    # any other kw...
)

```

I don’t understand what you mean by “I can’t retrieve the velocities of all birds in the model”.
