Skip to content

Commit d91456d

Browse files
General cleanup from PR comments
1 parent eec5f54 commit d91456d

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

ihmc-high-level-behaviors/src/libgdx/java/us/ihmc/rdx/perception/RDXHeightMapPanel.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import perception_msgs.msg.dds.HeightMapMessage;
1414
import perception_msgs.msg.dds.HeightMapMessagePubSubType;
1515
import us.ihmc.idl.serializers.extra.JSONSerializer;
16+
import us.ihmc.log.LogTools;
1617
import us.ihmc.perception.heightMap.HeightMapLogReader;
1718
import us.ihmc.rdx.imgui.RDXPanel;
1819
import us.ihmc.rdx.sceneManager.RDXSceneLevel;
@@ -26,11 +27,11 @@
2627

2728
public class RDXHeightMapPanel extends RDXPanel implements RenderableProvider
2829
{
29-
RDXROS2HeightMapVisualizer heightMapVisualizer;
30+
private final RDXROS2HeightMapVisualizer heightMapVisualizer;
3031

3132
private final HeightMapMessage heightMapMessage = new HeightMapMessage();
3233
private HeightMapLogReader logReader;
33-
int currentFrameIndex = 0;
34+
private int currentFrameIndex = 0;
3435

3536
private boolean isPlaying = false;
3637
private final float[] playbackSpeedSeconds = new float[] {0.1f};
@@ -66,7 +67,7 @@ public void renderImGuiWidgets()
6667
if (ImGuiFileDialog.isOk())
6768
{
6869
String selectedFile = ImGuiFileDialog.getFilePathName();
69-
System.out.println("Selected file: " + selectedFile);
70+
LogTools.info("Selected file: " + selectedFile);
7071

7172
if (selectedFile.endsWith(".json"))
7273
{
@@ -237,6 +238,14 @@ public void getRenderablesFull(Array<Renderable> renderables, Pool<Renderable> p
237238
public void destroy()
238239
{
239240
heightMapVisualizer.destroy();
241+
try
242+
{
243+
logReader.close();
244+
}
245+
catch (IOException e)
246+
{
247+
e.printStackTrace();
248+
}
240249
}
241250

242251
@Override

ihmc-high-level-behaviors/src/main/java/us/ihmc/behaviors/activeMapping/ContinuousHikingProcess.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,15 @@ public class ContinuousHikingProcess
3434
private final EnvironmentHandler environmentHandler = new EnvironmentHandler();
3535
private final ActiveMappingParameterToolBox activeMappingParameterToolBox;
3636
private final ContinuousPlannerSchedulingTask continuousPlannerSchedulingTask;
37-
3837
private final SnappingTerrainManager snappingTerrainManager;
39-
4038
private final RapidHeightMapThread rapidHeightMapThread;
41-
@org.jetbrains.annotations.NotNull
42-
private final ROS2ImageSensors ros2ImageSensors;
4339

4440
public ContinuousHikingProcess(DRCRobotModel robotModel,
4541
RobotCollisionModel robotCollisionModel,
4642
ROS2Node ros2Node,
4743
ROS2ImageSensors ros2ImageSensors,
4844
ROS2SyncedRobotModel ros2SyncedRobot)
4945
{
50-
this.ros2ImageSensors = ros2ImageSensors;
51-
5246
// Create a bunch of overhead for the ROS2 communication and the robot
5347
ros2SyncedRobot.initializeToDefaultRobotInitialSetup(0.0, 0.0, 0.0, 0.0);
5448
ControllerFootstepQueueMonitor controllerFootstepQueueMonitor = new ControllerFootstepQueueMonitor(ros2Node, robotModel.getSimpleRobotName());
@@ -118,7 +112,6 @@ public void update()
118112

119113
public void destroy()
120114
{
121-
ros2ImageSensors.destroy();
122115
rapidHeightMapThread.blockingKill();
123116
continuousPlannerSchedulingTask.destroy();
124117
snappingTerrainManager.close();

ihmc-perception/src/main/java/us/ihmc/perception/gpuHeightMap/RapidHeightMapManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ private void publishHeightMap(Mat globalHeightMap, Point3D heightMapCenter)
149149
{
150150
throw new RuntimeException(e);
151151
}
152-
catch (IOException ignored)
152+
catch (IOException e)
153153
{
154+
e.printStackTrace();
154155
}
155156

156157
try

ihmc-perception/src/main/java/us/ihmc/perception/heightMap/HeightMapMessageTools.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public static Mat unpackMessageToMat(HeightMapMessage heightMapMessage)
4646
Mat heightMap = new Mat(cellsPerAxis, cellsPerAxis, opencv_core.CV_16UC1);
4747
ShortBuffer shortBuffer = heightMap.createBuffer();
4848

49+
int totalCells = cellsPerAxis * cellsPerAxis;
50+
short[] heights = new short[totalCells];
51+
4952
for (int i = 0; i < heightMapMessage.getHeights().size(); i++)
5053
{
5154
short height = (short) heightMapMessage.getHeights().get(i);
@@ -55,9 +58,11 @@ public static Mat unpackMessageToMat(HeightMapMessage heightMapMessage)
5558
int yIndex = key / cellsPerAxis;
5659

5760
int index = yIndex * cellsPerAxis + xIndex;
58-
shortBuffer.put(index, height);
61+
heights[index] = height;
5962
}
6063

64+
shortBuffer.put(heights);
65+
6166
return heightMap;
6267
}
6368

@@ -93,7 +98,7 @@ public static void toMessage(HeightMapData heightMapData, HeightMapMessage messa
9398
for (int i = 0; i < heightMapData.getNumberOfOccupiedCells() && i < messageToPack.getKeys().capacity(); i++)
9499
{
95100
int key = heightMapData.getKey(i);
96-
messageToPack.getKeys().add((short) key);
101+
messageToPack.getKeys().add((key));
97102
messageToPack.getHeights().add((short) heightMapData.getHeightAt(key));
98103
}
99104
}

ihmc-perception/src/main/java/us/ihmc/perception/heightMap/HeightMapUpdater.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package us.ihmc.perception.heightMap;
22

33
import com.google.common.util.concurrent.AtomicDouble;
4-
import gnu.trove.list.TShortList;
5-
import gnu.trove.list.array.TShortArrayList;
64
import perception_msgs.msg.dds.HeightMapMessage;
75
import perception_msgs.msg.dds.HeightMapMessagePubSubType;
8-
import gnu.trove.list.array.TFloatArrayList;
96
import gnu.trove.list.array.TIntArrayList;
107
import us.ihmc.commons.MathTools;
118
import us.ihmc.euclid.tuple2D.interfaces.Point2DBasics;

ihmc-perception/src/test/java/us/ihmc/perception/heightmap/HeightMapMessageToolsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public class HeightMapMessageToolsTest
1616
{
17-
private final int iterations = 10000;
17+
private final int iterations = 1000;
1818

1919
@Test
2020
public void testHeightMapMessaging()
@@ -31,7 +31,7 @@ public void testHeightMapMessaging()
3131
{
3232
for (int j = 0; j < cellsPerAxis; j++)
3333
{
34-
heightMap.ptr(i, j).putInt(i + j);
34+
heightMap.ptr(i, j).putShort((short) (i + j));
3535
}
3636
}
3737

0 commit comments

Comments
 (0)