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

Package smarts_ros ROS node #1243

Merged
merged 13 commits into from
Jan 19, 2022
Merged

Package smarts_ros ROS node #1243

merged 13 commits into from
Jan 19, 2022

Conversation

sah-huawei
Copy link
Contributor

Here we include the smarts_ros ROS node with the SMARTS package for distribution (e.g., via PyPi).

It was moved into the smarts.ros module (which was chosen in favor of just ros to try to avoid conflicts with other packages) and the manifest was updated to allow including the non-python files in the node.

A script was added to be run via python -m smarts.ros setup_node in order to facilitate installing the ROS node (e.g., catkin_make) after the SMARTS package has been installed by a client.

Along the way, a couple minor bugs were fixed to allow for passing in a custom map builder (via a MapSpec) into a Scenario when it is created via the ROSDriver class.

@sah-huawei sah-huawei changed the title Package ros node Package smarts_ros ROS node Jan 14, 2022
@liu-allan
Copy link
Contributor

I encountered this while running roslaunch smarts_ros ros_driver.launch:

Traceback (most recent call last):
File "/home/smarts/SMARTS/smarts/ros/install/lib/smarts_ros/ros_driver.py", line 65, in
from smarts.ros.logging import log_everything_to_ROS
ModuleNotFoundError: No module named 'smarts.ros'

Comment on lines +33 to +34
if _ros_pkg_path and "smarts" in _ros_pkg_path:
from .src.smarts_ros.scripts.ros_driver import ROSDriver
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this condition intended to be here to avoid import errors in the base package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, as the comment right above it says, it only works when a user is in a ROS environment. So I added the if to prevent it from failing if someone tries to, say, run the script in __main__ or just do import smarts.ros somewhere.

@@ -27,7 +27,7 @@ Setup your environment:
source /opt/ros/kinetic/setup.bash
```
```bash
cd examples/ros
cd smarts/ros
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this look considering this will now be in the smarts package rather than in a directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, these instructions are only really for people who git clone the repo and want to build the ROS node themselves. (They aren't even included in the package itself.)

However, Allan had a good suggestion about this in his comment which I'm about to update.

@sah-huawei
Copy link
Contributor Author

I encountered this while running roslaunch smarts_ros ros_driver.launch:

Traceback (most recent call last): File "/home/smarts/SMARTS/smarts/ros/install/lib/smarts_ros/ros_driver.py", line 65, in from smarts.ros.logging import log_everything_to_ROS ModuleNotFoundError: No module named 'smarts.ros'

That seems to maybe be a problem with the virtual env? I assume you activated it. (it doesn't happen for me when I do.)

Right before the import that fails, can please you add print(sys.path) and let me know what you get? Thanks.

@liu-allan
Copy link
Contributor

I encountered this while running roslaunch smarts_ros ros_driver.launch:
Traceback (most recent call last): File "/home/smarts/SMARTS/smarts/ros/install/lib/smarts_ros/ros_driver.py", line 65, in from smarts.ros.logging import log_everything_to_ROS ModuleNotFoundError: No module named 'smarts.ros'

That seems to maybe be a problem with the virtual env? I assume you activated it. (it doesn't happen for me when I do.)

Right before the import that fails, can please you add print(sys.path) and let me know what you get? Thanks.

['/home/smarts/SMARTS/smarts/ros/install/lib/smarts_ros', '/home/smarts/SMARTS/smarts/ros/install/lib/python2.7/dist-packages', '/opt/x86/ros/kinetic/lib/python2.7/dist-packages', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/home/smarts/SMARTS/.venv/lib/python3.7/site-packages', '/home/smarts/SMARTS/examples/driving_in_traffic', '/home/smarts/SMARTS/examples/stable_baselines3']

@sah-huawei
Copy link
Contributor Author

'/home/smarts/SMARTS/.venv/lib/python3.7/site-packages'

So this part of the path instructs it to find smarts in the pip-installed package. It isn't using the repo. So if you cloned and/or pulled the repo to test the changes, you won't actually be testing them. You'll need to either pip install an updated smarts package (which you can't yet get from PyPi until we release it, so you would have to make the wheel yourself) or better, update your path to use the repo version instead of the package version.

@sah-huawei sah-huawei merged commit 391bb4a into develop Jan 19, 2022
@sah-huawei sah-huawei deleted the package_ros_node branch January 19, 2022 18:25
Gamenot added a commit that referenced this pull request Jan 26, 2022
* only load sumo road network once during scenario building

* map fixes, tests for generating od map, cleanup

* Add docstring test.

* Remove .sh files.

* Remove output folder.

* changes based on reviews

* changes based on reviews

* break into multiple lines

* reformatting

* cleanup

* use simple social agents for environment test

* bug fixes

* use simpler social agent

* use simpler social agent

* use simpler social agent

* Change message.

* bug fixes

* bug fixes

* bug fixes

* bug fix

* Map Creation Fixes (#1201)

* fix is_same_map for SumoRoadNetwork to handle net_file naming looseness

* oops

* updates from review

* minor: style

* GitHub Actions: Update requirements.txt

* fix od_newmarket map, cache width computations and extend map creation refactor to opendrive maps

* updated CHANGELOG.md

* reformatting

* changes based on reviews

* changes based on reviews

* Update CHANGELOG.md

* opendrive gym environment based on hiway environment

* Type annotation (#1208)

* GitHub Actions: Update requirements.txt

* add examples using opendrive gym environment

* reformatting

* type hint fixes (#1216)

* type hint fixes as detected by a pytype experiment

* change Set to Iterable to avoid being overly restrictive

* Delete opendrive_agent.py

* changes based on reviews

* revert minor change

* Add rendering check

* GitHub Actions: Update requirements.txt

* bug fix

* detect the version of scenario we are using instead and decide if to add the traffic to HiWayEnv.

* bug fix

* remove opendrive env

* refactoring

* refactoring

* refactoring

* reformatting and updated CHANGELOG.md

* updated CHANGELOG.md

* changes based on reviews

* reformatting

* GitHub Actions: Update requirements.txt

* Use bisect module to look up in a sorted array

* changes based on reviews

* changes based on reviews

* reformatting

* changes based on reviews

* pytype fixes

* only enable sumo traffic and social agents if all scenarios are SUMO

* remove spacing attribute in lanepoints.py

* Don't assume a file name more specific than searched for in cli/studio.py

* Don't assume a file name more specific than searched for in default_map_builder.py

* remove the odd interface of glb generation

* reformatting

* reformatting

* bug fix

* bug fix

* removed deprecated class and methods from agent.py (#1222)

* removed deprecated class and methods from agent.py

* changelog

* GitHub Actions: Update requirements.txt

* move human_in_the_loop.py into zoo

* Observation space modifier in FrameStack wrapper (#1121)

* Graceful handle of traci connection errors

* Make format

* Fix check for empty route

* Fix bugs with provider changes

* Add required property to provider

* Add provider error handling

* Add `__sim__` done

* Format

* Update changelog

* Fix missing changes

* Add unsaved file

* Push another unsaved file.

* Document new methods

* Move recovery flag configuration to SMARTS

* Apply suggestions

* Fix provider not inheriting from Provider

* Revert unimportant changes

* Note make test test_notebook timeout in CHANGELOG

* Make sure notebook tests do not time out

* Update changelog

* Remove unnecessary EmptyProvider

* Improve provider error handling

* Ensure that error handling is working

* Fix issue that causes crash with TrapManager

* Fix `SumoTrafficSimulation.recover` definition

* Add missing import

* Handle `SMARTS.reset(..)` errors

* Set default recover to re-raise exception

* Address comments.

* Misc. backfill (#1205)

* remove uses of open_agent_actor in some scenarios; limit num_cpus used in some tests

* gain updates to trajectory tracking controller

* Fix early end due to being off_road

* Ignore sumo map errors

* revert case-related changes in sstudio/type

* updates from review

* made it clearer that the error gains are not coming from the model config file

* cleanup based on review

* Driving in traffic example (#1141)

* GitHub Actions: Update requirements.txt

* Fix SMARTS.__del__() throwing at program exit

* Make  required for SMARTS

* Add doc to explain use of SMARTS

* Update changelog

* Update error demonstration

* Fix `Point.__del__`  error.

* Make SMARTS.__del__ idempotent

* GitHub Actions: Update requirements.txt

* Remove route_waypoints from RoadWaypoints (#1229)

* Smooth headings (#1219)

* type hint fixes (from pytype)

* add max_angular_velocity option

* added options to smooth headings with sliding window and ignore heading changes when below minumum speed

* comments + CHANGELOG

* updates from review

* updates from review

* minor typo fix

* changes based on reviews

* changes based on reviews

* changes based on reviews

* reformatting

* minor changes

* minor change

* GitHub Actions: Update requirements.txt

* move human-in-the-loop-v0 into zoo

* reformat human_in_the_loop.py

* expose vehicle Starts for use by imitation learning (#1227)

* refactor to expose get_vehicle_start_at_time()

* added docstring and CHANGELOG entry + fixed minor bug

* updates from review

* CHANGELOG

Co-authored-by: Rutvik Gupta <[email protected]>

* GitHub Actions: Update requirements.txt

* GitHub Actions: Update mac_requirements.txt

* remove unused imports and reformat

* GitHub Actions: Update requirements.txt

* Fix secondary traci connection error

* Update changelog

* Fix typo

* add black and isort to precommit hook

* add pylint to hooks

* format instead of only checking

* move pre-commit and pylint dependencies into [dev] option

* add instructions for setup

* update CONTRIBUTING.md

* update CONTRIBUTING.d

* update black in pre-commit

* use local black and isort in pre-commit

* remove comments

* update contributing, only format python files

* update contributing

* remove conflicts

* remove conflicts

* map building fixes (#1234)

* default map builder_fn will use map.net.xml first if it exists

* allow for hashing a non-file based map

* CHANGELOG

* typo

* typo and whitespace

* clean up sstudio for map building
- don't assume map filenames
- correctly handle shift_to_origin

* updates from review

* added/fixed type hints based on pytype

* First batch of docstrings

* Second batch of docstrings

* Third batch of docstrings

* Fourth batch of docstrings

* Fifth batch of docstrings

* remove python3.7-dev

* Sixth batch of docstrings

* add extra intro for zsh user

* Fix error

* Update README.md

* remove python3.7-dev from all setup-related files

* Seventh batch of docstrings

* GitHub Actions: Update mac_requirements.txt

* Eigth batch of docstrings

* Tenth batch of docstrings

* Eleventh batch of docstrings

* 12th batch of docstrings

* 13th batch of docstrings

* Package smarts_ros ROS node (#1243)

* move smarts_ros ROS node into smarts/ros so it can be distributed with pkg

* moved ros logging stuff to smarts.ros.logging
formatting

* set env for catkin_make

* fix typo

* copyright headers

* changelog

* bugfix: remove incorrect assert w.r.t. map_spec

* comment

* add error message to __main__.py in smarts.ros

* allow for install_path to be set for the smarts.ros node

* formatting

* updated README to ref the setup_node script

* comment change per review

* GitHub Actions: Update requirements.txt

* 14th batch of docstrings

* 15th batch of docstrings

* Fix imports

* 16th batch of docstrings

* Fix interface issues

* GitHub Actions: Update requirements.txt

* use process instead of thread to speed up the build-all option

* reformat and correct typo

* add the change to CHANGELOG

* GitHub Actions: Update requirements.txt

* GitHub Actions: Format - Black and isort.

* GitHub Actions: Update requirements.txt

* GitHub Actions: Update requirements.txt

* Auto format (#1)

* GitHub Actions: Update requirements.txt

* GitHub Actions: Format - Black and isort.

* exclude manager_pb2_grpc.py,worker_pb2_grpc.py

* Fix steering observation description

* Auto format and commit (#1252)

* GitHub Actions: Update requirements.txt

* GitHub Actions: Format

* Update studio.py

* Update studio.py

* Apply suggestions from code review

Co-authored-by: adai <[email protected]>
Co-authored-by: Saul Field <[email protected]>

* Remove duplicate packages.

* GitHub Actions: Update requirements.txt

* GitHub Actions: Format

* GitHub Actions: Update mac_requirements.txt

* GitHub Actions: Update mac_requirements.txt

* Apply suggestions from code review

Co-authored-by: adai <[email protected]>
Co-authored-by: Saul Field <[email protected]>

* Apply suggestions from code review

Co-authored-by: Saul Field <[email protected]>

* Apply suggestions from code review

Co-authored-by: Saul Field <[email protected]>

* Spelling check

* Fix import error

* Apply suggestions from code review

Co-authored-by: adai <[email protected]>

* Update smarts/core/smarts.py

* Apply suggestions from code review

Co-authored-by: adai <[email protected]>

* Add ros node docstrings

* Pass doctest

* Update smarts/core/utils/math.py

Co-authored-by: adai <[email protected]>

* Apply suggestions from code review

Co-authored-by: adai <[email protected]>

* Update smarts/env/custom_observations.py

Co-authored-by: adai <[email protected]>

* GitHub Actions: Format

* GitHub Actions: Update requirements.txt

* GitHub Actions: Format

* Driving in traffic - dependency version and type annotation (#1250)

* GitHub Actions: Update requirements.txt

* Update version of SMARTS

Co-authored-by: Rutvik Gupta <[email protected]>
Co-authored-by: adaickalavan <[email protected]>
Co-authored-by: Qianyi Sun <[email protected]>
Co-authored-by: Rutvik Gupta <[email protected]>
Co-authored-by: Steve <[email protected]>
Co-authored-by: Steve <[email protected]>
Co-authored-by: Qianyi Sun <[email protected]>
Co-authored-by: Qianyi Sun <[email protected]>
Co-authored-by: qianyi-sun <[email protected]>
Co-authored-by: Stephen Hockema <[email protected]>
Co-authored-by: Allan Liu <[email protected]>
Co-authored-by: Saul Field <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants