This repository has been archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
210 changed files
with
2,432 additions
and
5,866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[flake8] | ||
show-source = true | ||
max-line-length = 120 | ||
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s | ||
exclude = .git | ||
application-package-names = | ||
march_description, | ||
march_gain_scheduling, | ||
march_gait_scheduler, | ||
march_gait_selection, | ||
march_launch, | ||
march_safety, | ||
march_shared_classes, | ||
march_shared_resources, | ||
march_sound_scheduler, | ||
march_state_machine | ||
import-order-style = appnexus | ||
ignore = | ||
# D100: Missing docstring in public module | ||
D100, | ||
# D102: Missing docstring in public class | ||
D101, | ||
# D102: Missing docstring in public method | ||
D102, | ||
# D103: Missing docstring in public function | ||
D103, | ||
# D104: Missing docstring in public package | ||
D104, | ||
# D105: Missing docstring in magic method | ||
D105, | ||
# D106: Missing docstring in public nested class | ||
D106, | ||
# D107: Missing docstring in __init__ | ||
D107, | ||
# D401: First line should be in imperative mood | ||
D401, | ||
# W503: Line break before operator | ||
W503, | ||
# C815: Trailing comma in Python 3.5 | ||
C815 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* @Olavhaasie @project-march/v-software | ||
|
||
/march_data_collector/ @RutgerVanBeek @project-march/v-software @Olavhaasie | ||
/march_gain_scheduling/ @project-march/v-control @project-march/v-software @Olavhaasie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env python | ||
|
||
from march_data_collector import march_data_collector_node | ||
from march_data_collector import data_collector_node | ||
|
||
if __name__ == '__main__': | ||
march_data_collector_node.main() | ||
data_collector_node.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
march_data_collector/src/march_data_collector/com_calculator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Copyright (c) Hamburg Bit-Bots | ||
# | ||
# 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 geometry_msgs.msg | ||
import rospy | ||
import tf2_geometry_msgs as tf_geo | ||
import tf2_ros | ||
from visualization_msgs.msg import Marker | ||
|
||
|
||
class CoMCalculator(object): | ||
|
||
def __init__(self, robot, tf_buffer): | ||
self.tf_buffer = tf_buffer | ||
|
||
self.links = dict(filter(lambda (_, l): l.inertial is not None, robot.link_map.items())) | ||
self.mass = sum(l.inertial.mass for (_, l) in self.links.items()) | ||
|
||
self.marker = Marker() | ||
self.marker.header.frame_id = 'world' | ||
self.marker.type = self.marker.SPHERE | ||
self.marker.action = self.marker.ADD | ||
self.marker.pose.orientation.w = 1.0 | ||
self.marker.color.a = 1.0 | ||
self.marker.color.r = 1.0 | ||
self.marker.scale.x = 0.03 | ||
self.marker.scale.y = 0.03 | ||
self.marker.scale.z = 0.03 | ||
|
||
def calculate_com(self): | ||
x = 0 | ||
y = 0 | ||
z = 0 | ||
for link in self.links: | ||
try: | ||
trans = self.tf_buffer.lookup_transform('world', link, rospy.Time()) | ||
|
||
to_transform = geometry_msgs.msg.PointStamped() | ||
to_transform.point.x = self.links[link].inertial.origin.xyz[0] | ||
to_transform.point.y = self.links[link].inertial.origin.xyz[1] | ||
to_transform.point.z = self.links[link].inertial.origin.xyz[2] | ||
to_transform.header.frame_id = link | ||
to_transform.header.stamp = rospy.get_rostime() | ||
transformed = tf_geo.do_transform_point(to_transform, trans) | ||
|
||
# calculate part of CoM equation depending on link | ||
x += self.links[link].inertial.mass * transformed.point.x | ||
y += self.links[link].inertial.mass * transformed.point.y | ||
z += self.links[link].inertial.mass * transformed.point.z | ||
except tf2_ros.TransformException as err: | ||
rospy.logwarn('error in CoM calculation' + str(err)) | ||
|
||
x = x / self.mass | ||
y = y / self.mass | ||
z = z / self.mass | ||
|
||
# send CoM position to RViZ | ||
self.marker.header.stamp = rospy.get_rostime() | ||
self.marker.pose.position.x = x | ||
self.marker.pose.position.y = y | ||
self.marker.pose.position.z = z | ||
rospy.logdebug('center of mass is at ' + str(self.marker.pose.position)) | ||
|
||
return self.marker |
60 changes: 60 additions & 0 deletions
60
march_data_collector/src/march_data_collector/cp_calculator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from math import sqrt | ||
|
||
import rospy | ||
from visualization_msgs.msg import Marker | ||
|
||
|
||
class CPCalculator(object): | ||
|
||
def __init__(self, tf_buffer, foot_link): | ||
self.tf_buffer = tf_buffer | ||
self.foot_link = foot_link | ||
self.publisher = rospy.Publisher('/march/cp_marker_' + foot_link, Marker, queue_size=1) | ||
|
||
self.prev_x = 0 | ||
self.prev_y = 0 | ||
self.prev_t = rospy.Time.now() | ||
|
||
self.marker = Marker() | ||
|
||
self.marker.header.frame_id = 'world' | ||
self.marker.type = self.marker.SPHERE | ||
self.marker.action = self.marker.ADD | ||
self.marker.pose.orientation.w = 1.0 | ||
self.marker.color.a = 1.0 | ||
self.marker.color.g = 1.0 | ||
self.marker.scale.x = 0.03 | ||
self.marker.scale.y = 0.03 | ||
self.marker.scale.z = 0.03 | ||
|
||
self.g = 9.81 # gravity constant | ||
|
||
def calculate_cp(self, com_mark): | ||
current_time = com_mark.header.stamp | ||
time_difference = (current_time - self.prev_t).to_sec() | ||
if current_time is not self.prev_t: | ||
x_dot = (com_mark.pose.position.x - self.prev_x) / time_difference | ||
y_dot = (com_mark.pose.position.y - self.prev_y) / time_difference | ||
|
||
trans = self.tf_buffer.lookup_transform('world', self.foot_link, rospy.Time()) | ||
multiplier = sqrt(com_mark.pose.position.z / self.g) | ||
x_cp = trans.transform.translation.x + x_dot * multiplier | ||
y_cp = trans.transform.translation.y + y_dot * multiplier | ||
|
||
self.update_marker(x_cp, y_cp) | ||
|
||
self.prev_x = com_mark.pose.position.x | ||
self.prev_y = com_mark.pose.position.y | ||
self.prev_t = current_time | ||
|
||
return self.marker | ||
|
||
def update_marker(self, x_cp, y_cp): | ||
self.marker.header.stamp = rospy.get_rostime() | ||
self.marker.pose.position.x = x_cp | ||
self.marker.pose.position.y = y_cp | ||
self.marker.pose.position.z = 0 | ||
|
||
rospy.logdebug('capture point is at ' + str(self.marker.pose.position)) | ||
|
||
self.publisher.publish(self.marker) |
Oops, something went wrong.