Skip to content

Commit

Permalink
Merge branch 'devel' into 'master'
Browse files Browse the repository at this point in the history
release 1.2

See merge request MAB_Robotics/ros1_mab_md80!12
  • Loading branch information
jakubmatyszczak committed Dec 19, 2022
2 parents 48d765e + 00e52d7 commit 510c686
Show file tree
Hide file tree
Showing 13 changed files with 338 additions and 765 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "candle"]
path = candle
url = https://github.com/mabrobotics/candle.git
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ include_directories(
${catkin_INCLUDE_DIRS}
)

set(CANDLE_BUILD_STATIC ON)
set(CANDLE_OMIT_EXAMPLES ON)
add_subdirectory(candle)

set(CMAKE_INSTALL_RPATH $ORIGIN) # sets proper runtime paths for exec to link .so properly

add_executable(${PROJECT_NAME}_node src/md80_node.cpp)
target_link_libraries(${PROJECT_NAME}_node "${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/lib/libcandle.so" ${catkin_LIBRARIES})
target_include_directories(${PROJECT_NAME}_node PUBLIC ./include)
add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}_node candle ${catkin_LIBRARIES})
target_include_directories(${PROJECT_NAME}_node PUBLIC ./candle/include ./include)

add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS})
79 changes: 6 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Md80 ROS Node
# MD80 ROS Node

This node handles the communication between MAB's md80 drives in ROS environment. The node was designed to act as
This node handles the communication between MAB's MD80 drives in ROS environment. The node was designed to act as
operational endpoint - to control the drives and get information from them, thus it is not capable of configuring the drives,
for this use `mdtool` , `Candle` library or custom FDCAN application.
for this use [MDtool](https://github.com/mabrobotics/mdtool).

## Principles of operation
## Available services and topics

The node normally communicates via services for setup, and via topics for regular data transfers.
Services are:
Expand All @@ -23,73 +23,6 @@ Topics subscribed by the node are:
Topic published by the node is:
- /md80/joint_states

## Cloning the node
In order to run the node clone it into your local ROS workspace in the src folder. Then run build it with 'catkin' and run using the 'rosrun' command. Be sure to source your workspace with
```
source devel/setup.sh
```
prior to running the package.
## Quick startup guide

## Node setup
After starting the node, it will wait for configuration messages.

### Add drives
Firstly, the node should be informed which drives should be present on the FDCAN bus. This can be done via `/add_md80s` service.
For example:
```
rosservice call /add_md80s "drive_ids: [81, 97]"
```
Should produce the following output:
```
drives_success: [True, True]
total_number_of_drives: 2
```
informing, that both drives (ids: 81 and 97), have been successfully contacted, and were added to the node's drives list.

### Set mode
Next the desired control mode should be selected. This is accomplished with `/set_mode_md80s` service.
For example:
```
rosservice call /set_mode_md80s "{drive_ids: [81, 97], mode:["IMPEDANCE", "IMPEDANCE"]}"
```
Should produce:
```
drives_success: [True, True]
```
Informing that for both drives mode has been set correctly.

### Set Zero
Often when starting, setting a current position to zero is desired. This can be accomplished with a call to `/zero_md80s` service.
```
rosservice call /zero_md80s "{drive_ids:[81, 97]}"
```

### Setting limits
The limits can be set using `/set_limits_md80s` service, for example
```
rosservice call /set_limits_md80s "{drive_ids:[81, 97], velocity_limit:[10, 20], torque_limit:[0.1, 0.1]}"
```

### Enabling/Disabling drives
Using services `/enable_md80s` and `/disable_md80s` the drives and the node publishers and subscribers can be enabled/disabled.
**NOTE: After calling `/enable_md80s` service, no calls to services other than `/disable_md80s` should be done.**

After enabling, the node will publish current joint states to `/joint_states` at a frequency of 100Hz. Joint names are generated based on drivie ID, for example drive with id 546 will be called `Joint 546`.

The node will also listen for the messages on topics for controlling the drives. All of the above topics are listened to all the time, but currently applied settings are dependent on the md80 mode set before enabling.
```
rosservice call /enable_md80s "{drive_ids:[81, 97]}"
rosservice call /disable_md80s "{drive_ids:[81, 97]}"
```

### Controlling drives
Controlling the drives is done via the four topics listed above. For commands to be viable, all field of each message must be filled properly. For example, to set up custom gains for IMPEDANCE mode use:
```
rostopic pub /md80/impedance_command candle_ros/ImpedanceCommand "{drive_ids:[81, 97], kp:[0.25, 1.0], kd:[0.1, 0.05], max_output:[2.0, 2.0]}"
```

Setting desired position, velocity, and torque is done via `/md80/motion_command` topic. Note that for it to take effect, all fields in the message should be correctly filled. For example, to move the drives in impedance mode, it is possible to use the following command
```
rostopic pub /md80/motion_command candle_ros/MotionCommand "{drive_ids:[81,97], target_position:[3.0, -3.0], target_velocity:[0.0, 0.0], target_torque:[0, 0]}" -1
```
Please find a detailed startup guide in the [MD80 x CANdle manual](https://www.mabrobotics.pl/servos)
1 change: 1 addition & 0 deletions candle
Submodule candle added at 687300
239 changes: 0 additions & 239 deletions include/Candle/candle.hpp

This file was deleted.

0 comments on commit 510c686

Please sign in to comment.