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

⬆️ ihmc-ros2-library 1.1.0 #484

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import us.ihmc.avatar.drcRobot.RobotTarget;
import us.ihmc.avatar.networkProcessor.fiducialDetectorToolBox.FiducialDetectorToolboxModule;
import us.ihmc.avatar.networkProcessor.objectDetectorToolBox.ObjectDetectorToolboxModule;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;

public class AtlasCombinedFiducialModuleStarter
{
Expand Down Expand Up @@ -38,12 +37,10 @@ public static void main(String[] args) throws JSAPException
return;
}

PubSubImplementation pubSubImplementation = PubSubImplementation.FAST_RTPS;
new FiducialDetectorToolboxModule(robotModel.getSimpleRobotName(),
robotModel.getTarget(),
robotModel.createFullRobotModel(),
robotModel.getLogModelProvider(),
pubSubImplementation);
new ObjectDetectorToolboxModule(robotModel.getSimpleRobotName(),robotModel.createFullRobotModel(),robotModel.getLogModelProvider(),pubSubImplementation);
robotModel.getLogModelProvider());
new ObjectDetectorToolboxModule(robotModel.getSimpleRobotName(),robotModel.createFullRobotModel(),robotModel.getLogModelProvider());
}
}
20 changes: 10 additions & 10 deletions atlas/src/main/java/us/ihmc/atlas/AtlasDirectRobotInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
import atlas_msgs.msg.dds.AtlasDesiredPumpPSIPacket;
import atlas_msgs.msg.dds.AtlasLowLevelControlModeMessage;
import atlas_msgs.msg.dds.BDIBehaviorCommandPacket;
import controller_msgs.msg.dds.*;
import controller_msgs.msg.dds.AbortWalkingMessage;
import controller_msgs.msg.dds.PauseWalkingMessage;
import us.ihmc.avatar.drcRobot.DRCRobotModel;
import us.ihmc.communication.HumanoidControllerAPI;
import us.ihmc.ros2.ROS2PublisherBasics;
import us.ihmc.communication.ROS2Tools;
import us.ihmc.communication.controllerAPI.RobotLowLevelMessenger;
import us.ihmc.humanoidRobotics.communication.packets.HumanoidMessageTools;
import us.ihmc.humanoidRobotics.communication.packets.atlas.AtlasLowLevelControlMode;
import us.ihmc.ros2.ROS2NodeInterface;
import us.ihmc.ros2.ROS2Node;
import us.ihmc.ros2.ROS2Publisher;
import us.ihmc.ros2.ROS2Topic;

public class AtlasDirectRobotInterface implements RobotLowLevelMessenger
{
private final ROS2PublisherBasics<AtlasLowLevelControlModeMessage> lowLevelModePublisher;
private final ROS2PublisherBasics<BDIBehaviorCommandPacket> bdiBehaviorPublisher;
private final ROS2PublisherBasics<AtlasDesiredPumpPSIPacket> desiredPumpPSIPublisher;
private final ROS2PublisherBasics<AbortWalkingMessage> abortWalkingPublisher;
private final ROS2PublisherBasics<PauseWalkingMessage> pauseWalkingPublisher;
private final ROS2Publisher<AtlasLowLevelControlModeMessage> lowLevelModePublisher;
private final ROS2Publisher<BDIBehaviorCommandPacket> bdiBehaviorPublisher;
private final ROS2Publisher<AtlasDesiredPumpPSIPacket> desiredPumpPSIPublisher;
private final ROS2Publisher<AbortWalkingMessage> abortWalkingPublisher;
private final ROS2Publisher<PauseWalkingMessage> pauseWalkingPublisher;

public AtlasDirectRobotInterface(ROS2NodeInterface ros2Node, DRCRobotModel robotModel)
public AtlasDirectRobotInterface(ROS2Node ros2Node, DRCRobotModel robotModel)
{
ROS2Topic inputTopic = HumanoidControllerAPI.getInputTopic(robotModel.getSimpleRobotName());
lowLevelModePublisher = ros2Node.createPublisher(inputTopic.withTypeName(AtlasLowLevelControlModeMessage.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import us.ihmc.avatar.drcRobot.RobotTarget;
import us.ihmc.avatar.networkProcessor.fiducialDetectorToolBox.FiducialDetectorToolboxModule;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;

public class AtlasFiducialModulalStarter
{
public static void main(String[] args)
{
PubSubImplementation pubSubImplementation = PubSubImplementation.FAST_RTPS;
AtlasRobotModel robotModel = new AtlasRobotModel(AtlasRobotVersion.ATLAS_UNPLUGGED_V5_DUAL_ROBOTIQ, RobotTarget.REAL_ROBOT);
new FiducialDetectorToolboxModule(robotModel.getSimpleRobotName(),
robotModel.getTarget(),
robotModel.createFullRobotModel(),
robotModel.getLogModelProvider(),
pubSubImplementation);
robotModel.getLogModelProvider());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import us.ihmc.avatar.scs2.SCS2AvatarSimulation;
import us.ihmc.avatar.scs2.SCS2AvatarSimulationFactory;
import us.ihmc.commonWalkingControlModules.desiredFootStep.footstepGenerator.HeadingAndVelocityEvaluationScriptParameters;
import us.ihmc.communication.ROS2Tools;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;
import us.ihmc.robotics.robotSide.RobotSide;
import us.ihmc.robotics.robotSide.SideDependentList;
import us.ihmc.ros2.ROS2NodeBuilder;
import us.ihmc.ros2.RealtimeROS2Node;
import us.ihmc.scs2.SimulationConstructionSet2;
import us.ihmc.scs2.simulation.SimulationSession;
import us.ihmc.scs2.simulation.robot.Robot;
import us.ihmc.simulationConstructionSetTools.util.HumanoidFloatingRootJointRobot;
import us.ihmc.simulationConstructionSetTools.util.environments.FlatGroundEnvironment;
Expand All @@ -25,8 +23,7 @@ public class AtlasFlatGroundWalkingTrackSCS2
private static boolean createYoVariableServer = System.getProperty("create.yovariable.server") != null
&& Boolean.parseBoolean(System.getProperty("create.yovariable.server"));

private final RealtimeROS2Node realtimeROS2Node = ROS2Tools.createRealtimeROS2Node(PubSubImplementation.INTRAPROCESS,
"flat_ground_walking_track_simulation");
private final RealtimeROS2Node realtimeROS2Node = new ROS2NodeBuilder().buildRealtime("flat_ground_walking_track_simulation");

public AtlasFlatGroundWalkingTrackSCS2()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package us.ihmc.atlas;

import static us.ihmc.humanoidRobotics.communication.packets.dataobjects.HighLevelControllerName.DO_NOTHING_BEHAVIOR;
import static us.ihmc.humanoidRobotics.communication.packets.dataobjects.HighLevelControllerName.WALKING;

import java.util.ArrayList;

import us.ihmc.avatar.drcRobot.DRCRobotModel;
import us.ihmc.avatar.initialSetup.RobotInitialSetup;
import us.ihmc.avatar.scs2.SCS2AvatarSimulation;
Expand All @@ -15,26 +10,29 @@
import us.ihmc.commonWalkingControlModules.dynamicPlanning.bipedPlanning.CoPTrajectoryParameters;
import us.ihmc.commonWalkingControlModules.highLevelHumanoidControl.factories.ContactableBodiesFactory;
import us.ihmc.commonWalkingControlModules.highLevelHumanoidControl.factories.HighLevelHumanoidControllerFactory;
import us.ihmc.communication.ROS2Tools;
import us.ihmc.euclid.transform.RigidBodyTransform;
import us.ihmc.humanoidRobotics.communication.packets.dataobjects.HighLevelControllerName;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;
import us.ihmc.robotics.robotSide.RobotSide;
import us.ihmc.robotics.robotSide.SideDependentList;
import us.ihmc.ros2.ROS2NodeBuilder;
import us.ihmc.ros2.RealtimeROS2Node;
import us.ihmc.sensorProcessing.parameters.HumanoidRobotSensorInformation;
import us.ihmc.simulationConstructionSetTools.util.HumanoidFloatingRootJointRobot;
import us.ihmc.simulationConstructionSetTools.util.environments.FlatGroundEnvironment;
import us.ihmc.wholeBodyController.RobotContactPointParameters;

import java.util.ArrayList;

import static us.ihmc.humanoidRobotics.communication.packets.dataobjects.HighLevelControllerName.DO_NOTHING_BEHAVIOR;
import static us.ihmc.humanoidRobotics.communication.packets.dataobjects.HighLevelControllerName.WALKING;

public class AtlasFlatGroundWalkingTrackSCS2Bullet
{
private static final boolean USE_STAND_PREP = false;
private static boolean createYoVariableServer = System.getProperty("create.yovariable.server") != null
&& Boolean.parseBoolean(System.getProperty("create.yovariable.server"));

private final RealtimeROS2Node realtimeROS2Node = ROS2Tools.createRealtimeROS2Node(PubSubImplementation.INTRAPROCESS,
"flat_ground_walking_track_simulation");
private final RealtimeROS2Node realtimeROS2Node = new ROS2NodeBuilder().buildRealtime("flat_ground_walking_track_simulation");
//private static final double SIMULATION_DT = 0.001;

public AtlasFlatGroundWalkingTrackSCS2Bullet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import us.ihmc.avatar.scs2.SCS2AvatarSimulation;
import us.ihmc.avatar.scs2.SCS2AvatarSimulationFactory;
import us.ihmc.commonWalkingControlModules.desiredFootStep.footstepGenerator.HeadingAndVelocityEvaluationScriptParameters;
import us.ihmc.communication.ROS2Tools;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;
import us.ihmc.ros2.ROS2NodeBuilder;
import us.ihmc.ros2.RealtimeROS2Node;
import us.ihmc.simulationConstructionSetTools.util.HumanoidFloatingRootJointRobot;
import us.ihmc.simulationConstructionSetTools.util.environments.FlatGroundEnvironment;
Expand All @@ -15,8 +14,7 @@ public class AtlasFlatGroundWalkingTrackSCS2ImpulseBased
private static boolean createYoVariableServer = System.getProperty("create.yovariable.server") != null
&& Boolean.parseBoolean(System.getProperty("create.yovariable.server"));

private final RealtimeROS2Node realtimeROS2Node = ROS2Tools.createRealtimeROS2Node(PubSubImplementation.INTRAPROCESS,
"flat_ground_walking_track_simulation");
private final RealtimeROS2Node realtimeROS2Node = new ROS2NodeBuilder().buildRealtime("flat_ground_walking_track_simulation");

public AtlasFlatGroundWalkingTrackSCS2ImpulseBased()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
package us.ihmc.atlas;

import java.util.HashMap;
import java.util.Map;

import com.martiansoftware.jsap.FlaggedOption;
import com.martiansoftware.jsap.JSAP;
import com.martiansoftware.jsap.JSAPException;
import com.martiansoftware.jsap.JSAPResult;

import us.ihmc.avatar.drcRobot.DRCRobotModel;
import us.ihmc.avatar.drcRobot.RobotTarget;
import us.ihmc.avatar.networkProcessor.kinemtaticsStreamingToolboxModule.KinematicsStreamingToolboxModule;
import us.ihmc.log.LogTools;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;
import us.ihmc.robotDataLogger.logger.DataServerSettings;
import us.ihmc.robotics.partNames.ArmJointName;
import us.ihmc.robotics.partNames.HumanoidJointNameMap;
import us.ihmc.robotics.partNames.LegJointName;
import us.ihmc.robotics.partNames.SpineJointName;
import us.ihmc.robotics.robotSide.RobotSide;

import java.util.HashMap;
import java.util.Map;

public class AtlasKinematicsStreamingToolboxModule extends KinematicsStreamingToolboxModule
{
public AtlasKinematicsStreamingToolboxModule(DRCRobotModel robotModel,
boolean startYoVariableServer,
PubSubImplementation pubSubImplementation)
boolean startYoVariableServer)
{
super(robotModel, startYoVariableServer, pubSubImplementation);
super(robotModel, startYoVariableServer);
controller.setInitialRobotConfigurationNamedMap(initialConfiguration(robotModel));
controller.getTools().getIKController().getCenterOfMassSafeMargin().set(0.10);
}
Expand Down Expand Up @@ -100,8 +97,6 @@ public static void main(String[] args) throws JSAPException
}

boolean startYoVariableServer = true;
PubSubImplementation pubSubImplementation = PubSubImplementation.FAST_RTPS;
LogTools.info("Using ROS 2 {} mode.", pubSubImplementation.name());
new AtlasKinematicsStreamingToolboxModule(robotModel, startYoVariableServer, pubSubImplementation);
new AtlasKinematicsStreamingToolboxModule(robotModel, startYoVariableServer);
}
}
10 changes: 6 additions & 4 deletions atlas/src/main/java/us/ihmc/atlas/AtlasNetworkProcessor.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package us.ihmc.atlas;

import com.martiansoftware.jsap.*;

import com.martiansoftware.jsap.FlaggedOption;
import com.martiansoftware.jsap.JSAP;
import com.martiansoftware.jsap.JSAPException;
import com.martiansoftware.jsap.JSAPResult;
import com.martiansoftware.jsap.Switch;
import us.ihmc.atlas.sensors.AtlasSensorSuiteManager;
import us.ihmc.avatar.drcRobot.RobotTarget;
import us.ihmc.avatar.networkProcessor.HumanoidNetworkProcessor;
import us.ihmc.communication.producers.VideoControlSettings;
import us.ihmc.log.LogTools;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;

import static us.ihmc.atlas.AtlasNetworkProcessor.NetworkProcessorMode.VR;

Expand Down Expand Up @@ -103,7 +105,7 @@ else if (config.getBoolean(runningOnGazebo.getID()))

LogTools.info("Selected model: {}", model);

HumanoidNetworkProcessor networkProcessor = new HumanoidNetworkProcessor(model, PubSubImplementation.FAST_RTPS);
HumanoidNetworkProcessor networkProcessor = new HumanoidNetworkProcessor(model);
LogTools.info("ROS_MASTER_URI = " + networkProcessor.getOrCreateRosURI());

LogTools.info("Setting up network processor modules...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package us.ihmc.atlas;

import java.net.URISyntaxException;

import com.martiansoftware.jsap.*;

import com.martiansoftware.jsap.FlaggedOption;
import com.martiansoftware.jsap.JSAP;
import com.martiansoftware.jsap.JSAPException;
import com.martiansoftware.jsap.JSAPResult;
import com.martiansoftware.jsap.Switch;
import us.ihmc.avatar.drcRobot.DRCRobotModel;
import us.ihmc.avatar.drcRobot.RobotTarget;
import us.ihmc.avatar.networkProcessor.HumanoidNetworkProcessor;
import us.ihmc.log.LogTools;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;

import java.net.URISyntaxException;

public class AtlasNetworkProcessorWithAutomaticDiagnosticRunner
{
Expand Down Expand Up @@ -65,7 +67,7 @@ else if(config.getBoolean(runningOnGazebo.getID()))

System.out.println("Using the " + model + " model");

HumanoidNetworkProcessor networkProcessor = new HumanoidNetworkProcessor(model, PubSubImplementation.FAST_RTPS);
HumanoidNetworkProcessor networkProcessor = new HumanoidNetworkProcessor(model);
LogTools.info("ROS_MASTER_URI = " + networkProcessor.getOrCreateRosURI());
networkProcessor.setupRosModule();
networkProcessor.setupBehaviorModule(true, true, 15.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import us.ihmc.avatar.networkProcessor.objectDetectorToolBox.ObjectDetectorToolboxModule;
import us.ihmc.commons.thread.ThreadTools;
import us.ihmc.log.LogTools;
import us.ihmc.pubsub.DomainFactory;
import us.ihmc.pubsub.DomainFactory.PubSubImplementation;

public class AtlasObjectDetectionModules
{
Expand All @@ -21,12 +19,10 @@ public AtlasObjectDetectionModules()
fiducialDetectorToolboxModule = new FiducialDetectorToolboxModule(robotModel.getSimpleRobotName(),
robotModel.getTarget(),
robotModel.createFullRobotModel(),
robotModel.getLogModelProvider(),
PubSubImplementation.FAST_RTPS);
robotModel.getLogModelProvider());
objectDetectorToolboxModule = new ObjectDetectorToolboxModule(robotModel.getSimpleRobotName(),
robotModel.createFullRobotModel(),
robotModel.getLogModelProvider(),
PubSubImplementation.FAST_RTPS);
robotModel.getLogModelProvider());

Runtime.getRuntime().addShutdownHook(new Thread(() ->
{
Expand Down
5 changes: 2 additions & 3 deletions atlas/src/main/java/us/ihmc/atlas/AtlasROS1MappingTopics.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import std_msgs.Header;
import us.ihmc.commons.thread.ThreadTools;
import us.ihmc.communication.HumanoidControllerAPI;
import us.ihmc.communication.ROS2Tools;
import us.ihmc.communication.configuration.NetworkParameters;
import us.ihmc.euclid.transform.RigidBodyTransform;
import us.ihmc.euclid.tuple3D.interfaces.Tuple3DReadOnly;
import us.ihmc.euclid.tuple4D.interfaces.QuaternionReadOnly;
import us.ihmc.pubsub.DomainFactory;
import us.ihmc.ros2.ROS2Node;
import us.ihmc.ros2.ROS2NodeBuilder;
import us.ihmc.utilities.ros.RosMainNode;
import us.ihmc.utilities.ros.RosTools;
import us.ihmc.utilities.ros.publisher.RosPointCloudPublisher;
Expand Down Expand Up @@ -62,7 +61,7 @@ public void onNewMessage(PointCloud2 pointCloud)
ros1Node.attachSubscriber(OUSTER_TOPIC_IN, pointCloudSubscriber);

AtomicReference<RobotConfigurationData> robotConfigurationDataHolder = new AtomicReference<>(new RobotConfigurationData());
ROS2Node ros2Node = ROS2Tools.createROS2Node(DomainFactory.PubSubImplementation.FAST_RTPS, "atlas_topics2");
ROS2Node ros2Node = new ROS2NodeBuilder().build("atlas_topics2");
ros2Node.createSubscription(HumanoidControllerAPI.getOutputTopic("Atlas").withTypeName(RobotConfigurationData.class),
s -> robotConfigurationDataHolder.set(s.takeNextData()));

Expand Down
16 changes: 8 additions & 8 deletions atlas/src/main/java/us/ihmc/atlas/AtlasRobotModel.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package us.ihmc.atlas;

import java.io.InputStream;
import java.util.Arrays;
import java.util.function.Consumer;

import com.jme3.math.Transform;
import us.ihmc.atlas.diagnostic.AtlasDiagnosticParameters;
import us.ihmc.atlas.initialSetup.AtlasSimInitialSetup;
Expand Down Expand Up @@ -51,13 +47,13 @@
import us.ihmc.footstepPlanning.graphSearch.parameters.DefaultFootstepPlannerParametersBasics;
import us.ihmc.footstepPlanning.swing.SwingPlannerParametersBasics;
import us.ihmc.jMonkeyEngineToolkit.jme.util.JMEDataTypeUtils;
import us.ihmc.perception.depthData.CollisionBoxProvider;
import us.ihmc.log.LogTools;
import us.ihmc.mecano.multiBodySystem.interfaces.OneDoFJointBasics;
import us.ihmc.modelFileLoaders.SdfLoader.SDFModelLoader;
import us.ihmc.multicastLogDataProtocol.modelLoaders.DefaultLogModelProvider;
import us.ihmc.multicastLogDataProtocol.modelLoaders.LogModelProvider;
import us.ihmc.pathPlanning.visibilityGraphs.parameters.VisibilityGraphsParametersBasics;
import us.ihmc.perception.depthData.CollisionBoxProvider;
import us.ihmc.robotDataLogger.logger.DataServerSettings;
import us.ihmc.robotModels.FullHumanoidRobotModel;
import us.ihmc.robotModels.FullHumanoidRobotModelWrapper;
Expand All @@ -68,7 +64,7 @@
import us.ihmc.robotiq.model.RobotiqHandModel;
import us.ihmc.robotiq.simulatedHand.SimulatedRobotiqHandKinematicController;
import us.ihmc.robotiq.simulatedHand.SimulatedRobotiqHandsControlThread;
import us.ihmc.ros2.ROS2NodeInterface;
import us.ihmc.ros2.ROS2Node;
import us.ihmc.ros2.RealtimeROS2Node;
import us.ihmc.scs2.definition.robot.RobotDefinition;
import us.ihmc.scs2.definition.visual.ColorDefinition;
Expand All @@ -84,6 +80,10 @@
import us.ihmc.wholeBodyController.diagnostics.DiagnosticParameters;
import us.ihmc.yoVariables.providers.DoubleProvider;

import java.io.InputStream;
import java.util.Arrays;
import java.util.function.Consumer;

public class AtlasRobotModel implements DRCRobotModel
{
public final static boolean SCALE_ATLAS = false;
Expand Down Expand Up @@ -514,7 +514,7 @@ public AtlasSensorSuiteManager getSensorSuiteManager()
}

@Override
public AtlasSensorSuiteManager getSensorSuiteManager(ROS2NodeInterface ros2Node)
public AtlasSensorSuiteManager getSensorSuiteManager(ROS2Node ros2Node)
{
if (sensorSuiteManager == null)
{
Expand Down Expand Up @@ -717,7 +717,7 @@ public DiagnosticParameters getDiagnoticParameters()
}

@Override
public RobotLowLevelMessenger newRobotLowLevelMessenger(ROS2NodeInterface ros2Node)
public RobotLowLevelMessenger newRobotLowLevelMessenger(ROS2Node ros2Node)
{
return new AtlasDirectRobotInterface(ros2Node, this);
}
Expand Down
Loading
Loading