Skip to content

Commit

Permalink
starting ros2 port
Browse files Browse the repository at this point in the history
  • Loading branch information
hzheng40 committed Aug 29, 2021
1 parent 4b3d7a9 commit a241408
Show file tree
Hide file tree
Showing 37 changed files with 349 additions and 114 deletions.
113 changes: 47 additions & 66 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,76 +1,57 @@
FROM ros:melodic-robot-bionic
# MIT License

ENV IM_IN_DOCKER Yes

RUN apt-get update --fix-missing && \
apt-get install -y \
python-pip

RUN apt-get install -y libzmq3-dev \
git \
build-essential \
autoconf \
libtool \
libeigen3-dev \
cmake \
vim \
ros-melodic-ackermann-msgs \
ros-melodic-map-server \
ros-melodic-genpy
# Copyright (c) 2020 Hongrui Zheng

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

RUN cp -r /usr/include/eigen3/Eigen /usr/include
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

RUN git clone https://github.com/protocolbuffers/protobuf.git && \
cd protobuf && \
git checkout tags/v3.8.0 && \
git submodule update --init --recursive && \
./autogen.sh && \
./configure && \
make -j8 && \
make install && \
ldconfig && \
make clean && \
cd .. && \
rm -r protobuf
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

RUN pip install --upgrade pip
FROM osrf/ros:foxy-desktop

RUN pip install numpy==1.16.0 \
scipy==1.2.0 \
zmq \
pyzmq \
Pillow \
gym \
protobuf==3.8.0 \
pyyaml \
llvmlite==0.31.0 \
numba==0.47.0


# RUN git clone https://github.com/f1tenth/f1tenth_gym
RUN mkdir /f1tenth_gym
COPY ./f1tenth_gym /f1tenth_gym

RUN cd f1tenth_gym && \
mkdir build && \
cd build && \
cmake .. && \
make
SHELL ["/bin/bash", "-c"]

# dependencies
RUN apt-get update --fix-missing && \
apt-get install -y git \
nano \
vim \
python3-pip

RUN pip3 install --upgrade pip
RUN pip3 install numpy \
scipy \
Pillow \
gym \
pyyaml \
llvmlite \
numba \
pyglet

# f1tenth gym
RUN git clone https://github.com/f1tenth/f1tenth_gym
RUN cd f1tenth_gym && \
cp ./build/sim_requests_pb2.py ./gym/ && \
pip install -e gym/

RUN /bin/bash -c "source /opt/ros/melodic/setup.bash; mkdir -p catkin_ws/src; cd catkin_ws; catkin_make"

RUN mkdir /catkin_ws/src/f1tenth_gym_ros

COPY . /catkin_ws/src/f1tenth_gym_ros

RUN /bin/bash -c "source /opt/ros/melodic/setup.bash; cd catkin_ws; catkin_make; source devel/setup.bash"

pip3 install -e gym/

CMD ["/catkin_ws/src/f1tenth_gym_ros/start.sh"]
# ros2 gym bridge
RUN mkdir -p sim_ws/src/f1tenth_gym_ros
COPY . /sim_ws/src/f1tenth_gym_ros
RUN source /opt/ros/foxy/setup.bash && \
cd sim_ws/ && \
rosdep install -i --from-path src --rosdistro foxy -y && \
colcon build

# CMD ["roslaunch", "package file.launch"]
ENTRYPOINT ["/bin/bash"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Hongrui Zheng, Matthew O'Kelly
Copyright (c) 2020 Hongrui Zheng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 0 additions & 7 deletions build_docker.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions deprecated/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<package format="2">
<name>f1tenth_gym_ros</name>
<version>0.0.0</version>
<description>The f1tenth_gym_ros package</description>

<maintainer email="[email protected]">Hongrui Zheng</maintainer>


<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>message_filters</build_depend>
<build_depend>nav_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>visualization_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_export_depend>message_filters</build_export_depend>
<build_export_depend>nav_msgs</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>visualization_msgs</build_export_depend>
<exec_depend>message_filters</exec_depend>
<exec_depend>nav_msgs</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>visualization_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>


<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->

</export>
</package>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions docker.sh

This file was deleted.

Empty file added f1tenth_gym_ros/__init__.py
Empty file.
83 changes: 83 additions & 0 deletions f1tenth_gym_ros/gym_bridge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# MIT License

# Copyright (c) 2020 Hongrui Zheng

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import rclpy
from rclpy.node import Node

from sensor_msgs.msg import LaserScan
from nav_msgs.msg import Odometry
from geometry_msgs.msg import PoseStamped
from geometry_msgs.msg import TransformStamped
from geometry_msgs.msg import Transform
from geometry_msgs.msg import Quaternion
from ackermann_msgs.msg import AckermannDriveStamped

import gym

class GymBridge(Node):
def __init__(self):
super().__init__('gym_bridge')

# env backend
self.env = gym.make('f110_gym:f110_v0',
map=self.get_parameter('map_path').get_parameter_value(),
map_ext=self.get_parameter('map_img_ext').get_parameter_value(),
num_agents=self.get_parameter('num_agent').get_parameter_value())

# params
ego_scan_topic = self.get_parameter('ego_scan_topic').get_parameter_value().string_value
ego_odom_topic = self.get_parameter('ego_odom_topic').get_parameter_value().string_value
ego_drive_topic = self.get_parameter('ego_drive_topic').get_parameter_value().string_value
opp_scan_topic = self.get_parameter('opp_scan_topic').get_parameter_value().string_value
opp_odom_topic = self.get_parameter('opp_odom_topic').get_parameter_value().string_value
opp_drive_topic = self.get_parameter('opp_drive_topic').get_parameter_value().string_value

# sim physical step timer
self.timer = self.create_timer(0.01, self.timer_callback)

# publishers
self.ego_scan_pub = self.create_publisher(LaserScan, ego_scan_topic, 10)
self.ego_odom_pub = self.create_publisher(Odometry, ego_odom_topic, 10)

# subscribers
self.ego_drive_sub = self.create_subscription(
AckermannDriveStamped,
ego_drive_topic,
self.drive_callback,
10)

def drive_callback(self, drive_msg):
pass

def pose_callback(self, pose_msg):
pass

def timer_callback(self):
pass

def main(args=None):
rclpy.init(args=args)
gym_bridge = GymBridge()
rclpy.spin(gym_bridge)

if __name__ == '__main__':
main()
52 changes: 52 additions & 0 deletions launch/gym_bridge_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# MIT License

# Copyright (c) 2020 Hongrui Zheng

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
return LaunchDescription([
Node(
package='f1tenth_gym_ros',
executable='gym_bridge',
name='bridge',
parameters=[{
'ego_scan_topic': 'scan',
'ego_odom_topic': 'odom',
'ego_drive_topic': 'drive',
'opp_scan_topic': 'opp_scan',
'opp_odom_topic': 'opp_odom',
'opp_drive_topic': 'opp_drive',
'scan_distance_to_base_link': 0.275,
'scan_fov': 4.7,
'scan_beams': 1080,
'map_path': '/f1tenth_gym/maps/berlin.yaml',
'map_img_ext': '.png',
'num_agent': 1
}]
),
Node(
package='rviz2',
executable='rviz2',
name='rviz'
)
])
Binary file added maps/levine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions maps/levine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
image: levine.png
resolution: 0.050000
origin: [-51.224998, -51.224998, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196
48 changes: 13 additions & 35 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,24 @@
<?xml version="1.0"?>
<package format="2">
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>f1tenth_gym_ros</name>
<version>0.0.0</version>
<description>The f1tenth_gym_ros package</description>
<description>Bridge for using f1tenth_gym in ROS2</description>
<maintainer email="[email protected]">Billy Zheng</maintainer>
<license>MIT</license>

<maintainer email="[email protected]">Hongrui Zheng</maintainer>


<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>message_filters</build_depend>
<build_depend>nav_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>visualization_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_export_depend>message_filters</build_export_depend>
<build_export_depend>nav_msgs</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>visualization_msgs</build_export_depend>
<exec_depend>message_filters</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>nav_msgs</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>visualization_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>
<exec_depend>ackermann_msgs</exec_depend>
<exec_depend>rclpy</exec_depend>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->

<build_type>ament_python</build_type>
</export>
</package>
Empty file added resource/f1tenth_gym_ros
Empty file.
Loading

0 comments on commit a241408

Please sign in to comment.