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

Feature/mobility #7

Open
wants to merge 8 commits into
base: ros2-humble
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

/src/roarm_main/roarm_driver/roarm_driver/__pycache__/
72 changes: 60 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,19 @@ Check the serial devices again:

You should now see a new device like `/dev/ttyUSB0` at the end of the list. If not, disconnect and reconnect the robotic arm.

### 3.2 Change the Serial Port Device
If the detected serial port device is `/dev/ttyUSB0`, you can skip this section and proceed to **3.3** Running the Robotic Arm Driver Node.
### 3.2 Update the Serial Port Device

If the serial port device is not `/dev/ttyUSB0`, you need to update the serial port device name in the Python script `~/roarm_ws_em0/src/roarm_main/roarm_driver/roarm_driver/roarm_driver.py` by changing line 15:
Grant read and write permissions to the serial device using the following command (replace `/dev/ttyUSB0` with your actual device path):

sudo chmod 666 /dev/ttyUSB0

If the serial port device is not `/dev/ttyUSB0`, you can either provide the proper device name at launch and/or you can update the serial port device name in the launch file `~/roarm_ws_em0/src/roarm_main/roarm_driver/launch/roarm.launch.py` by changing line 10:

serial_port = "/dev/ttyUSB0"
default_value='/dev/ttyUSB0',

to your actual serial port device name.
![image](images/roarm_driver.py.png)
<img src="images/roarm.launch.py.png" alt="editor" width="600"/>

Then, recompile the ROS2 packages in the terminal:

cd ~/roarm_ws_em0/
Expand All @@ -217,15 +221,13 @@ Then, recompile the ROS2 packages in the terminal:
### 3.3 Running the Robotic Arm Driver Node
According to the ROS2 official documentation, it is not recommended to run ROS2 nodes in the same terminal where you compile the packages. Open a new terminal window using `Ctrl + Alt + T`.

Grant serial port permissions and run the ROS2 robotic arm driver node:

Grant read and write permissions to the serial device using the following command (replace `/dev/ttyUSB0` with your actual device path):
Launch the driver node:

sudo chmod 666 /dev/ttyUSB0
ros2 launch roarm_driver roarm.launch.py #if you have the default port or edited the launch file

Run the driver node:
Or, override the serial port name at launch with something like:

ros2 run roarm_driver roarm_driver
ros2 launch roarm_driver roarm.launch.py serial_port:=/dev/ttyUSB2

### 3.4 Viewing the Model Joints
Open a new terminal window with `Ctrl + Alt + T`.
Expand Down Expand Up @@ -564,4 +566,50 @@ Call the service to make the robotic arm draw a circle at the specified position

The x, y, and z parameters specify the center of the circle, and radius specifies the radius of the circle in meters.

By calling this service, you can control the robotic arm to draw a circle at the desired position.
By calling this service, you can control the robotic arm to draw a circle at the desired position.

## 9 Description Options ##

The URDF description is embedded in xacro files to enable extended capabilities:
- Dynamically generate the latest description at launch-time
- Allow multiple copies of the arm to be loaded into a robot_description
- Allow the end-effector to be rotated
- Mount the arm on a robot

### 9.1 Xacro Arguments ###
The arguments to the xacro files include:
- **prefix**. This parameter governs the prefix applied to the beginning of all links and joints. Because the TF framespace is global, multiple instances of the arm or robots can't have the same name. Defaults to nothing.
- **arm_base_link_name**. If you don't want to use a namespace to isolate the arm, this parameter allows you to rename the base link so it doesn't conflict with the robot's base_link. Defaults to base_link.
- **end_rot**. The final joint for the arm can be rotated by adjusting the clamp that holds the last servo. The factory configuration has the gripper opening to the right. To change the rotation, specifiy either 90, 180 or 270 degrees rotation. This is a CCW rotation when looking at the gripper. Defaults to 0.

To run build the description, change to the roarm_description/urdf folder and run:

xacro roarm_description.urdf.xacro

This will compile the description and put it out to the terminal. It won't actually change anything. To experiment with the defaults run it like:

xacro roarm_description.urdf.xacro prefix:=/left_arm/ end_rot:=180

This will cause all the link and joint names to start with /left_arm and flip the end effector to grip from the left.

To save the compiled urdf, output it to roarm_generated.urdf:

xacro roarm_description.urdf.xacro prefix:=/left_arm/ end_rot:=180 > roarm_generaated.urdf

Remember to a fresh **colcon build** if not using the --symlink-install option. It's not necessary to save the changes if doing a live compile with a launch file:

### 9.2 Launch Example of Two Mounted Arms ###

To display two arms attached to a simplistic robot base, enabled with the same parameters, run:

ros2 launch roarm_description mounted.display.launch.py end_rot:=90

Examine this launch file to understand how multiple arms could be added to a robot or how multiple robots with arms could exist in the same robot description. This command will launch the arms with the gripper/wrist rotated to open downward.

This launch file defaults to an example namespace of /mybot1. All of the nodes it launches will share this namespace which can help create isolation needed to manage duplicates.

In depth treatment of node isolation is beyond the scope of this example. To actually run two roarm_driver nodes you would need to isolate them with their own arm namespaces so they pick up their respective joints. The harder problem on a real robot might lie in reliabily assigning the correct serial port to each arm across reboots.

This launch file compiles the xacro at launch time and loads the description as a parameter, pulling in the latest changes and arguments. If the robot base gets moved around in the environment the arms should move with it.

<img src="images/twoarms.PNG" alt="Two Arms, One Bot" width="600"/>
Binary file added images/roarm.launch.py.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/twoarms.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
282 changes: 282 additions & 0 deletions src/roarm_main/roarm_description/config/mounted_roarm_description.rviz
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
Panels:
- Class: rviz_common/Displays
Help Height: 78
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /Status1
- /RobotModel1
- /RobotModel1/Description Topic1
- /TF1
- /TF1/Frames1
Splitter Ratio: 0.8294117450714111
Tree Height: 439
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expanded:
- /2D Goal Pose1
- /Publish Point1
Name: Tool Properties
Splitter Ratio: 0.5886790156364441
- Class: rviz_common/Views
Expanded:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz_common/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: ""
Visualization Manager:
Class: ""
Displays:
- Alpha: 0.5
Cell Size: 1
Class: rviz_default_plugins/Grid
Color: 160; 160; 164
Enabled: true
Line Style:
Line Width: 0.029999999329447746
Value: Lines
Name: Grid
Normal Cell Count: 0
Offset:
X: 0
Y: 0
Z: 0
Plane: XY
Plane Cell Count: 10
Reference Frame: <Fixed Frame>
Value: true
- Alpha: 1
Class: rviz_default_plugins/RobotModel
Collision Enabled: false
Description File: ""
Description Source: Topic
Description Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /mybot1/robot_description
Enabled: true
Links:
/mybot1/arm_left/base_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_left/gripper_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_left/hand_tcp:
Alpha: 1
Show Axes: false
Show Trail: false
/mybot1/arm_left/link1:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_left/link2:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_left/link3:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_right/base_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_right/gripper_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_right/hand_tcp:
Alpha: 1
Show Axes: false
Show Trail: false
/mybot1/arm_right/link1:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_right/link2:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/arm_right/link3:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
/mybot1/base_link:
Alpha: 1
Show Axes: false
Show Trail: false
Value: true
All Links Enabled: true
Expand Joint Details: false
Expand Link Details: false
Expand Tree: false
Link Tree Style: Links in Alphabetic Order
Mass Properties:
Inertia: false
Mass: false
Name: RobotModel
TF Prefix: ""
Update Interval: 0
Value: true
Visual Enabled: true
- Class: rviz_default_plugins/TF
Enabled: true
Frame Timeout: 15
Frames:
All Enabled: true
mybot1/arm_left/base_link:
Value: true
mybot1/arm_left/gripper_link:
Value: true
mybot1/arm_left/hand_tcp:
Value: true
mybot1/arm_left/link1:
Value: true
mybot1/arm_left/link2:
Value: true
mybot1/arm_left/link3:
Value: true
mybot1/arm_right/base_link:
Value: true
mybot1/arm_right/gripper_link:
Value: true
mybot1/arm_right/hand_tcp:
Value: true
mybot1/arm_right/link1:
Value: true
mybot1/arm_right/link2:
Value: true
mybot1/arm_right/link3:
Value: true
mybot1/base_link:
Value: true
Marker Scale: 1
Name: TF
Show Arrows: false
Show Axes: false
Show Names: false
Tree:
mybot1/base_link:
mybot1/arm_left/base_link:
mybot1/arm_left/link1:
mybot1/arm_left/link2:
mybot1/arm_left/link3:
mybot1/arm_left/gripper_link:
{}
mybot1/arm_left/hand_tcp:
{}
mybot1/arm_right/base_link:
mybot1/arm_right/link1:
mybot1/arm_right/link2:
mybot1/arm_right/link3:
mybot1/arm_right/gripper_link:
{}
mybot1/arm_right/hand_tcp:
{}
Update Interval: 0
Value: true
Enabled: true
Global Options:
Background Color: 222; 221; 218
Fixed Frame: mybot1/base_link
Frame Rate: 30
Name: root
Tools:
- Class: rviz_default_plugins/Interact
Hide Inactive Objects: true
- Class: rviz_default_plugins/MoveCamera
- Class: rviz_default_plugins/Select
- Class: rviz_default_plugins/FocusCamera
- Class: rviz_default_plugins/Measure
Line color: 128; 128; 0
- Class: rviz_default_plugins/SetInitialPose
Covariance x: 0.25
Covariance y: 0.25
Covariance yaw: 0.06853891909122467
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /initialpose
- Class: rviz_default_plugins/SetGoal
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /goal_pose
- Class: rviz_default_plugins/PublishPoint
Single click: true
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /clicked_point
Transformation:
Current:
Class: rviz_default_plugins/TF
Value: true
Views:
Current:
Class: rviz_default_plugins/Orbit
Distance: 1.4765546321868896
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: 0.15409952402114868
Y: 0.1464391052722931
Z: 0.17184139788150787
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.28039857745170593
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 5.69858980178833
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 736
Hide Left Dock: false
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd00000004000000000000015600000242fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000242000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000242fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d00000242000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004ba0000003efc0100000002fb0000000800540069006d00650100000000000004ba000002fb00fffffffb0000000800540069006d00650100000000000004500000000000000000000002490000024200000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: false
Width: 1210
X: 702
Y: 299
2 changes: 1 addition & 1 deletion src/roarm_main/roarm_description/launch/display.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def generate_launch_description():
package_name = 'roarm_description'
urdf_name = "roarm_description.urdf"
urdf_name = "roarm_generated.urdf"
ld = LaunchDescription()
pkg_share = FindPackageShare(package=package_name).find(package_name)
urdf_model_path = os.path.join(pkg_share, f'urdf/{urdf_name}')
Expand Down
Loading