Skip to content

Commit

Permalink
add odrive_rrbot demo
Browse files Browse the repository at this point in the history
  • Loading branch information
borongyuan committed Sep 16, 2022
1 parent b5920b2 commit 5b1a015
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
33 changes: 33 additions & 0 deletions odrive_demo_bringup/config/rrbot_controllers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
controller_manager:
ros__parameters:
update_rate: 100 # Hz

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

joint_trajectory_controller:
type: joint_trajectory_controller/JointTrajectoryController

joint_trajectory_controller:
ros__parameters:
joints:
- joint1
- joint2

command_interfaces:
- position
- velocity

state_interfaces:
- position
- velocity

state_publish_rate: 100.0 # Defaults to 50
action_monitor_rate: 20.0 # Defaults to 20

allow_partial_joints_goal: false # Defaults to false
open_loop_control: false
allow_integration_in_goal_trajectories: true
constraints:
stopped_velocity_tolerance: 0.01 # Defaults to 0.01
goal_time: 0.0 # Defaults to 0.0 (start immediately)
92 changes: 92 additions & 0 deletions odrive_demo_bringup/launch/odrive_rrbot.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2022 Factor Robotics
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.substitutions import Command, FindExecutable, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[
FindPackageShare("odrive_demo_description"),
"urdf",
"odrive_rrbot.urdf.xacro"
]
),
]
)
robot_description = {"robot_description": robot_description_content}

robot_controllers = PathJoinSubstitution(
[
FindPackageShare("odrive_demo_bringup"),
"config",
"rrbot_controllers.yaml",
]
)

rviz_config_file = PathJoinSubstitution(
[
FindPackageShare("rrbot_description"),
"config",
"rrbot.rviz"
]
)

control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_description, robot_controllers],
output="both",
)

robot_state_pub_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
)

joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_state_broadcaster", "-c", "/controller_manager"],
)

robot_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_trajectory_controller", "-c", "/controller_manager"],
)

rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
arguments=["-d", rviz_config_file],
)

return LaunchDescription([
control_node,
robot_state_pub_node,
joint_state_broadcaster_spawner,
robot_controller_spawner,
rviz_node
])
23 changes: 23 additions & 0 deletions odrive_demo_description/urdf/odrive_rrbot.urdf.xacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="2dof_robot">

<xacro:arg name="prefix" default="" />

<xacro:include filename="$(find rrbot_description)/urdf/rrbot_description.urdf.xacro" />

<xacro:include filename="$(find rrbot_description)/gazebo/rrbot.materials.xacro" />

<xacro:include filename="$(find odrive_demo_description)/urdf/odrive.ros2_control.xacro" />

<link name="world"/>

<xacro:rrbot parent="world" prefix="$(arg prefix)">
<origin xyz="0 0 0" rpy="0 0 0" />
</xacro:rrbot>

<xacro:odrive_ros2_control
name="ODriveRRBot"
joint0_name="$(arg prefix)joint1"
joint1_name="$(arg prefix)joint2" />

</robot>

0 comments on commit 5b1a015

Please sign in to comment.