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

Add support for nested models #6

Closed
srmainwaring opened this issue Dec 13, 2021 · 0 comments · Fixed by #32
Closed

Add support for nested models #6

srmainwaring opened this issue Dec 13, 2021 · 0 comments · Fixed by #32
Assignees
Labels
enhancement New feature or request

Comments

@srmainwaring
Copy link
Collaborator

The original Gazebo version of the plugin allowed models to be nested, however this is not currently supported in the Ignition version.

Motivation

It is useful to be able to create variants of a basic model that are equipped with different sensors or other peripherals. The base robot, each peripheral, and other components can each be defined as separate models which may then be composed into new robot variants.

For example: a base rover defines the chassis, wheel train and minimal sensor array (viz. IMU sensor). A peripheral model defines a laser scanner. A variant of the rover is then defined by composing the base rover and the laser scanner.

Issues

For composition to work, a plugin must be able to locate links, joints and sensors in composite models, and also define and resolve topics which have been scoped with the nested model names. The following list of issues have been identified:

  1. A nested IMU sensor cannot be resolved: The code in ArduPilotPlugin::PreUpdate that uses the entity component manager (ECM) to search for a named IMU component is not resolving IMU sensors in nested models.

  2. Nested joints cannot be resolved: The function ignition::gazebo::Model::JointByName only searches for joints that have the top level model as a parent. There is no recursion down into nested models.

  3. Topics: the rules for defining topics have changed between classic Gazebo and Ignition. In particular the prefix ~/ which used to be resolved to a namespace prefix comprising the world and top level model name is no longer permitted. The ArduPilot plugin needs to subscribe to a number of topics published by sensors and these need to reference topics published by sensors in the top level model as well as those in nested models. Furthermore the plugin should only need to specify topics up to a world and model namespace which is automatically resolved, otherwise every additional instance of a model spawned will need to be edited to ensure the correct sensor topics are subscribed to - this is not practical if say you are attempting to create a swarm of robots.

This was referenced Dec 14, 2021
@srmainwaring srmainwaring self-assigned this Dec 14, 2021
@srmainwaring srmainwaring added the bug Something isn't working label Dec 14, 2021
srmainwaring added a commit that referenced this issue Apr 14, 2022
* [Lock-Step] add define to display debug information for JSON

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] split the creation and sending of the JSON state and cache the state between updates

- Add function CreateStateJSON that creates and caches the state JSON string
- Modify the function SendState to send the cached JSON state
- This is to allow the JSON state to be resent to the controller if required

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] move the update of motor commands to a separate function

- Move the servo packet declaration to the header
- Move the conversion of PWM values to motor commands to a separate function

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] check the simulation is not paused in the pre and post update steps

- Check that the simulation is not paused before receiving or sending state

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] removed unused debug checks

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] add logic to enforce lock-step and a plugin parameter to toggle

- Add parameter <lock_step> which is set to true to enforce lock-step simulation
- Update the Iris and Zephyr models to use lock-step
- Modify PreUpdate when in lock-step mode
	- Keep calling ReceiveServoPacket until a packet is received
- Modify ReceiveServoPacket when in lock-step mode
	- Resend the state if no data received from the controller instead of timing out
	- Resend the state if a duplicate servo packet is received
- Fix a bug in the missed frames warning message

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] add signal handler and break out of the receive servo packet loop when a signal is received

- Add a signal handler to allow the plugin to exit cleanly on Ctrl-C.

Signed-off-by: Rhys Mainwaring <[email protected]>
@srmainwaring srmainwaring added enhancement New feature or request and removed bug Something isn't working labels Dec 15, 2022
Tarek-H pushed a commit to Tarek-H/ardupilot_gazebo that referenced this issue Apr 5, 2023
* [Lock-Step] add define to display debug information for JSON

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] split the creation and sending of the JSON state and cache the state between updates

- Add function CreateStateJSON that creates and caches the state JSON string
- Modify the function SendState to send the cached JSON state
- This is to allow the JSON state to be resent to the controller if required

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] move the update of motor commands to a separate function

- Move the servo packet declaration to the header
- Move the conversion of PWM values to motor commands to a separate function

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] check the simulation is not paused in the pre and post update steps

- Check that the simulation is not paused before receiving or sending state

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] removed unused debug checks

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] add logic to enforce lock-step and a plugin parameter to toggle

- Add parameter <lock_step> which is set to true to enforce lock-step simulation
- Update the Iris and Zephyr models to use lock-step
- Modify PreUpdate when in lock-step mode
	- Keep calling ReceiveServoPacket until a packet is received
- Modify ReceiveServoPacket when in lock-step mode
	- Resend the state if no data received from the controller instead of timing out
	- Resend the state if a duplicate servo packet is received
- Fix a bug in the missed frames warning message

Signed-off-by: Rhys Mainwaring <[email protected]>

* [Lock-Step] add signal handler and break out of the receive servo packet loop when a signal is received

- Add a signal handler to allow the plugin to exit cleanly on Ctrl-C.

Signed-off-by: Rhys Mainwaring <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant